World Library  
Flag as Inappropriate
Email this Article

Channel (programming)

Article Id: WHEBN0014524675
Reproduction Date:

Title: Channel (programming)  
Author: World Heritage Encyclopedia
Language: English
Subject: Go (programming language), Blocking (computing), Process calculus, Stackless Python, Occam (programming language)
Publisher: World Heritage Encyclopedia

Channel (programming)

In computing, a channel is a model for interprocess communication and synchronization via message passing. 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, as a stream.

Channels are fundamental to the process calculus approach to concurrency, and first originated in communicating sequential processes (CSP), a formal model for concurrency, and has been used in many derived languages, such as occam, and Limbo programming language (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.

Channel implementations

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)

libthread channels

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.

OCaml events

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.


In addition to their fundamental use for interprocess communication, channels can be used as a primitive to implement various other concurrent programming constructs which can be realized as streams. For example, channels can be used to construct futures and promises, where a future is a one-element channel, and a promise is a process that sends to the channel, fulfilling the future.[1] Similarly, iterators can be constructed directly from channels.[2]


  1. ^ "Futures", Go Language Patterns
  2. ^ "Iterators", Go Language Patterns

External links

  • – Libthread Channel Implementation
  • Bell Labs and CSP Threads
  • Limbo – Inferno Application Programming
  • – Channels
  • – OCaml Events
This article was sourced from Creative Commons Attribution-ShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for and content contributors is made possible from the U.S. Congress, E-Government Act of 2002.
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a non-profit organization.

Copyright © World Library Foundation. All rights reserved. eBooks from Project Gutenberg are sponsored by the World Library Foundation,
a 501c(4) Member's Support Non-Profit Organization, and is NOT affiliated with any governmental agency or department.