img
. . . . . . .
Chapter 2. Concepts
Background: Traditional Operating Systems
What Is a Thread?
Kernel Interaction
The Value of Using Threads
What Kinds of Programs to Thread
What About Shared Memory?
Threads Standards
Performance
In which the reader is introduced to the basic concepts of multitasking operating systems and of
multithreading as it compares to other programming paradigms. The reader is shown reasons why
multithreading is a valuable addition to programming paradigms, and a number of examples of
successful deployment are presented.
Background: Traditional Operating Systems
Before we get into the details of threads, it will be useful for us to have some clear understanding
of how operating systems without threads work. In the simplest operating system world of single-
user, single-tasking operating systems such as DOS, everything is quite easy to understand and to
use, although the functionality offered is minimal.
DOS divides the memory of a computer into two sections: the portion where the operating system
itself resides (kernel space[1]) and the portion where the programs reside (user space). The division
into these two spaces is done strictly by the implicit agreement of the programmers involved--
meaning that nothing stops a user program from accessing data in kernel space. This lack of
hardware enforcement is good, because it is simple and works well when people write perfect
programs. When a user program needs some function performed for it by kernel code (such as
reading a file from a disk), the program can call the DOS function directly to read that file.
[1]
Kernel space is UNIX lingo for this concept, but the concept is valid for all operating systems.
Each program has some code that it runs (which is just a series of instructions, where the program
counter points to the current instruction), some data (global and local) that it uses, and a stack
where local data and return addresses are stored (the stack pointer designates the current active
location on the stack).
Figure 2-1 illustrates the traditional DOS operating system memory layout. Thus, as shown in
Figure 2-1, the division between user space and kernel space is a division by agreement of the
programmers; there is no hardware enforcement of the policy at all. The drawbacks to this
technique are significant, however. Not all programs are written flawlessly, and a programming
mistake (or virus!) here can bring down the entire machine or, worse, destroy valued data. Neither
can a machine run more than one program at a time, nor can more than one user log in to the
machine at a time. Dealing with networks from DOS machines is somewhat awkward and limited.
Figure 2-1. Memory Layout for DOS-Style Operating Systems
Search WWH :
Custom Search
Previous Page
Multithreaded Programming with JAVA - Topic Index
Next Page
Multithreaded Programming with JAVA - Bookmarks
Home