threading
Roy Smith
roy at panix.com
Wed Apr 9 10:52:43 EDT 2014
In article <mailman.9078.1397053837.18130.python-list at python.org>,
"Frank Millman" <frank at chagford.com> wrote:
> "Chris Angelico" <rosuav at gmail.com> wrote in message
> news:CAPTjJmqwhb8O8vq84mMTv+-Rkc3Ff1AQDXe5cs8Y5gY02kHyNg at mail.gmail.com...
> > On Wed, Apr 9, 2014 at 11:23 PM, Frank Millman <frank at chagford.com> wrote:
> >
> >> How does one distinguish betwen 'blocking' and 'non-blocking'? Is it
> >> either/or, or is it some arbitrary timeout - if a handler returns within
> >> that time it is non-blocking, but if it exceeds it it is blocking?
> >
> > No; a blocking request is one that waits until it has a response, and
> > a non-blocking request is one that goes off and does something, and
> > then comes back to you when it's done.
>
> Does reading from disk count as blocking? Strictly speaking I would have
> thought 'yes'.
Of course it does. But, the bigger question is, "What counts as reading
from disk?"
In the old days, all Unix system calls were divided up into two groups,
based on whether they were "fast" or "slow". Processes executing a
"fast" system call would block, and could not be interrupted; i.e. any
signals delivered to them would be queued up and delivered after the
system call had finished. Typically, that meant, if you typed
Control-C, your process wouldn't get killed until the system call it was
executing completed.
Disk reads were considered fast. You type Control-C, the read takes
another few ms to finish, then your process gets whacked. You never
even notice the delay. But, a read on a tty was slow. It would sit
there forever, until you hit return. Slow system calls got interrupted.
Then, along came the network, and everything got confusing. If I open a
file that lives on an NFS server, and read from it, am I doing a disk
read? Should I be able to interrupt an NFS operation?
More information about the Python-list
mailing list