IBM REDP-4285-00 User Manual

Page of 170
Chapter 1. Understanding the Linux operating system 
5
Draft Document for Review May 4, 2007 11:35 am
4285ch01.fm
From the performance perspective, thread creation is less expensive than process creation 
because a thread does not need to copy resources on creation. On the other hand, processes 
and threads have similar characteristics in term of scheduling algorithm. The kernel deals 
with both of them in the similar manner. 
Figure 1-4   process and thread
In current Linux implementations, a thread is supported with the POSIX (Portable Operating 
System Interface for UNIX) compliant library (
pthread
). There are several thread 
implementations available in the Linux operating system. The following are the widely used.
򐂰
LinuxThreads
LinuxThreads have been the default thread implementation since Linux kernel 2.0 was 
available. The LinuxThread has some noncompliant implementations with the POSIX 
standard. NPTL is taking the place of LinuxThreads. The LinuxThreads will not be 
supported in future release of Enterprise Linux distributions.
򐂰
Native POSIX Thread Library (NPTL)
The NPTL was originally developed by Red Hat. NPTL is more compliant with POSIX 
standards. Taking advantage of enhancements in kernel 2.6 such as the new clone() 
system call, signal handling implementation etc., it has better performance and scalability 
than LinuxThreads. 
There is some incompatibility with LinuxThreads. An application which has a dependence 
on LinuxThread may not work with the NPTL implementation.
򐂰
Next Generation POSIX Thread (NGPT)
NGPT is an IBM developed version of POSIX thread library. It is currently under 
maintenance operation and no further development is planned.
Using the LD_ASSUME_KERNEL environment variable, you can choose which threads library the 
application should use. 
1.1.4  Process priority and nice level
Process priority
 is a number that determines the order in which the process is handled by the 
CPU and is determined by dynamic priority and static priority. A process which has higher 
process priority has higher chances of getting permission to run on processor. 
The kernel dynamically adjusts dynamic priority up and down as needed using a heuristic 
algorithm based on process behaviors and characteristics. A user process can change the 
static priority indirectly through the use of the 
nice
 level of the process. A process which has 
higher static priority will have longer time slice (how long the process can run on processor).
Process
Process
resource
e
resource
resourc
resource
resource
e
resource
resource
copy
Process
Thread
Thread
Threa
ad
Thread
Thread
Thread
Threa
ad
Thread
resource
e
resource
resource
share
share
Process creation
Thread creation