In computing, a channel is a model for interprocess communication and synchronization. A message may be sent over a channel, and another process or thread is able to synchronously receive messages sent over a channel it has a reference to. Channels first originated in communicating sequential processes (CSP), a formal model for concurrency. The Limbo programming language uses channels as the primary way of communicating between processes, inherited from CSP via Newsqueak and the Alef programming language. They are also used in the C programming language threading library libthread, and in Plan 9 from Bell Labs, which uses libthread, as well as in Stackless Python and the Go programming language.
Most Channel implementations are modeled close to the CSP model. Channels are inherently synchronous: a process waiting to receive an object from a channel will block until the object is sent. This is also called rendezvous behaviour. Typical supported operations are presented below using the example of the libthread channel API.
- Channel creation of fixed or variable size, returning a reference or handle
Channel* chancreate(int elemsize, int bufsize)
- sending to a channel
int chansend(Channel *c, void *v)
- receiving from a channel
int chanrecv(Channel *c, void *v)
The Multithreading library, libthread, which was first created for the operating system Plan 9 and later adopted by several Unix systems as well, offers inter-thread communication based on fixed-size channels.
The OCaml event module offers typed channels for synchronization. When the module's send and receive functions are called, they create corresponding send and receive events which can be synchronized.
- – Libthread Channel Implementation
- Bell Labs and CSP Threads
- Limbo – Inferno Application Programming
- Stackless.com – Channels
- – OCaml Events
|This computer science article is a stub. You can help Wikipedia by expanding it.|
|This computer programming-related article is a stub. You can help Wikipedia by expanding it.|