Tuesday 15 January 2013

python - How is waiting for I/O or waiting for a lock to be released implemented? -


I'm curious. I was programming in Python for years. When I run a command that blocks the I / O (whether it is read on hard disk or is a network request), or blocks at the time of release on the lock, how is it implemented? How does the thread know that to start GIL again and start over again?

I wonder if it has been continuously tested and implemented ("Is there a production here? Is it right now? What about now?") Which I think is meaningless, or alternative In a more beautiful way.

There is no need to check repeatedly for I / O termination or for release of lock .

An I / O fullness, a hardware-driven driver is prompted, or because of any other thread disturbed by the software, lock releases, threads were waiting instantly on those operations, And were quite likely to walk, and were preparing for another thread during walking. Essentially, after being in the middle of software or hardware, the OS can decide to embed - compared to being interrupted can return to a different thread.

High I / O performance of this mechanism, eliminating any polling or investigation, is a matter of very little time.

No comments:

Post a Comment