(0) Threads Single Threaded and Multithreaded Process Models
Lightweight process (LW)

Single threaded programs have one path of execution, Single threaded programs can perform only one task at a time, and have to finish each task in sequence before they can start another. For most programs, one thread of execution is all you need, but sometimes it makes sense to use multiple threads in a program to accomplish multiple simultaneous tasks. In a single processor environment, the processor 'context switches' between different threads. In this case, the processing is not literally simultaneous, for the single processor is really doing only one thing at a time. This switching can happen so fast as to give the illusion of simultaneity to an end user.
Multiple threads can be executed in parallel across many computer systems. This is multithreading, and generally occurs by time slicing (similar to time-division multiplexing) across the computer systems. multi-threaded programs have two or more paths of execution.
Welcome
Blog Archive
(0) User Thread
•Managed by user-level Threads Library
–No support from the kernel (The kernel is not aware of the existence of threads)
–Fast to create and manage
–Block all threads for a blocking system call if the kernel is single threaded–Cannot take advantage of multi-processors
•Examples
–POSIX Pthreads
–Mach C-threads
–Solaris UI-threads
a user-level thread includes a set of registers and a stack, and shares the entire address space with the other threads in the enclosing process. however, a user-level thread is handled entirely in user code, usually by a special library that provides at least start, swap and suspend calls. Because the OS is unaware of a user-level thread's existence, a user-level thread can not separately receive signals or use operating system scheduling calls such as sleep(). Many implementations of user-level threads exist, including:
GNU Portable Threads (Pth)
FreeBSD's userland threads
QuickThreads and those developed by us for the Charm++ system.
(0) Kernel Threads
•Supported by the Kernel
–Kernel maintains context information for the process and the threads
–Scheduling is done on a thread basis
–Slower to create and manage
–If a thread performs a blocking system call, the kernel can schedule another thread in the application for execution
–Can take advantage of a multi-processor environment
•Examples
–Windows 95/98/NT/2000
–Solaris
–Tru64 UNIX
–BeOS–Linux
(0) Thread Library
The threads library allows concurrent programming in Objective Caml. It provides multiple threads of control (also called lightweight processes) that execute concurrently in the same memory space. Threads communicate by in-place modification of shared data structures, or by sending and receiving data on communication channels. The threads library is implemented by time-sharing on a single processor. It will not take advantage of multi-processor machines.
Using this library will therefore never make programs run faster. However, many programs are easier to write when structured as several communicating processes. Two implementations of the threads library are available, depending on the capabilities of the operating system: System threads. This implementation builds on the OS-provided threads facilities: POSIX 1003.1c threads for Unix, and Win32 threads for Windows. When available, system threads support both bytecode and native-code programs. VM-level threads. This implementation performs time-sharing and context switching at the level of the OCaml virtual machine (bytecode interpreter). It is available on Unix systems, and supports only bytecode programs. It cannot be used with native-code programs.
- Many-to-one model
•Many user-level threads mapped to single kernel thre
ad–Thread management is done in user space
–Blocking problem
–No support for running in parallel on MP–Used on systems that do not support kernel threads.–Green-threads library in Solaris 2
- One-to One Model

•Each user-level thread maps to a kernel thread–Creating a user thread r
equires creating the corresponding kernel thread•Overhead–Restrict the number of threads supported by the OS•Examples
–Windows NT/2000–OS/2

Many-to Many
•Multiplex many user-level threads to a smaller or equal number of kernel threads•Allows many user level threads to be mapped to many kernel threads.•Allows OS to create a sufficient number of kernel threads.•Examples–Solaris 2, IRIX, HP-UX, Tru64 UNIX–Windows NT/2000 with the ThreadFiber package
