Single-Queue Scheduling
This lesson describes the single-queue scheduling mechanism and covers its strengths and shortcomings.
We'll cover the following
With the background in place, we now discuss how to build a scheduler for a multiprocessor system. The most basic approach is to simply reuse the basic framework for single processor scheduling, by putting all jobs that need to be scheduled into a single queue; we call this single-queue multiprocessor scheduling or SQMS for short. This approach has the advantage of simplicity; it does not require much work to take an existing policy that picks the best job to run next and adapt it to work on more than one CPU (where it might pick the best two jobs to run, if there are two CPUs, for example).
Shortcomings of SQMS
However, SQMS has obvious shortcomings:
Lack of scalability
The first problem is a lack of scalability. To ensure the scheduler works correctly on multiple CPUs, the developers will have inserted some form of locking into the code, as described above. Locks ensure that when SQMS code accesses the single queue (say, to find the next job to run), the proper outcome arises.
Cache affinity
The second main problem with SQMS is cache affinity. For example, let us assume we have five jobs to run (A, B, C, D, E) and four processors. Our scheduling queue thus looks like this:
Over time, assuming each job runs for a time slice and then another job is chosen, here is a possible job schedule across CPUs:
Get hands-on with 1400+ tech skills courses.