All Topics  
Thread (computer science)

 

   Email Print
   Bookmark   Link






 

Thread (computer science)



 
 
In computer science
Computer science

Computer science is the study of the theoretical foundations of information and computation, and of practical techniques for their implementation and application in computer systems....
, a thread of execution is a fork
Fork (operating system)

In computing, when a Computer_process forks, it creates a copy of itself, which is called a "Child_process." The original process is then called the "Parent_process"....
 of a computer program
Computer program

Computer programs are Instruction for a computer. A computer requires programs to function. Moreover, a computer program does not run unless its instructions are executed by a Central processing unit; however, a program may communicate an Algorithm#Formalization of algorithms to people without running....
 into two or more concurrently
Concurrency (computer science)

In computer science, concurrency is a property of systems in which several computations are executing simultaneously, and potentially interacting with each other....
 running task
Task (computers)

A task is "an execution path through address space". In other words, a set of Computer program instruction s that are loaded in computer storage....
s. The implementation of threads and process
Process (computing)

In computing, a process is an Object of a computer program that is being sequentially executed by a computer system that has the ability to run several computer programs Concurrency ....
es differs from one operating system
Operating system

An operating system is an interface between hardware and applications; it is responsible for the management and coordination of activities and the sharing of the limited resources of the computer....
 to another, but in most cases, a thread is contained inside a process. Multiple threads can exist within the same process and share resources such as memory
Shared memory

In computing, shared memory is a memory that may be simultaneously accessed by multiple programs with an intent to provide communication among them or avoid redundant copies....
, while different process
Process (computing)

In computing, a process is an Object of a computer program that is being sequentially executed by a computer system that has the ability to run several computer programs Concurrency ....
es do not share this data.

On a single processor, multithreading generally occurs by time-division multiplexing
Time-division multiplexing

Time-Division Multiplexing is a type of digital or Pulse-amplitude modulation multiplexing in which two or more signals or bit streams are transferred apparently simultaneously as sub-channels in one communication channel, but are physically taking turns on the channel....
 (as in multitasking
Computer multitasking

In computing, multitasking is a method by which multiple tasks, also known as Computer process, share common processing resources such as a Central processing unit....
): the processor
Central processing unit

A central processing unit is an electronic circuit that can execute computer programs. This broad definition can easily be applied to many early computers that existed long before the term "CPU" ever came into widespread usage....
 switches between different threads.






Discussion
Ask a question about 'Thread (computer science)'
Start a new discussion about 'Thread (computer science)'
Answer questions from other users
Full Discussion Forum



Encyclopedia


In computer science
Computer science

Computer science is the study of the theoretical foundations of information and computation, and of practical techniques for their implementation and application in computer systems....
, a thread of execution is a fork
Fork (operating system)

In computing, when a Computer_process forks, it creates a copy of itself, which is called a "Child_process." The original process is then called the "Parent_process"....
 of a computer program
Computer program

Computer programs are Instruction for a computer. A computer requires programs to function. Moreover, a computer program does not run unless its instructions are executed by a Central processing unit; however, a program may communicate an Algorithm#Formalization of algorithms to people without running....
 into two or more concurrently
Concurrency (computer science)

In computer science, concurrency is a property of systems in which several computations are executing simultaneously, and potentially interacting with each other....
 running task
Task (computers)

A task is "an execution path through address space". In other words, a set of Computer program instruction s that are loaded in computer storage....
s. The implementation of threads and process
Process (computing)

In computing, a process is an Object of a computer program that is being sequentially executed by a computer system that has the ability to run several computer programs Concurrency ....
es differs from one operating system
Operating system

An operating system is an interface between hardware and applications; it is responsible for the management and coordination of activities and the sharing of the limited resources of the computer....
 to another, but in most cases, a thread is contained inside a process. Multiple threads can exist within the same process and share resources such as memory
Shared memory

