On Thursday 24 July 2008, b.n. wrote:

>
> I jump here to relief my everlasting UNIX ignorance.
>
> What does it mean a process is "sleeping", technically?

It's a misnomer, it means "not running".

The cpu gives the illusion of executing many tasks simultaneously. In 
reality, it is executing them one at a time and very rapidly (many 
times a second) switching between them.

Normally at a given instant in time, one task is running per cpu. The 
rest are mostly waiting their turn or sleeping. There are various OS 
strategies for bringing this about - some rely on the task itself to 
back out after a running for a short while, sometimes the OS kernel 
enforces it, sometimes you have a combination. If everything is working 
nicely, the end result is pretty much the same.

There's another state worthy of note - blocked. This is when a task is 
waiting for something else to happen first (most often disk or network 
I/O) so it won't try and execute till that other thing happens. This is 
not the same as sleeping. Sleeping is spinning you wheels in idle, 
blocked is a deliberate stop and sit back and wait.

hth

alan


-- 
Alan McKinnon
alan dot mckinnon at gmail dot com


Reply via email to