(adopted from the AIX 4.3 Programmer's Manual)
A thread is an independent flow of control that operates within the same address space as other independent flows of controls within a process. In most of UNIX systems, thread and process characteristics are grouped into a single entity called a process. Sometimes, threads are called ``lightweight processes''.
In traditional single-threaded process systems, a process has a set of properties. In multi-threaded systems, these properties are divided between processes and threads.
A process in a multi-threaded system is the changeable entity. It must be considered as an execution frame. It has all traditional process attributes, such as:
A process also provides a common address space and common system resources:
A thread is the schedulable entity. It has only those properties that are required to ensure its independent flow of control. These include the following properties:
An example of thread-specific data is the error indicator, errno. In multi-threaded systems, errno is no longer a global variable, but usually a subroutine returning a thread-specific errno value. Some other systems may provide other implementations of errno.
With respect to ROOT, a thread specific data is for example the gPad pointer, which is treated in a different way, whether it is accessed from any thread or the main thread.
Threads within a process must not be considered as a group of processes (even though in Linux each thread receives an own process id, so that it can be scheduled by the kernel scheduler). All threads share the same address space. This means that two pointers having the same value in two threads refer to the same data. Also, if any thread changes one of the shared system resources, all threads within the process are affected. For example, if a thread closes a file, the file is closed for all threads.
When a process is created, one thread is automatically created. This thread is called the initial thread or the main thread. It is the initial thread that executes the main routine in multi-threaded programs.
File translated from TEX by TTH,
version 2.30.
On 18 Apr 2000, 14:42.