In computing, shared memory is a memory that may be simultaneously accessed by multiple programs with an intent to provide communication among them or avoid redundant copies....
, while different process
Process (computing)

In computing, a process is an Object of a computer program that is being sequentially executed by a computer system that has the ability to run several computer programs Concurrency ....
es do not share this data.

On a single processor, multithreading generally occurs by time-division multiplexing
Time-division multiplexing

Time-Division Multiplexing is a type of digital or Pulse-amplitude modulation multiplexing in which two or more signals or bit streams are transferred apparently simultaneously as sub-channels in one communication channel, but are physically taking turns on the channel....
 (as in multitasking
Computer multitasking

In computing, multitasking is a method by which multiple tasks, also known as Computer process, share common processing resources such as a Central processing unit....
): the processor
Central processing unit

A central processing unit is an electronic circuit that can execute computer programs. This broad definition can easily be applied to many early computers that existed long before the term "CPU" ever came into widespread usage....
 switches between different threads. This context switch
Context switch

A context switch is the computing process of storing and restoring the State of a Central processing unit such that multiple Process es can share a single CPU resource....
ing generally happens frequently enough that the user perceives the threads or tasks to be running at the same time. On a multiprocessor or multi-core
Multi-core (computing)

A multi-core processor combines two or more independent cores into a single package composed of a single integrated circuit , called a Die , or more dies packaged together....
 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
Python (programming language)

Python is a general-purpose high-level programming language. Its design philosophy emphasizes code readability. Python's core syntax and semantics are Minimalism , while the standard library is large and comprehensive....
, and OCaml. These languages use threads that are user threads, threads not visible to the kernel, and thus cannot be scheduled to run concurrently. On the other hand, kernel threads, threads visible to the kernel, will indeed enable true concurrency.

Many modern operating system
Operating system

An operating system is an interface between hardware and applications; it is responsible for the management and coordination of activities and the sharing of the limited resources of the computer....
s directly support both time-sliced and multiprocessor threading with a process scheduler
Scheduling (computing)

Scheduling is a key concept in computer multitasking and multiprocessing operating system design, and in real-time operating system design. In modern operating systems, there are typically many more processes running than there are CPUs available to run them....
. The operating system kernel allows programmers to manipulate threads via the system call
System call

In computing, a system call is the mechanism used by an application program to request service from the kernel based on the Monolithic_kernel or to system servers on operating systems based on the microkernel-structure....
 interface. Some implementations are called a kernel thread, whereas a lightweight process
Light-weight process

