Suppose I have a C# thread doing some blocking IO and waiting for it to finish. Now the OS scheduler gives it CPU time. Will it be given back right away or will it just be used by the thread doing nothing?
Or perhaps something entirely else?
Suppose I have a C# thread doing some blocking IO and waiting for it
Share
On Windows blocking IO to any device (accessible via the file system interface or others) works by sending the IO request to the driver associated with the device, along with a handle to an event object, and then blocks the calling thread by waiting on that event object. (The event would get signaled when driver completes the IO). Hence when a thread does blocking IO it does not hog the CPU as it is only waiting on the event handle.
All blocking IO API(s) works in this fashion with probably subtle differences in implementation.