Switching to Another Thread
The system offers a function called SwitchToThread
that allows another schedulable thread to run if one exists:
BOOL SwitchToThread();
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 ...
Get Windows® via C/C++, Fifth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.