img
. .
Chapter 5. Scheduling
·
Different Models of Kernel Scheduling
·
Thread Scheduling
·
Context Switching
·
Java Scheduling Summary
·
When Should You Care About Scheduling?
·
APIs Used in This Chapter
·
The Class java.lang.Thread
In which we explain the myriad details of various scheduling models and alternative choices that
could be made, describe context switching in detail, and delve into gruesome detail on various
design options. There is light at the end of the tunnel, however.
Different Models of Kernel Scheduling
There are three primary techniques for scheduling threads onto kernel resources (and indirectly,
onto CPUs). Two of them involve the use of LWPs (or something similar). These are the
techniques from which the designers of the various operating systems had to choose. They wanted
a model that would adequately support the complexity of the operating system and still meet the
various demands of dedicated programmers. All three models are perfectly reasonable and give
the programmer different sets of trade-offs, simultaneously building programs that do exactly the
same things with different levels of efficiency. All three of these models are in use by different
vendors.
Many Threads on One LWP
The first technique is known as the many-to-one model. It is also known as co-routining.[1]
Numerous threads are created in user space, and they all take turns running on the one LWP.
Programming on such a model will give you a superior programming paradigm, but running your
program on an MP machine will not give you any speedup, and when you make a blocking system
call, the whole process will block. However, the thread creation, scheduling, and synchronization
are all done 100% in user space, so they're done fast and cheap and use no kernel resources. This
is how green threads[2] works. The DCE threads library also followed this model on HP-UX 10.20.
[1]
The exact use of this term varies from topic to topic, but in broad terms, this is accurate.
[2]
During the initial design phase of Java, Sun's native threading library wasn't complete and the
"Green" group chose to implement a simpler library rather than wait. All of the early
implementations of Java were based on green threads.
Search WWH :
Custom Search
Previous Page
Multithreaded Programming with JAVA - Topic Index
Next Page
Multithreaded Programming with JAVA - Bookmarks
Home