As far as all books say, switching between tasks/processes is more expensive than switching between threads of the same process/task. If so, then scheduler of threads-aware OS should schedule threads in such way that the threads of the same process/task should be executed next to each other (grouped) and not interleaved with threads from other processes/tasks.
As I am reading books on OSes, all books just stop at stating that threads switching is less expensive than process switching. And that's it. No book tells how exactly scheduler is solving problem of avoiding switching between threads of different tasks. As if such problem does not exist or is trivial to each and every reader.
Is my understanding of the problem not correct? Or am I missing something? Why such huge topic of possible performance degrade is not covered in each and every OS book in "Scheduling" chapter? Am I reading wrong books?
A user-level thread is a thread that the OS does not know about. The OS only knows about the process containing the threads. The OS only schedules the process, not the threads within the process.
HARDWARE SUPPORT: THE TIMER INTERRUPT The addition of a timer interrupt gives the OS the ability to regain control of the CPU even if processes act in a non- cooperative fashion. Thus, this hardware is key in helping the OS maintain control of the system.
Scheduling of threads involves two boundary scheduling, Scheduling of user level threads (ULT) to kernel level threads (KLT) via lightweight process (LWP) by the application developer. Scheduling of kernel level threads by the system scheduler to perform different unique os functions.
By limiting each task to a certain amount of time, the operating system can ensure that it can cycle through all ready tasks, giving each one a chance to run. With round robin scheduling, interactive performance depends on the length of the quantum and the number of processes in the run queue.
In my opinion this would be a dangerous optimization, because if the scheduler favored threads based on whether or not the process memory pages are already loaded two things would happen:
The scheduler's main priorities are:
It's pretty easy to see that these 3 conditions conflict with the mentioned optimization.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With