img
. . . . .
The POSIX Multithreaded Model
In the POSIX multithreaded model (see Figure 3-5), threads are the portable application-level
interface. Programmers write applications using the appropriate API. The underlying threads
library schedules the threads onto LWPs. The LWPs in turn are implemented by kernel threads[5]
in the kernel. These kernel threads are then scheduled onto the available CPUs by the standard
kernel scheduling routine, completely invisible to the user. This picture is accurate for POSIX
threads. It is equally applicable for Win32 and Java threads, save that there are some limitations
regarding the binding of threads to LWPs (see Different Models of Kernel Scheduling).
[5]
All the kernels are implemented using a threads library, often similar to Pthreads (Solaris kernel
threads are very similar; DEC's kernel threads were based on Mach and are quite different). These
kernel threads are used to implement LWPs. The kernel also uses them for its own internal tasks,
such as the page daemon. The term kernel thread is not used uniformly, and many people use it to
refer to LWPs (or logical equivalent). We will not deal with kernel threads at all.
Figure 3-5. POSIX Multithreaded Architecture
System Calls
A system call is the way that multitasking operating systems allow user processes to get
information or request services from the kernel. Such things as "Write this file to the disk" and
"How many users are on the system?" are done with system calls. We divide system calls into two
categories, blocking and nonblocking calls. In a blocking system call, such as "Read this file from
the disk," the program makes the call, the operating system executes it and returns the answer, and
the program proceeds. If a blocking system call takes a long time, the program just waits for it.
(Usually, another process will be scheduled while this one is waiting.)
In a nonblocking system call, such as "Write this file to the disk without waiting," the program
makes the call, the operating system sets up the parameters for the write, then returns, and the
program continues. Exactly when the disk write actually occurs is not particularly important, and
the program is able to continue working. A nonblocking system call may send the process a signal
Search WWH :
Custom Search
Previous Page
Multithreaded Programming with JAVA - Topic Index
Next Page
Multithreaded Programming with JAVA - Bookmarks
Home