On a single processor, multithreading generally occurs by time-division multiplexing (as in multitasking): the processor switches between different threads. This context switching generally happens frequently enough that the user perceives the threads or tasks as running at the same time. On a multiprocessor or multi-core system, the threads or tasks will generally run at the same time, with each processor or core running a particular thread or task. Support for threads in programming languages varies: a number of languages simply do not support having more than one execution context inside the same program executing at the same time. Examples of such languages include Python, and OCaml, because the parallel support of their runtime support is limited by the use of a central lock, called "Global Interpreter Lock" in Python, "master lock" in Ocaml. Other languages may be limited because they use threads that are user threads, which are not visible to the kernel, and thus cannot be scheduled to run concurrently. On the other hand, kernel threads, which are visible to the kernel, can run concurrently.
Many modern operating systems directly support both time-sliced and multiprocessor threading with a process scheduler. The kernel of an operating system allows programmers to manipulate threads via the system call interface. Some implementations are called a kernel thread, whereas a lightweight process (LWP) is a specific type of kernel thread that shares the same state and information.
Programs can have user-space threads when threading with timers, signals, or other methods to interrupt their own execution, performing a sort of ad-hoc time-slicing.
- User Thread
-Thread management done by user-level threads library
(e.g.):
1. POSIX Pthreads
2. Mach C-threads
3.Solaris threads
- Kernel Thread
- Supported by Kernel
(e.g.):
1.Windows 95/98/NT/2000
2.Solaris
3.Tru64 UNIX
4.BeOS
5.Linux
- Thread Library
- Multithreading models
1)Many-to-one Model
-Many user-level threads mapped to single kernel thread.
-Used on systems that do not supported kernel threads.
2)One-to-One Model
-Each user-level thread maps to kernel thread.
(e.g.):
-Windows 95/98/NT/2000
-OS/2