IBM REDP-4285-00 Manual De Usuario

Descargar
Página de 170
4285ch01.fm
Draft Document for Review May 4, 2007 11:35 am
4
 
Linux Performance and Tuning Guidelines
1.1.2  Lifecycle of a process
Every process has its own lifecycle such as creation, execution, termination and removal. 
These phases will be repeated literally millions of times as long as the system is up and 
running. Therefore, the process lifecycle is a very important topic from the performance 
perspective.
Figure 1-3 shows typical lifecycle of processes.
Figure 1-3   Lifecycle of typical processes 
When a process creates new process, the creating process (parent process) issues a fork() 
system call. When a fork() system call is issued, it gets a process descriptor for the newly 
created process (child process) and sets a new process id. It then copies the values of the 
parent process’s process descriptor to the child’s. At this time the entire address space of the 
parent process is not copied; both processes share the same address space.
The exec() system call copies the new program to the address space of the child process. 
Because both processes share the same address space, writing new program data causes a 
page fault exception. At this point, the kernel assigns the new physical page to the child 
process.
This deferred operation is called the 
Copy On Write
. The child process usually executes their 
own program rather than the same execution as its parent does. This operation is a 
reasonable choice to avoid unnecessary overhead because copying an entire address space 
is a very slow and inefficient operation which uses much processor time and resources. 
When program execution has completed, the child process terminates with an exit() system 
call. The exit() system call releases most of the data structure of the process, and notifies 
the parent process of the termination sending a certain signal. At this time, the process is 
called a 
zombie process
The child process will not be completely removed until the parent process knows of the 
termination of its child process by the wait() system call. As soon as the parent process is 
notified of the child process termination, it removes all the data structure of the child process 
and release the process descriptor. 
1.1.3  Thread
thread
 is an execution unit which is generated in a single process and runs in parallel with 
other threads in the same process. They can share the same resources such as memory, 
address space, open files and so on. They can access the same set of application data. A 
thread is also called 
Light Weight Process
 (LWP). Because they share resources, each thread 
should take care not to change their shared resources at the same time. The implementation 
of mutual exclusion, locking and serialization etc. are the user application’s responsibility.
parent
process
child
process
child
process
zombie
process
parent
process
wait()
fork()
exec()
exit()
parent
process
child
process
child
process
zombie
process
parent
process
wait()
fork()
exec()
exit()