I've been reading a bit about threads and interrupts. And there is a sections which says that parallel programing using threads is simpler because we don't have to worry about interrupts.
However, what is the mechanism in which signals the release of the blocking system call if not an interrupt?
Example
I read i file in my thread which use a blocking system call to read the file from the disk.
During that time, other threads are running.
At some point the file is ready to be read from the hard disk.
Does it notify the processor of this via a hardware interrupt, so that it can do a context switch ti the thread which asked for the file?
Best Answer
Interrupts are handled by the operating system, threads (or processes, for that matter) aren't even aware of them.
In the scenario you paint:
read()
system call; the kernel gets the request, realizes that the thread won't do anything until data arrives (blocking call), so the thread is blocked.Something like that, anyway. No, the CPU isn't asigned to the waiting thread when an interrupt happens to signal completion of the transfer. It might interrupt another thread, and execution probably resumes that thread (or perhaps another one might be selected).