In computer operating systems, a light-weight process is a means of achieving computer multitasking. In contrast to a regular process, an LWP shares all its logical address space and system resources with other process; in contrast to a thread , a light-weight process has its own private process identifier and Parent process with other pro...
 (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.

Threads compared with processes

Threads are distinguished from traditional multitasking
Computer multitasking

In computing, multitasking is a method by which multiple tasks, also known as Computer process, share common processing resources such as a Central processing unit....
 operating system processes in that:
  • processes are typically independent, while threads exist as subsets of a process
  • processes carry considerable state
    State (computer science)

    In computer science and automata theory, a state is a unique configuration of information in a program or machine. It is a concept that occasionally extends into some forms of systems programming such as Lexical analysiss and parsers....
     information, where multiple threads within a process share state
    State (computer science)

    In computer science and automata theory, a state is a unique configuration of information in a program or machine. It is a concept that occasionally extends into some forms of systems programming such as Lexical analysiss and parsers....
     as well as memory
    Computer storage

    Computer data storage, often called storage or memory, refers to computer components, devices, and recording medium that retain digital data used for computing for some interval of time....
     and other resource
    Resource (computer science)

    A resource, or system resource, is any physical or virtual component of limited availability within a computer system. Every device connected to a computer system is a resource....
    s
  • processes have separate address space
    Address space

    In computing, an address space defines a range of discrete addresses, each of which may correspond to a physical or virtual memory register, a Node , peripheral device, disk sector or other logical or physical entity....
    s, where threads share their address space
    Address space

    In computing, an address space defines a range of discrete addresses, each of which may correspond to a physical or virtual memory register, a Node , peripheral device, disk sector or other logical or physical entity....
  • processes interact only through system-provided inter-process communication
    Inter-process communication

    Inter-Process Communication is a set of techniques for the exchange of data among multiple thread in one or more Process . Processes may be running on one or more computers connected by a computer network....
     mechanisms.
  • Context switching between threads in the same process is typically faster than context switching between processes.
Systems like Windows NT
Windows NT

Windows NT is a family of operating systems produced by Microsoft, the first version of which was released in July 1993. It was originally designed to be a powerful high-level-language-based, processor-independent, multiprocessing, multiuser operating system with features comparable to Unix....
 and OS/2
OS/2

OS/2 is a computer operating system, initially created by Microsoft and IBM, then later developed by IBM exclusively. The name stands for "Operating System/2," because it was introduced as part of the same generation change release as IBM's "IBM Personal System/2 " line of second-generation personal computers....
 are said to have "cheap" threads and "expensive" processes; in other operating systems there is not so great a difference except the cost of address space
Address space

In computing, an address space defines a range of discrete addresses, each of which may correspond to a physical or virtual memory register, a Node , peripheral device, disk sector or other logical or physical entity....
 change which implies a TLB
Translation Lookaside Buffer

A Translation lookaside buffer is a Central processing unit CPU cache that is used by Memory management unit to improve the speed of virtual address translation....
 flush.

Multithreading: Advantages/Uses

Multithreading is a popular programming and execution model that allows multiple threads to exist within the context of a single process. These threads share the process' resources but are able to execute independently. The threaded programming model provides developers with a useful abstraction of concurrent execution. However, perhaps the most interesting application of the technology is when it is applied to a single process to enable parallel execution on a multiprocessor system.

This advantage of a multithreaded program allows it to operate faster on computer systems that have multiple CPUs
Central processing unit

A central processing unit is an electronic circuit that can execute computer programs. This broad definition can easily be applied to many early computers that existed long before the term "CPU" ever came into widespread usage....
, CPUs with multiple cores, or across a cluster of machines. This is because the threads of the program naturally lend themselves to truly concurrent
Concurrency (computer science)

In computer science, concurrency is a property of systems in which several computations are executing simultaneously, and potentially interacting with each other....
 execution
Execution (computers)

Execution in computer engineering and software engineering is the Process by which a computer or a virtual machine carries out the instructions of a computer program....
. In such a case, the programmer
Programmer

A programmer is someone who writes computer software. The term computer programmer can refer to a specialist in one area of computer programming or to a generalist who writes code for many kinds of software....
 needs to be careful to avoid race condition
Race condition

A race condition or race hazard is a flaw in a system or process whereby the output and/or result of the process is unexpectedly and critically dependent on the sequence or timing of other events....
s, and other non-intuitive behaviors. In order for data to be correctly manipulated, threads will often need to rendezvous
Rendezvous problem

The rendezvous dilemma is related to the prisoner's dilemma and can be formulated in this way:If they both choose to wait, of course, they will never meet....
 in time in order to process the data in the correct order. Threads may also require atomic operations (often implemented using semaphore
Semaphore (programming)

In computer science, a semaphore is a protected variable or abstract data type which constitutes the classic method for restricting access to shared resources such as shared memory in a multiprogramming environment....
s) in order to prevent common data from being simultaneously modified, or read while in the process of being modified. Careless use of such primitives can lead to deadlock
Deadlock

A deadlock is a situation wherein two or more competing actions are waiting for the other to finish, and thus neither ever does. It is often seen in a paradox like 'the chicken or the egg'....
s.

Operating systems schedule threads in one of two ways. Preemptive multithreading is generally considered the superior approach, as it allows the operating system to determine when a context switch
Context switch

A context switch is the computing process of storing and restoring the State of a Central processing unit such that multiple Process es can share a single CPU resource....
 should occur. Cooperative multithreading, on the other hand, relies on the threads themselves to relinquish control once they are at a stopping point. This can create problems if a thread is waiting for a resource to become available. The disadvantage to preemptive multithreading is that the system may make a context switch at an inappropriate time, causing priority inversion
Priority inversion

In scheduling , priority inversion is the scenario where a low priority task holds a shared resource that is required by a high priority task. This causes the execution of the high priority task to be blocked until the low priority task has released the resource, effectively "inverting" the relative priorities of the two tasks....
 or other bad effects which may be avoided by cooperative multithreading.

Traditional mainstream computing hardware did not have much support for multithreading as switching between threads was generally already quicker than full process context switch
Context switch

A context switch is the computing process of storing and restoring the State of a Central processing unit such that multiple Process es can share a single CPU resource....
es. Processors in embedded systems, which have higher requirements for real-time behaviors, might support multithreading by decreasing the thread switch time, perhaps by allocating a dedicated register file for each thread instead of saving/restoring a common register file. In the late 1990s, the idea of executing instructions from multiple threads simultaneously has become known as simultaneous multithreading
Simultaneous multithreading

Simultaneous multithreading, often abbreviated as SMT, is a technique for improving the overall efficiency of superscalar Central processing unit with Multithreading ....
. This feature was introduced in Intel's Pentium 4
Pentium 4

The Pentium 4 brand refers to Intel's line of single-core mainstream Desktop computer and laptop central processing units introduced on November 20, 2000 ....
 processor, with the name hyper threading

Processes, kernel threads, user threads, and fibers


A
process is the "heaviest" unit of kernel scheduling. Processes own resources
Resource (computer science)

A resource, or system resource, is any physical or virtual component of limited availability within a computer system. Every device connected to a computer system is a resource....
 allocated by the operating system. Resources include memory, file handles
Handle (computing)

A handle is a particular kind of smart pointer. Handles are used when an application references blocks of memory or objects managed by another system, such as a database or an operating system....
, sockets, device handles, and windows. Processes do not share address spaces or file resources except through explicit methods such as inheriting file handles or shared memory segments, or mapping the same file in a shared way. Processes are typically preemptively multitasked.

A
kernel thread is the "lightest" unit of kernel scheduling. At least one kernel thread exists within each process. If multiple kernel threads can exist within a process, then they share the same memory and file resources. Kernel threads are preemptively multitasked if the operating system's process scheduler
Scheduling (computing)

Scheduling is a key concept in computer multitasking and multiprocessing operating system design, and in real-time operating system design. In modern operating systems, there are typically many more processes running than there are CPUs available to run them....
 is preemptive. Kernel threads do not own resources except for a stack
Call stack

In computer science, a call stack is a dynamic Stack data structure that stores information about the active subroutines of a computer program....
, a copy of the registers
Processor register

In computer architecture, a processor register is a small amount of Computer storage available on the CPU whose contents can be accessed more quickly than storage available elsewhere....
 including the program counter
Program counter

The program counter, or PC is a processor register that indicates where the computer is in its instruction sequence. Depending on the details of the particular computer, the PC holds either the address of the instruction being executed, or the address of the next instruction to be executed....
, and thread-local storage
Thread-local storage

Thread-local storage is a computer programming method that uses static or global Computer storage local to a Thread .This is sometimes needed because all threads in a Process share the same address space....
 (if any).

Threads are sometimes implemented in userspace
User space

A conventional operating system usually segregates virtual memory into kernel space and user space. Kernel space is strictly reserved for running the kernel , kernel extensions, and some device drivers....
 libraries, thus called
user threads. The kernel is not aware of them, they are managed and scheduled in userspace
User space

A conventional operating system usually segregates virtual memory into kernel space and user space. Kernel space is strictly reserved for running the kernel , kernel extensions, and some device drivers....
. Some implementations base their
user threads on top of several kernel threads to benefit from multi-processor
Multiprocessing

Multiprocessing is the use of two or more CPU within a single computer system. The term also refers to the ability of a system to support more than one processor and/or the ability to allocate tasks between them....
 machines (N:M model). In this article the term "thread" (without kernel or user qualifier) defaults to referring to kernel threads. User threads as implemented by virtual machines
Virtual machine

In computer science, a virtual machine is a software implementation of a machine that executes programs like a real machine.Definitions...
 are also called green threads
Green threads

In computer programming, green threads are thread that are scheduled by a Virtual Machine instead of natively by the underlying operating system....
.

Fibers
Fiber (computer science)

In computer science, a fiber is a particularly lightweight thread of execution.Like threads, fibers share address space; where a distinction exists, it is that fibers use Computer multitasking#Cooperative multitasking/time-sharing while threads use pre-emptive multitasking....
 are an even lighter unit of scheduling which are cooperatively scheduled: a running fiber must explicitly "yield" to allow another fiber to run, which makes their implementation much easier than kernel or user threads. A fiber can be scheduled to run in any thread in the same process. This permits applications to gain performance improvements by managing scheduling themselves, instead of relying on the kernel scheduler (which may not be tuned for the application). Parallel programming environments such as OpenMP
OpenMP

The OpenMP is an application programming interface that supports multi-platform shared memory multiprocessing programming in C , C++ and Fortran on many architectures, including Unix and Microsoft Windows platforms....
 typically implement their tasks through fibers.

Thread and fiber issues


Concurrency and data structures
Threads in the same process share the same address space. This allows concurrently-running code to couple
Coupling (computer science)

In computer science, coupling or dependency is the degree to which each program module relies on each one of the other modules.Coupling is usually contrasted with cohesion ....
 tightly and conveniently exchange data without the overhead or complexity of an IPC
Inter-process communication

Inter-Process Communication is a set of techniques for the exchange of data among multiple thread in one or more Process . Processes may be running on one or more computers connected by a computer network....
. When shared between threads, however, even simple data structures become prone to race hazards
Race condition

A race condition or race hazard is a flaw in a system or process whereby the output and/or result of the process is unexpectedly and critically dependent on the sequence or timing of other events....
 if they require more than one CPU instruction to update: two threads may end up attempting to update the data structure at the same time and find it unexpectedly changing underfoot. Bugs caused by race hazards can be very difficult to reproduce and isolate.

To prevent this, threading APIs offer synchronization primitives such as mutexes
Mutual exclusion

Mutual exclusion algorithms are used in concurrent programming to avoid the simultaneous use of a common resource, such as a global variable, by pieces of computer code called critical sections....
 to lock
Lock (computer science)

In computer science, a lock is a Synchronization mechanism for enforcing limits on access to a resource in an environment where there are many thread ....
 data structures against concurrent access. On uniprocessor systems, a thread running into a locked mutex must sleep and hence trigger a context switch. On multi-processor systems, the thread may instead poll the mutex in a spinlock
Spinlock

In software engineering, a spinlock is a lock where the thread simply waits in a loop repeatedly checking until the lock becomes available. As the thread remains active but isn't performing a useful task, the use of such a lock is a kind of busy waiting....
. Both of these may sap performance and force processors in SMP
Symmetric multiprocessing

In computing, symmetric multiprocessing or SMP involves a multiprocessor computer-architecture where two or more identical processors can connect to a single shared main memory....
 systems to contend for the memory bus, especially if the granularity
Granularity

Granularity is the extent to which a system is broken down into small parts, either the system itself or its description or observation. It is the "extent to which a larger entity is subdivided....
 of the locking is fine.

I/O and scheduling
User thread or fiber implementations are typically entirely in userspace. As a result, context switching between user threads or fibers within the same process is extremely efficient because it does not require any interaction with the kernel at all: a context switch can be performed by locally saving the CPU registers used by the currently executing user thread or fiber and then loading the registers required by the user thread or fiber to be executed. Since scheduling occurs in userspace, the scheduling policy can be more easily tailored to the requirements of the program's workload.

However, the use of blocking system calls in user threads or fibers can be problematic. If a user thread or a fiber performs a system call that blocks, the other user threads and fibers in the process are unable to run until the system call returns. A typical example of this problem is when performing I/O: most programs are written to perform I/O synchronously. When an I/O operation is initiated, a system call is made, and does not return until the I/O operation has been completed. In the intervening period, the entire process is "blocked" by the kernel and cannot run, which starves other user threads and fibers in the same process from executing.

A common solution to this problem is providing an I/O API that implements a synchronous interface by using non-blocking I/O internally, and scheduling another user thread or fiber while the I/O operation is in progress. Similar solutions can be provided for other blocking system calls. Alternatively, the program can be written to avoid the use of synchronous I/O or other blocking system calls.

SunOS 4.x implemented "light-weight processes" or LWPs. NetBSD
NetBSD

NetBSD is a freely redistributable, open source version of the Unix-derivative Berkeley Software Distribution computer operating system. It was the second open source BSD descendant to be formally released, after 386BSD, and continues to be actively developed....
 2.x+, and DragonFly BSD
DragonFly BSD

DragonFly BSD is a Free software Unix-like operating system created as a fork of FreeBSD 4.8. Matthew Dillon , a FreeBSD and Amiga developer since 1994, began work on DragonFly BSD in June 2003 and announced it on the FreeBSD mailing lists on July 16, 2003....
 implement LWPs as kernel threads (1:1 model). SunOS 5.2 through SunOS 5.8 as well as NetBSD 2 to NetBSD 4 implemented a two level model, multiplexing one or more user level threads on each kernel thread (M:N model). SunOS 5.9 and later, as well as NetBSD 5 eliminated user threads support, returning to a 1:1 model. FreeBSD 5 implemented M:N model. FreeBSD 6 supported both 1:1 and M:N, user could choose which one should be used with a given program using /etc/libmap.conf. Starting with FreeBSD 7, the 1:1 became the default. FreeBSD 8 no longer supports the M:N model.

The use of kernel threads simplifies user code by moving some of the most complex aspects of threading into the kernel. The program doesn't need to schedule threads or explicitly yield the processor. User code can be written in a familiar procedural style, including calls to blocking APIs, without starving other threads. However, kernel threading on uniprocessor systems may force a context switch between threads at any time, and thus expose race hazards and concurrency bugs that would otherwise lie latent. On SMP systems, this is further exacerbated because kernel threads may actually execute concurrently on separate processors.

Models


1:1

1:1 threads created by the user are in 1-1 correspondence with schedulable entities in the kernel. This is the simplest possible threading implementation. On Linux
Linux

Linux is a generic term referring to Unix-like computer operating systems based on the Linux kernel. Their development is one of the most prominent examples of free and open source software collaboration; typically all the underlying source code can be used, freely modified, and redistributed by anyone under the terms of the GNU GPL license...
, the usual C library
GNU C Library

The GNU C Library, commonly known as glibc, is the C standard library released by the GNU Project. Originally written by the Free Software Foundation for the GNU operating system, the library's development has been overseen by a committee since 2001, with Ulrich Drepper from Red Hat as the lead contributor and maintainer....
 implements this approach (via the NPTL
Native POSIX Thread Library

The Native POSIX Thread Library is a software feature that enables the Linux kernel to run programs written to use POSIX Threads fairly efficiently....
). The same approach is used by Solaris and FreeBSD
FreeBSD

FreeBSD is a Unix-like free software operating system descended from AT&T Unix via the Berkeley Software Distribution branch through the 386BSD and Berkeley Software Distribution#4.4BSD and descendants operating systems....
.

N:M

N:M maps some N number of application threads onto some M number of kernel entities, or "virtual processors". This is a compromise between kernel-level ("1:1") and user-level ("N:1") threading. In general, "N:M" threading systems are more complex to implement than either kernel or user threads, because both changes to kernel and user-space code are required. In the N:M implementation, the threading library is responsible for scheduling user threads on the available schedulable entities; this makes context switching of threads very fast, as it avoids system calls. However, this increases complexity and the likelihood of priority inversion, as well as suboptimal scheduling without extensive (and expensive) coordination between the userland scheduler and the kernel scheduler.

N:1

An N:1 model implies that all application-level threads map on to a single kernel-level scheduled entity; the kernel has no knowledge of the application threads. With this approach, context switching can be done very fast and, in addition, it can be implemented even on simple kernels which do not support threading. One of the major drawbacks however is that it cannot benefit from the hardware acceleration on multi-threaded
Multithreading (computer hardware)

Multithreading computers have hardware support to efficiently execute multiple thread . These are distinguished from multiprocessing systems in that the threads have to share the resources of single core: the computing units, the CPU caches and the translation lookaside buffer ....
 processors or multi-processor
Multiprocessing

Multiprocessing is the use of two or more CPU within a single computer system. The term also refers to the ability of a system to support more than one processor and/or the ability to allocate tasks between them....
 computers: there is never more than one thread being scheduled at the same time.

Implementations

There are many different and incompatible implementations of threading. These include both kernel-level and user-level implementations. They however often follow more or less closely the POSIX Threads
POSIX Threads

POSIX Threads, or Pthreads, is a POSIX standard for thread s. The standard defines an Application programming interface for creating and manipulating threads....
 interface.

Kernel-level implementation examples

  • Light Weight Kernel Threads
    Light Weight Kernel Threads

    Light Weight Kernel Threads or LWKT is a term from computer science in general and in DragonFlyBSD in particular. LWKTs differ from normal Kernel Thread in that they can preempt normal light-weight process....
     in various BSDs
  • M:N threading
  • Native POSIX Thread Library
    Native POSIX Thread Library

    The Native POSIX Thread Library is a software feature that enables the Linux kernel to run programs written to use POSIX Threads fairly efficiently....
     for Linux
    Linux

    Linux is a generic term referring to Unix-like computer operating systems based on the Linux kernel. Their development is one of the most prominent examples of free and open source software collaboration; typically all the underlying source code can be used, freely modified, and redistributed by anyone under the terms of the GNU GPL license...
    , an implementation of the POSIX Threads
    POSIX Threads

    POSIX Threads, or Pthreads, is a POSIX standard for thread s. The standard defines an Application programming interface for creating and manipulating threads....
     (pthreads) standard
  • Apple Multiprocessing Services version 2.0 and later, uses the built-in nanokernel in Mac OS 8
    Mac OS 8

    Mac OS 8 is an operating system released by Apple Inc. on July 26 1997. It represented the largest overhaul of the Mac OS since the release of System 7 , some six years previous....
    .6 and later which was modified to support it.


User-level implementation examples

  • GNU Portable Threads
    GNU Portable Threads

    GNU Pth is a POSIX/ANSI-C based Thread library which provides priority-based scheduling for multithreading applications. GNU Pth targets for a high degree of Portability ....
  • FSU Pthreads
    FSU Pthreads

    FSU Pthreads is an implementation of POSIX Threads, a standard for Thread . It was developed by Ted Baker and his computer science students at Florida State University for use in the Ada programming language....
  • Apple Inc.'s Thread Manager
  • REALbasic
    REALbasic

    REALbasic is an object-oriented dialect of the BASIC programming language developed and commercially marketed by REAL Software, Inc in Austin, Texas for Mac OS X, Microsoft Windows, and Linux....
     (includes an API for cooperative threading)
  • Netscape Portable Runtime
    Netscape Portable Runtime

    In computing, the Netscape Portable Runtime, or NSPR, a platform abstraction library, makes all operating systems it supports appear the same to Mozilla-style web-browsers....
     (includes a user-space fibers implementation)


Hybrid implementation examples

  • Scheduler activations
    Scheduler activations

    Scheduler Activations is a thread ing mechanism that, when implemented in an operating system's process Scheduling , provides kernel-level thread functionality with user-level thread flexibility and performance....
     used by the NetBSD native POSIX threads library implementation (an N:M model as opposed to a 1:1 kernel or userspace implementation model)
  • Marcel from the PM2
    PM2

    The Parallel Multithreaded Machine is a software for parallel networking of computers.PM2 is an open-source distributed multithreaded programming environment designed to support efficiently distributed programs with a highly irregular behavior on distributed architectures....
     project.


Fiber implementation examples

Fibers can be implemented without operating system support, although some operating systems or libraries provide explicit support for them.

  • Win32 supplies a fiber API (Windows NT 3.51 SP3 and later)


See also

  • Win32 Thread Information Block
    Win32 Thread Information Block

    In computing, the Win32 Thread Information Block is a data structure in Win32 on x86 that stores info about the currently running thread .The TIB is officially undocumented for Windows 9x....
  • Hardware: Multithreading (computer hardware)
    Multithreading (computer hardware)

    Multithreading computers have hardware support to efficiently execute multiple thread . These are distinguished from multiprocessing systems in that the threads have to share the resources of single core: the computing units, the CPU caches and the translation lookaside buffer ....
    , Multi-core (computing)
    Multi-core (computing)

    A multi-core processor combines two or more independent cores into a single package composed of a single integrated circuit , called a Die , or more dies packaged together....
    , Simultaneous multithreading
    Simultaneous multithreading

    Simultaneous multithreading, often abbreviated as SMT, is a technique for improving the overall efficiency of superscalar Central processing unit with Multithreading ....
  • Theory: Communicating sequential processes
    Communicating sequential processes

    In computer science, Communicating Sequential Processes is a specification language for describing patterns of interaction in concurrent systems....
    , Computer multitasking
    Computer multitasking

    In computing, multitasking is a method by which multiple tasks, also known as Computer process, share common processing resources such as a Central processing unit....
    , Message passing
    Message passing

    Message passing in computer science, is a form of communication used in parallel computing, object-oriented programming, and interprocess communication....
  • Problems: Thread safety, Priority inversion
    Priority inversion

    In scheduling , priority inversion is the scenario where a low priority task holds a shared resource that is required by a high priority task. This causes the execution of the high priority task to be blocked until the low priority task has released the resource, effectively "inverting" the relative priorities of the two tasks....
  • Techniques: Protothreads
    Protothreads

    In computer science, a protothread is a low-overhead mechanism for concurrent programming.Protothreads function as Call stack, lightweight Thread providing a blocking context cheaply using minimal memory per protothread ....
    , Thread pool pattern
    Thread pool pattern

    In the thread pool Design_pattern_ in programming, a number of thread are created to perform a number of tasks, which are usually organized in a Queue ....
    , Lock-free and wait-free algorithms


External links

  • Article "" by Binildas C. A.
  • Article "" by Herb Sutter
    Herb Sutter

    Herb Sutter is a prominent C++ expert. He is also a book author and a columnist for Dr. Dobb's Journal.His books include:* Exceptional C++ ...
  • Article "" by Edward Lee
    Edward Lee

    Edward Lee may refer to:* Edward Lee , an American horror writer.* Edward Lee , Archbishop of York, 1531–1544* Lieutenant Colonel Edward Merwin Lee , a Union officer during the American Civil War...
  • by Daniel Robbins
    Daniel Robbins

    Daniel Robbins is a software developer best known as the founder and former chief architect of the Gentoo Linux project....