Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Concurrent computing

From Wikipedia, the free encyclopedia
Executing several computations during overlapping time periods
For the American computer company, seeConcurrent Computer Corporation. For a more theoretical discussion, seeConcurrency (computer science).
icon
This articleneeds additional citations forverification. Please helpimprove this article byadding citations to reliable sources. Unsourced material may be challenged and removed.
Find sources: "Concurrent computing" – news ·newspapers ·books ·scholar ·JSTOR
(February 2014) (Learn how and when to remove this message)

Concurrent computing is a form ofcomputing in which severalcomputations are executedconcurrently—during overlapping time periods—instead ofsequentially—with one completing before the next starts.

This is a property of a system—whether aprogram,computer, or anetwork—where there is a separate execution point or "thread of control" for each process. Aconcurrent system is one where a computation can advance without waiting for all other computations to complete.[1]

Concurrent computing is a form ofmodular programming. In itsparadigm an overall computation isfactored into subcomputations that may be executed concurrently. Pioneers in the field of concurrent computing includeEdsger Dijkstra,Per Brinch Hansen, andC.A.R. Hoare.[2]

Introduction

[edit]
See also:Parallel computing
This section has multiple issues. Please helpimprove it or discuss these issues on thetalk page.(Learn how and when to remove these messages)
icon
This sectionneeds additional citations forverification. Please helpimprove this article byadding citations to reliable sources in this section. Unsourced material may be challenged and removed.(December 2016) (Learn how and when to remove this message)
This sectionpossibly containsoriginal research. Pleaseimprove it byverifying the claims made and addinginline citations. Statements consisting only of original research should be removed.(December 2016) (Learn how and when to remove this message)
(Learn how and when to remove this message)

The concept of concurrent computing is frequently confused with the related but distinct concept ofparallel computing,[3][4] although both can be described as "multiple processes executingduring the same period of time". In parallel computing, execution occurs at the same physical instant: for example, on separateprocessors of amulti-processor machine, with the goal of speeding up computations—parallel computing is impossible on a (one-core) single processor, as only one computation can occur at any instant (during any single clock cycle).[a] By contrast, concurrent computing consists of processlifetimes overlapping, but execution does not happen at the same instant. The goal here is to model processes that happen concurrently, like multiple clients accessing a server at the same time. Structuring software systems as composed of multiple concurrent, communicating parts can be useful for tackling complexity, regardless of whether the parts can be executed in parallel.[5]: 1 

For example, concurrent processes can be executed on one core by interleaving the execution steps of each process viatime-sharing slices: only one process runs at a time, and if it does not complete during its time slice, it ispaused, another process begins or resumes, and then later the original process is resumed. In this way, multiple processes are part-way through execution at a single instant, but only one process is being executed at that instant.[citation needed]

Concurrent computationsmay be executed in parallel,[3][6] for example, by assigning each process to a separate processor or processor core, ordistributing a computation across a network.

The exact timing of when tasks in a concurrent system are executed depends on thescheduling, and tasks need not always be executed concurrently. For example, given two tasks, T1 and T2:[citation needed]

  • T1 may be executed and finished before T2 orvice versa (serialand sequential)
  • T1 and T2 may be executed alternately (serialand concurrent)
  • T1 and T2 may be executed simultaneously at the same instant of time (paralleland concurrent)

The word "sequential" is used as an antonym for both "concurrent" and "parallel"; when these are explicitly distinguished,concurrent/sequential andparallel/serial are used as opposing pairs.[7] A schedule in which tasks execute one at a time (serially, no parallelism), without interleaving (sequentially, no concurrency: no task begins until the prior task ends) is called aserial schedule. A set of tasks that can be scheduled serially isserializable, which simplifiesconcurrency control.[citation needed]

Coordinating access to shared resources

[edit]

The main challenge in designing concurrent programs isconcurrency control: ensuring the correct sequencing of the interactions or communications between different computational executions, and coordinating access to resources that are shared among executions.[6] Potential problems includerace conditions,deadlocks, andresource starvation. For example, consider the following algorithm to make withdrawals from a checking account represented by the shared resourcebalance:

boolwithdraw(intwithdrawal){if(balance>=withdrawal){balance-=withdrawal;returntrue;}returnfalse;}

Supposebalance = 500, and two concurrentthreads make the callswithdraw(300) andwithdraw(350). If line 3 in both operations executes before line 5 both operations will find thatbalance >= withdrawal evaluates totrue, 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 benefit from the use of concurrency control, ornon-blocking algorithms.

Advantages

[edit]
icon
This sectiondoes notcite anysources. Please helpimprove this section byadding citations to reliable sources. Unsourced material may be challenged andremoved.(December 2006) (Learn how and when to remove this message)

There are advantages of concurrent computing:

  • Increased program throughput—parallel execution of a concurrent algorithm allows the number of tasks completed in a given time to increase proportionally to the number of processors according toGustafson's law.[8]
  • High responsiveness for input/output—input/output-intensive programs 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.[9]
  • More appropriate program structure—some problems and problem domains are well-suited to representation as concurrent tasks or processes. For exampleMVCC.

Models

[edit]

Introduced in 1962,Petri nets were an early attempt to codify the rules of concurrent execution. Dataflow theory later built upon these, andDataflow architectures were created to physically implement the ideas of dataflow theory. Beginning in the late 1970s,process calculi such asCalculus of Communicating Systems (CCS) andCommunicating Sequential Processes (CSP) were developed to permit algebraic reasoning about systems composed of interacting components. Theπ-calculus added the capability for reasoning about dynamic topologies.

Input/output automata were introduced in 1987.

Logics such as Lamport'sTLA+, and mathematical models such astraces andActor event diagrams, have also been developed to describe the behavior of concurrent systems.

Software transactional memory borrows fromdatabase theory the concept ofatomic transactions and applies them to memory accesses.

Consistency models

[edit]
Main article:Consistency model

Concurrent programming languages and multiprocessor programs must have aconsistency model (also known as a memory model). The consistency model defines rules for how operations oncomputer memory occur and how results are produced.

One of the first consistency models wasLeslie Lamport'ssequential consistency model. Sequential consistency is the property of a program that its execution produces the same results as a sequential program. Specifically, a program is sequentially consistent if "the results of any execution is the same as if the operations of all the processors were executed in some sequential order, and the operations of each individual processor appear in this sequence in the order specified by its program".[10]

See also:Relaxed sequential

Implementation

[edit]
[icon]
This sectionneeds expansion. You can help byadding to it.(February 2014)

A number of different methods can be used to implement concurrent programs, such as implementing each computational execution as anoperating system process, or implementing the computational processes as a set ofthreads within a single operating system process.

Interaction and communication

[edit]

In some concurrent computing systems, communication between the concurrent components is hidden from the programmer (e.g., by usingfutures), 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 ofshared memory locations (exemplified byJava andC#). This style of concurrent programming usually needs the use of some form of locking (e.g.,mutexes,semaphores, ormonitors) to coordinate between threads. A program that properly implements any of these is said to bethread-safe.
Message passing communication
Concurrent components communicate bymessage passing (exchanging messages, exemplified byMPI,Go,Scala,Erlang andoccam). The exchange of messages may be carried out asynchronously, or may use a synchronous "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.[citation needed] A wide variety of mathematical theories to understand and analyze message-passing systems are available, including theactor model, and variousprocess calculi. Message passing can be efficiently implemented viasymmetric multiprocessing, with or without shared memorycache coherence.

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 is greater than for a procedure call. These differences are often overwhelmed by other performance factors.

History

[edit]

Concurrent computing developed out of earlier work on railroads andtelegraphy, from the 19th and early 20th century, and some terms date to this period, such as semaphores. These arose to address the question of how to handle multiple trains on the same railroad system (avoiding collisions and maximizing efficiency) and how to handle multiple transmissions over a given set of wires (improving efficiency), such as viatime-division multiplexing (1870s).

The academic study of concurrent algorithms started in the 1960s, withDijkstra (1965) credited with being the first paper in this field, identifying and solvingmutual exclusion.[11]

Prevalence

[edit]

Concurrency is pervasive in computing, occurring from low-level hardware on a single chip to worldwide networks. Examples follow.

At the programming language level:

At the operating system level:

At the network level, networked systems are generally concurrent by their nature, as they consist of separate devices.

Languages supporting concurrent programming

[edit]

Concurrent programming languages are programming languages that use language constructs forconcurrency. These constructs may involvemulti-threading, support fordistributed computing,message passing,shared resources (includingshared memory) orfutures and promises. Such languages are sometimes described asconcurrency-oriented languages orconcurrency-oriented programming languages (COPL).[12]

Today, the most commonly used programming languages that have specific constructs for concurrency areJava andC#. Both of these languages fundamentally use a shared-memory concurrency model, with locking provided bymonitors (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 was probably the most widely used in industry as of 2010.[citation needed]

Many concurrent programming languages have been developed more as research languages (e.g.,Pict) rather than as languages for production use. However, languages such asErlang,Limbo, andoccam have seen industrial use at various times in the last 20 years. A non-exhaustive list of languages which use or provide concurrent programming facilities:

  • Ada—general purpose, with native support for message passing and monitor based concurrency
  • Alef—concurrent, with threads and message passing, for system programming in early versions ofPlan 9 from Bell Labs
  • Alice—extension toStandard ML, adds support for concurrency via futures
  • Ateji PX—extension toJava with parallel primitives inspired fromπ-calculus
  • Axum—domain specific, concurrent, based on actor model and .NET Common Language Runtime using a C-like syntax
  • BMDFM—Binary Modular DataFlow Machine
  • C++—thread and coroutine support libraries[13][14]
  • (C omega)—for research, extends C#, uses asynchronous communication
  • C#—supports concurrent computing usinglock,yield, also since version 5.0async andawait keywords introduced
  • Clojure—modern,functional programming dialect ofLisp on theJava platform
  • Concurrent Clean—functional programming, similar toHaskell
  • Concurrent Collections (CnC)—Achieves implicit parallelism independent of memory model by explicitly defining flow of data and control
  • Concurrent Haskell—lazy, pure functional language operating concurrent processes on shared memory
  • Concurrent ML—concurrent extension ofStandard ML
  • Concurrent Pascal—byPer Brinch Hansen
  • Curry
  • Dmulti-paradigmsystem programming language with explicit support for concurrent programming (actor model)
  • E—uses promises to preclude deadlocks
  • ECMAScript—uses promises for asynchronous operations
  • Eiffel—through itsSCOOP mechanism based on the concepts of Design by Contract
  • Elixir—dynamic and functional meta-programming aware language running on the Erlang VM.
  • Erlang—uses synchronous or asynchronous message passing with no shared memory
  • FAUST—real-time functional, for signal processing, compiler provides automatic parallelization viaOpenMP or a specificwork-stealing scheduler
  • Fortrancoarrays anddo concurrent are part of Fortran 2008 standard
  • Go—for system programming, with a concurrent programming model based onCSP
  • Haskell—concurrent, and parallel functional programming language[15]
  • Hume—functional, concurrent, for bounded space and time environments where automata processes are described by synchronous channels patterns and message passing
  • Io—actor-based concurrency
  • Janus—features distinctaskers andtellers to logical variables, bag channels; is purely declarative
  • Java—thread class or Runnable interface
  • Julia—"concurrent programming primitives: Tasks, async-wait, Channels."[16]
  • JavaScript—viaweb workers, in a browser environment,promises, andcallbacks.
  • JoCaml—concurrent and distributed channel based, extension ofOCaml, implements thejoin-calculus of processes
  • Join Java—concurrent, based onJava language
  • Joule—dataflow-based, communicates by message passing
  • Joyce—concurrent, teaching, built onConcurrent Pascal with features fromCSP byPer Brinch Hansen
  • LabVIEW—graphical, dataflow, functions are nodes in a graph, data is wires between the nodes; includes object-oriented language
  • Limbo—relative ofAlef, for system programming inInferno (operating system)
  • Locomotive BASIC—Amstrad variant of BASIC contains EVERY and AFTER commands for concurrent subroutines
  • MultiLispScheme variant extended to support parallelism
  • Modula-2—for system programming, by N. Wirth as a successor to Pascal with native support for coroutines
  • Modula-3—modern member of Algol family with extensive support for threads, mutexes, condition variables
  • Newsqueak—for research, with channels as first-class values; predecessor ofAlef
  • occam—influenced heavily bycommunicating sequential processes (CSP)
  • ooRexx—object-based, message exchange for communication and synchronization
  • Orc—heavily concurrent, nondeterministic, based onKleene algebra
  • Oz-Mozart—multiparadigm, supports shared-state and message-passing concurrency, and futures
  • ParaSail—object-oriented, parallel, free of pointers, race conditions
  • PHP—multithreading support with parallel extension implementing message passing inspired fromGo[17]
  • Pict—essentially an executable implementation of Milner'sπ-calculus
  • Python — uses thread-based parallelism and process-based parallelism[18]
  • Raku includes classes for threads, promises and channels by default[19]
  • Reia—uses asynchronous message passing between shared-nothing objects
  • Red/System—for system programming, based onRebol
  • Rust—for system programming, using message-passing with move semantics, shared immutable memory, and shared mutable memory.[20]
  • Scala—general purpose, designed to express common programming patterns in a concise, elegant, and type-safe way
  • SequenceL—general purpose functional, main design objectives are ease of programming, code clarity-readability, and automatic parallelization for performance on multicore hardware, and provably free ofrace conditions
  • SR—for research
  • SuperPascal—concurrent, for teaching, built onConcurrent Pascal andJoyce byPer Brinch Hansen
  • Swift—built-in support for writing asynchronous and parallel code in a structured way[21]
  • Unicon—for research
  • TNSDL—for developing telecommunication exchanges, uses asynchronous message passing
  • VHSIC Hardware Description Language (VHDL)—IEEE STD-1076
  • XC—concurrency-extended subset of C language developed byXMOS, based oncommunicating sequential processes, built-in constructs for programmable I/O

Many other languages provide support for concurrency in the form of libraries, at levels roughly comparable with the above list.

See also

[edit]

Notes

[edit]
  1. ^This is discounting parallelism internal to a processor core, such as pipelining or vectorized instructions. A one-core, one-processormachine may be capable of some parallelism, such as with acoprocessor, but the processor alone is not.

References

[edit]
  1. ^Operating System Concepts 9th edition, Abraham Silberschatz. "Chapter 4: Threads"
  2. ^Hansen, Per Brinch, ed. (2002).The Origin of Concurrent Programming.doi:10.1007/978-1-4757-3472-0.ISBN 978-1-4419-2986-0.S2CID 44909506.
  3. ^abPike, Rob (2012-01-11). "Concurrency is not Parallelism".Waza conference, 11 January 2012. Retrieved fromhttp://talks.golang.org/2012/waza.slide (slides) andhttp://vimeo.com/49718712 (video).
  4. ^"Parallelism vs. Concurrency".Haskell Wiki.
  5. ^Schneider, Fred B. (1997-05-06).On Concurrent Programming. Springer.ISBN 9780387949420.
  6. ^abBen-Ari, Mordechai (2006).Principles of Concurrent and Distributed Programming (2nd ed.). Addison-Wesley.ISBN 978-0-321-31283-9.
  7. ^Patterson & Hennessy 2013, p. 503.
  8. ^Padua, David (2011).Encyclopedia of Parallel Computing. Springer New York, NY (published September 8, 2011). pp. 819–825.ISBN 978-0-387-09765-7.
  9. ^"Asynchronous I/O",Wikipedia, 2024-12-20, retrieved2024-12-27
  10. ^Lamport, Leslie (1 September 1979). "How to Make a Multiprocessor Computer That Correctly Executes Multiprocess Programs".IEEE Transactions on Computers.C-28 (9):690–691.doi:10.1109/TC.1979.1675439.S2CID 5679366.
  11. ^PODC Influential Paper Award: 2002.ACM Symposium on Principles of Distributed Computing (Report). Retrieved2009-08-24.
  12. ^Armstrong, Joe (2003)."Making reliable distributed systems in the presence of software errors"(PDF). Archived fromthe original(PDF) on 2016-04-15.
  13. ^"Standard library header <thread> (C++11)".en.cppreference.com. Retrieved2024-10-03.
  14. ^"Standard library header <coroutine> (C++20)".en.cppreference.com. Retrieved2024-10-03.
  15. ^ Marlow, Simon (2013) Parallel and Concurrent Programming in Haskell: Techniques for Multicore and Multithreaded ProgrammingISBN 9781449335946
  16. ^"Concurrent and Parallel programming in Julia — JuliaCon India 2015 — HasGeek Talkfunnel".juliacon.talkfunnel.com. Archived fromthe original on 2016-10-18.
  17. ^"PHP: parallel - Manual".www.php.net. Retrieved2024-10-03.
  18. ^Documentation » The Python Standard Library » Concurrent Execution
  19. ^"Concurrency".docs.perl6.org. Retrieved2017-12-24.
  20. ^Blum, Ben (2012)."Typesafe Shared Mutable State". Retrieved2012-11-14.
  21. ^"Concurrency". 2022. Retrieved2022-12-15.

Sources

[edit]
  • Patterson, David A.; Hennessy, John L. (2013).Computer Organization and Design: The Hardware/Software Interface. The Morgan Kaufmann Series in Computer Architecture and Design (5 ed.). Morgan Kaufmann.ISBN 978-0-12407886-4.

Further reading

[edit]

External links

[edit]
General
Process calculi
Classic problems
Imperative
Structured
Object-oriented
(comparison,list)
Declarative
Functional
(comparison)
Dataflow
Logic
Domain-
specific
language

(DSL)
Concurrent,
distributed,
parallel
Metaprogramming
Separation
of concerns
Level
Generation
Retrieved from "https://en.wikipedia.org/w/index.php?title=Concurrent_computing&oldid=1303981981"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp