On Thursday 24 July 2008, 17:09, Alan McKinnon wrote:

> > 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.

From what I know, "blocked" is the same as "sleeping", ie waiting for 
something to happen. Tasks that have completed their time slice and are 
forced by the scheduler to stop, are not "sleeping"; they are 
re-inserted in the queue of the runnable processes, and the scheduler 
picks them up again from there when another time slice is assigned to 
them. These processes are in the "runnable" or "ready" state.

But of course I may be wrong, so corrections welcome.

Reply via email to