. .
Thread Scheduling
As we have just seen, there are two basic levels to scheduling threads: process local scheduling
(also known as process contention scope, or unbound threads--the many-to-many model) and
system global scheduling (also known as system contention scope, or bound threads--the one-to-
one model). These scheduling classes are known as the scheduling contention scope, and are
defined concepts only in POSIX. In Win32 and in Java there is no such concept defined in the
specs, no functions to select different models, no method of changing the default behavior at all.
This is a limitation in some Java implementations and forces the user to call some native methods
in order to get to the desired behavior (see How to Get Those LWPs in Java). Certain things
cannot be done at all.
Process contention scope scheduling means that all of the scheduling mechanism for the thread is
local to the process--the threads library has full control over which thread will be scheduled on an
LWP. This also implies the use of either the many-to-one or many-to-many model. This is the
scheduling method used for Java on Solaris. (Actually, POSIX allows PCS to be implemented as
SCS, although we are not aware of any implementations that do so.)
System contention scope scheduling means that the scheduling is done by the kernel (i.e., one-to-
one binding). POSIX allows both (it doesn't require both), whereas Win32 specifies only global
scheduling. As it turns out, system contention scope scheduling is invariably what the programmer
really wants on many platforms (e.g., Solaris). It provides the most predictable behavior and best
The entire subject of scheduling is fraught with problems. In all operating systems, both the
scheduling of threads and the scheduling of processes themselves have problems that have never
been resolved to everyone's satisfaction. In brief, there are two basic situations in which we find
ourselves (see Figure 5-1).
Figure 5-1. The Two Basic Types of Scheduling
The first case (the independent case) occurs when two processes (or threads) are running almost
completely independently--neither ever has anything it wants from the other, and both would
Search WWH :
Custom Search
Previous Page
Multithreaded Programming with JAVA - Topic Index
Next Page
Multithreaded Programming with JAVA - Bookmarks