The system offers a function called
SwitchToThread that allows another schedulable thread to run if one exists:
When you call this function, the system checks to see whether there is a thread that is being starved of CPU time. If no thread is starving,
SwitchToThread returns immediately. If there is a starving thread,
SwitchToThread schedules that thread (which might have a lower priority than the thread calling
SwitchToThread). The starving thread is allowed to run for one time quantum and then the system scheduler operates as usual.
This function allows a thread that wants a resource to force a lower-priority thread that might currently own the resource to relinquish the resource. If no other thread ...