. . . . . . . .
In a typical multitasking operating system such as VMS, UNIX, Windows NT, etc., this dividing
line between the user space and the kernel space is solid (Figure 2-2); it's enforced by the
hardware. There are actually two different modes of operation for the CPUs: user mode, which
allows normal user programs to run, and kernel mode, which also allows some special instructions
to run that only the kernel can execute. These kernel-mode instructions include I/O instructions,
processor interrupt instructions, instructions that control the state of the virtual memory subsystem,
and, of course, the change mode instruction.
Figure 2-2. Memory Layout for Multitasking Systems
So a user program can execute only user-mode instructions, and it can execute them only in user
space. The data it can access and change directly is also limited to data in user space. When it
needs something from the kernel (say, it wants to read a file or find out the current time), the user
program must make a system call. This is a library function that sets up some arguments, then
executes a special trap instruction. This instruction causes the hardware to trap into the kernel,
which then takes control of the machine. The kernel figures out what the user wants (based upon
the data that the system call set up) and whether the user has permission to do so. Finally, the
kernel performs the desired task, returning any information to the user process.
Because the operating system has complete control over I/O, memory, processors, etc., it needs to
maintain data for each process it's running. The data tells the operating system what the state of
that process is--what files are open, which user is running it, etc. So, the concept of process in the
multitasking world extends into the kernel (see Figure 2-2), where this information is maintained
in a process structure. In addition, as this is a multitasking world, more than one process can be
active at the same time, and for most of these operating systems (notably, neither Windows NT
Search WWH :
Custom Search
Previous Page
Multithreaded Programming with JAVA - Topic Index
Next Page
Multithreaded Programming with JAVA - Bookmarks