
Normally, the parent performs a wait() and cleans up the PID. When a process dies, it becomes a zombie process.

Higher numbered priorities are given precedence. No system protection between threads in a process the programmer is responsible for interactions.Ĭan share information between threads without IPC overhead. User threads are also responsible for handling of SIGSEGV (segmentation violation) signals, since the kernel does not keep track of user thread stacks.Įach thread has the following characteristics:Įxecutes independently (and perhaps concurrently with other threads).Ĭompletely invisible from outside the process.Ĭannot be controlled from the command line. Locking issues must also be carefully considered by the programmer in order to prevent several threads from blocking on a single resource. If time slicing is desired, it must be programmed in.

This scheduler does implement priorities, but does not implement time slicing. User threads are scheduled on their LWPs via a scheduler in libthread. Lightweight process information for a process can be examined with ps -elcL. The programmer can specify that threads are bound to LWPs.

Pointer to the associated proc structure.īy default, one LWP is assigned to each process additional LWPs are created if all the process's LWPs are sleeping and there are additional user threads that libthread can schedule. System call arguments, results, error codes. Saved values of user-level registers (if the LWP is not active) LWPs contain the following information in their data structure: IPC (interprocess communication) facilities exist for coordinating access to shared resources. All LWPs in a process share a common address space. LWPs can make system calls and can block while waiting for resources. Application threads are attached to available lightweight processes, which are attached to a a kernel thread, which is scheduled on the system's CPU dispatch queue. Context switching between kernel threads is very fast because memory mappings do not have to be flushed.Ī lightweight process can be considered as the swappable portion of a kernel thread.Īnother way to look at a lightweight process is to think of them as "virtual CPUs" which perform the processing for applications. Kernel threads can be independently scheduled on CPUs. Information about the associated LWP (as appropriate). Pointers to maintain queues of threads in a process and threads in the system. Pointers to associated LWP and proc structures. Pointers to put the thread on the scheduler or wait queue. Kernel threads store the following in their data structure: It uses kernel text and global data, but has its own kernel stack, as well as a data structure to hold scheduling and syncronization information. If no lightweight process is attached, it is also known as a system thread. Interprocess communication also takes considerably less time for threads than for processes, since global data can be shared instantly.Ī kernel thread is the entity that is scheduled by the kernel. Sun reports that a fork() takes 30 times as long as an unbound thread creation and 5 times as long as a bound thread creation.Įven within a single-processor environment, multiple threads are advantageous because one thread may be able to progress even though another thread is blocked while waiting for a resource. The main benefit of threads (as compared to multiple processes) is that the context switches are much cheaper than those required to change current processes. Threads also have private resources (program counter, stack, register context, etc). It shares global resources within the context of the process (address space, open files, user credentials, quotas, etc). A thread is a control point within a process. Threads are frequently used to increase an application's concurrency.Ī thread represents a relatively independent set of instructions within a program. Concurrency is the maximum acheivable parallelism in a theoretical machine that has an unlimited number of processors. In the real world, this is limited by the number of processors available in the hardware configuration. PID:- is the process idUSERNAME:- is the unix username.THR:- indicates the number of execution threads in the process.ThreadsĪn application's parallelism is the degree of parallel execution acheived. Load Averages: Displays the processor average load in every 1, 5, 15 minutes.

Commands to view the performance of the Sun servers:
