World Library  
Flag as Inappropriate
Email this Article

Concurrent Programming

Article Id: WHEBN0004521105
Reproduction Date:

Title: Concurrent Programming  
Author: World Heritage Encyclopedia
Language: English
Subject: Dining philosophers problem
Collection:
Publisher: World Heritage Encyclopedia
Publication
Date:
 

Concurrent Programming

Concurrent computing is a form of computing in which programs are designed as collections of interacting computational processes that may be executed in parallel.[1] Concurrent programs (processes or threads) can be executed on a single processor by interleaving the execution steps of each in a time-slicing way, or can be executed in parallel by assigning each computational process to one of a set of processors that may be close or distributed across a network. The main challenges in designing concurrent programs are ensuring the correct sequencing of the interactions or communications between different computational executions, and coordinating access to resources that are shared among executions.[1] A number of different methods can be used to implement concurrent programs, such as implementing each computational execution as an operating system process, or implementing the computational processes as a set of threads within a single operating system process.

Pioneers in the field of concurrent computing include Edsger Dijkstra, Per Brinch Hansen, and C.A.R. Hoare.

Concurrent interaction and communication

In some concurrent computing systems, communication between the concurrent components is hidden from the programmer (e.g., by using futures), while in others it must be handled explicitly. Explicit communication can be divided into two classes:

