threading

Terry Reedy tjreedy at udel.edu
Wed Apr 9 12:14:15 EDT 2014


On 4/9/2014 10:30 AM, Frank Millman wrote:

> In other words, non-blocking implies that everything required to pass off
> the request to a handler and be ready to deal with the next one must already
> be in memory, and it must not rely on communicating with any outside
> resource at all. Is this correct?

Chris said no, I would have said yes, but I think we understand the 
above differently. The important point is that there are two goals.

The first is to avoid having the cpu sitting idle when there is work to 
be done. Switching processes, switching threads within a process, and 
switching tasks within a thread are all aimed at this. (So are compiler 
code rearrangements that aim to keep various parts of a cpu, such 
integer and float arithmetic units, active simultaneously.)

The second, usually, is to keep the system responsive by not letting any 
particular work unit hog the cpu. But note that is work units are made 
too small, cpu time is wasted in excessive switching overhead.

A handler should neither waste nor monopolize cpu time. If input data is 
needed for a long computation, the handler should store the data where 
it needs to be for the computation but leave the actual computation to a 
background or idle task that runs when there is nothing else to do.

-- 
Terry Jan Reedy





More information about the Python-list mailing list