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?