1  Understanding Threads

(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''.

1.1  Threads and 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.

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.

1.2  The Initial Thread

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.