[ prev | next | up ]

Making sense of the scheduler

I suspect that much of the confusion regarding the scheduler is because students are viewing it in terms of a Unix-like preemptive system that runs as a separate process. This is natural, because that's the only sort of scheduler you've seen so far. For this assignment, though, the scheduler is neither a separate process nor a separate thread. Think of the scheduler simply as "the mechanism by which your threads library selects the next thread to run whenever a context switch occurs."

The introduction of the ThreadsUseScheduler() function doesn't really change this mechanism: on a context switch, your library will still select the next ready thread with highest priority. The difference is simply that once ThreadsUseScheduler() is invoked, priority no longer refers to the user assigned "external priority" but to an internally computed value (that is based, in part, on external priority). In other words, the call to ThreadsUseScheduler() just changes the way this calculation is performed.