By Daniel P. Bovet, Marco Cesati
Book Price: $49.95 USD
£35.50 GBP
PDF Price: $39.99
Cover | Table of Contents
/). Names must be different within the same
directory, but the same name may be used in different
directories.0x00000000 to
0xffffffff.
cs, ss, ds,
es, fs, and gs. Although there are only six of them, a
program can reuse the same segmentation register for different
purposes by saving its content in memory and then restoring it
later.csssds Segment | Base
| G
| Limit | S
|
|---|
PG flag of
a control register named cr0
. When PG = 0, linear
addresses are interpreted as physical addresses.
task_struct
type structure whose fields contain all the information related to a
single process. As the repository of so much information, the process
descriptor is rather complex. In addition to a large number of fields
containing process attributes, the process descriptor contains several
pointers to other data structures that, in turn, contain pointers to
other structures. Figure
3-1 describes the Linux process descriptor schematically.state field of the process descriptor
describes what is currently happening to the process. It consists of
an array of flags, each of which describes a possible process state.
In the current Linux version, these states are mutually exclusive, and
hence exactly one flag of state
always is set; the remaining flags are cleared. The following are the
possible process states:TASK_RUNNINGTASK_INTERRUPTIBLEprev local variable refers to the process
descriptor of the process being switched out and next refers to the one being switched in to
replace it. We can thus define a process switch
as the activity consisting of saving the hardware context of prev and replacing it with the hardware
context of next. Because process
switches occur quite often, it is important to minimize the time
spent in saving and loading hardware contexts.far jmp instruction to the selector of the Task State Segment Descriptor of
the next process. While executing
the instruction, the CPU performs a hardware context
switchexecve( ) and wipes out the
address space that was so carefully copied.vfork( ) system call
creates a process that shares the memory address space of its
parent. To prevent the parent from overwriting data needed by the
child, the parent's execution is blocked until the child exits or
executes a new program. We'll learn more about the vfork( ) system call in the following
section.clone( ), which uses
the following parameters:exit( ) library function, which releases the
resources allocated by the C library, executes each function registered
by the programmer, and ends up invoking a system call that evicts the
process from the system. The exit( )
library function may be inserted by the programmer
explicitly. Additionally, the C compiler always inserts an exit( ) function call right after the last
statement of the main( )
function.exit_group( )
system call, which terminates a full thread group,
that is, a whole multithreaded application. The main kernel
function that implements this system call is called do_group_exit( ). This is the system
call that should be invoked by the exit() C library function._exit( ) system call, which terminates a single process,
regardless of any other process in the thread group of the victim.
The main kernel function that implements this system call is
called do_exit( ). This is the
system call invoked, for instance, by the pthread_exit( ) function of the LinuxThreads library.int
or sysenter —for a kernel service.eip and cs
registers) in the Kernel Mode stack and by placing an address related to
the interrupt type into the program counter.eip register that is saved on the
Kernel Mode stack when the CPU control unit raises the
exception.eip is the address
of the instruction that caused the fault, and hence that
instruction can be resumed when the exception handler
terminates. As we'll see in the section "Page Fault Exception
Handler" in Chapter
9, resuming the same instruction is necessary whenever
the handler is able to correct the anomalous condition that
caused the exception.