Shared memory communication 
Concurrent components communicate by altering the contents of shared memory locations (exemplified by Java and C#). This style of concurrent programming usually requires the application of some form of locking (e.g., mutexes, semaphores, or monitors) to coordinate between threads.
Message passing communication 
Concurrent components communicate by exchanging messages (exemplified by Scala, Erlang and occam). The exchange of messages may be carried out asynchronously, or may use a rendezvous style in which the sender blocks until the message is received. Asynchronous message passing may be reliable or unreliable (sometimes referred to as "send and pray"). Message-passing concurrency tends to be far easier to reason about than shared-memory concurrency, and is typically considered a more robust form of concurrent programming. A wide variety of mathematical theories for understanding and analyzing message-passing systems are available, including the Actor model, and various process calculi. Message passing can be efficiently implemented on symmetric multiprocessors, with or without shared coherent memory.

Shared memory and message passing concurrency have different performance characteristics. Typically (although not always), the per-process memory overhead and task switching overhead is lower in a message passing system, but the overhead of message passing itself is greater than for a procedure call. These differences are often overwhelmed by other performance factors.

Coordinating access to resources

One of the major issues in concurrent computing is preventing concurrent processes from interfering with each other. For example, consider the following algorithm for making withdrawals from a checking account represented by the shared resource balance:

  1.   bool withdraw( int withdrawal )
  2.   {
  3.      if ( balance >= withdrawal )
  4.      {
  5.          balance -= withdrawal;
  6.          return true;
  7.      } 
  8.      return false;
  9.   }

Suppose balance=500, and two concurrent threads make the calls withdraw(300) and withdraw(350). If line 3 in both operations executes before line 5 both operations will find that balance > withdrawal evaluates to true, and execution will proceed to subtracting the withdrawal amount. However, since both processes perform their withdrawals, the total amount withdrawn will end up being more than the original balance. These sorts of problems with shared resources require the use of concurrency control, or non-blocking algorithms.

Because concurrent systems rely on the use of shared resources (including communication media), concurrent computing in general requires the use of some form of arbiter somewhere in the implementation to mediate access to these resources.

Unfortunately, while many solutions exist to the problem of a conflict over one resource, many of those "solutions" have their own concurrency problems such as deadlock when more than one resource is involved.

Advantages

  • Increased application throughput – parallel execution of a concurrent program allows the number of tasks completed in certain time period to increase.
  • High responsiveness for input/output – input/output-intensive applications mostly wait for input or output operations to complete. Concurrent programming allows the time that would be spent waiting to be used for another task.
  • More appropriate program structure – some problems and problem domains are well-suited to representation as concurrent tasks or processes.

Concurrent programming languages

Concurrent programming languages are programming languages that use language constructs for concurrency. These constructs may involve multi-threading, support for distributed computing, message passing, shared resources (including shared memory) or futures (known also as promises). Such languages are sometimes described as Concurrency Oriented Languages or Concurrency Oriented Programming Languages (COPL).[2]

Today, the most commonly used programming languages that have specific constructs for concurrency are Java and C#. Both of these languages fundamentally use a shared-memory concurrency model, with locking provided by monitors (although message-passing models can and have been implemented on top of the underlying shared-memory model). Of the languages that use a message-passing concurrency model, Erlang is probably the most widely used in industry at present.

Many concurrent programming languages have been developed more as research languages (e.g. Pict) rather than as languages for production use. However, languages such as Erlang, Limbo, and occam have seen industrial use at various times in the last 20 years. Languages in which concurrency plays an important role include:

  • Ada - general purpose programming language with native support for message passing and monitor based concurrency.
  • Alef – concurrent language with threads and message passing, used for systems programming in early versions of Plan 9 from Bell Labs
  • Alice – extension to Standard ML, adds support for concurrency via futures.
  • Ateji PX – an extension to Java with parallel primitives inspired from pi-calculus
  • Axum – domain specific concurrent programming language, based on the Actor model and on the .NET Common Language Runtime using a C-like syntax.
  • Chapel – a parallel programming language being developed by Cray Inc.
  • Charm++C++-like language for thousands of processors.
  • Cilk – a concurrent C
  • – C Omega, a research language extending C#, uses asynchronous communication
  • C# – supports concurrent computing since version 5.0 using lock, yield, async and await keywords, as well as the TPL
  • Clojure – a modern Lisp targeting the JVM
  • Concurrent Clean – a functional programming language, similar to Haskell
  • Concurrent Haskell – lazy, pure functional language operating concurrent processes on shared memory
  • Concurrent ML – a concurrent extension of Standard ML
  • Concurrent Pascal – by Per Brinch Hansen
  • Curry
  • Dmulti-paradigm system programming language with explicit support for concurrent programming (Actor model)
  • E – uses promises, ensures deadlocks cannot occur
  • ECMAScript – promises available in various libraries, proposed for inclusion in standard in ECMAScript 6
  • Eiffel – through its SCOOP mechanism based on the concepts of Design by Contract
  • Erlang – uses asynchronous message passing with nothing shared
  • Faust – Realtime functional programming language for signal processing. The Faust compiler provides automatic parallelization using either OpenMP or a specific work-stealing scheduler.
  • FortranCoarrays and "do concurrent" are part of Fortran 2008 standard
  • Go – systems programming language with explicit support for concurrent programming
  • Hume functional concurrent lang. for bounded space and time environments where automata processes are described by synchronous channels patterns and message passing.
  • Io – actor-based concurrency
  • Janus features distinct "askers" and "tellers" to logical variables, bag channels; is purely declarative
  • JoCaml Concurrent and distributed channel based language (extension of OCaml) that implements the Join-calculus of processes.
  • Join Java – concurrent language based on the Java programming language
  • Joule – dataflow language, communicates by message passing
  • Joyce – a concurrent teaching language built on Concurrent Pascal with features from CSP by Per Brinch Hansen
  • LabVIEW – graphical, dataflow programming language, in which functions are nodes in a graph and data is wires between those nodes. Includes object oriented language extensions.
  • Limbo – relative of Alef, used for systems programming in Inferno (operating system)
  • MultiLispScheme variant extended to support parallelism
  • Modula-2 – systems programming language by N.Wirth as a successor to Pascal with native support for coroutines.
  • Modula-3 – modern language in Algol family with extensive support for threads, mutexes, condition variables.
  • Newsqueak – research language with channels as first-class values; predecessor of Alef
  • occam – influenced heavily by Communicating Sequential Processes (CSP).
  • Orc – a heavily concurrent, nondeterministic language based on Kleene algebra.
  • Oz – multiparadigm language, supports shared-state and message-passing concurrency, and futures
  • ParaSail – a pointer-free, data-race-free, object-oriented parallel programming language
  • Pict – essentially an executable implementation of Milner's π-calculus
  • Coro
  • gevent.
  • Reia – uses asynchronous message passing between shared-nothing objects
  • Rust – a systems language with a focus on massive concurrency, utilizing message-passing with move semantics, shared immutable memory, and shared mutable memory that is provably free of data races.[3]
  • SALSA – actor language with token-passing, join, and first-class continuations for distributed computing over the Internet
  • Scala – a general purpose programming language designed to express common programming patterns in a concise, elegant, and type-safe way
  • SequenceL – general purpose functional programming language whose primary design objectives are ease of programming, code clarity/readability, and automatic parallelization for performance on multicore hardware, which is provably free of Race condition
  • SR – research language
  • Stackless Python
  • StratifiedJS – a combinator-based concurrency language based on JavaScript
  • SuperPascal – a concurrent teaching language built on Concurrent Pascal and Joyce by Per Brinch Hansen
  • Unicon – Research language.
  • Termite Scheme adds Erlang-like concurrency to Scheme
  • TNSDL – a language used at developing telecommunication exchanges, uses asynchronous message passing
  • VHDL – VHSIC Hardware Description Language, aka IEEE STD-1076
  • XC – a concurrency-extended subset of the C programming language developed by XMOS based on Communicating Sequential Processes. The language also offers built-in constructs for programmable I/O.

Many other languages provide support for concurrency in the form of libraries (on level roughly comparable with the above list).

Models of concurrency

There are several models of concurrent computing, which can be used to understand and analyze concurrent systems. These models include:

See also

References

Further reading

  • expand by hand

External links

  • Concurrent Systems Virtual Library

de:Parallele Programmierung nl:Multiprogrammeren

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 USA.gov, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for USA.gov 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.