Nepedia
Back to Discover
Advanced Reader
💻

Concurrent computing

technology Maturity 9-11 Next article →

Concurrent computing is a method of organizing computations so that multiple tasks overlap in time. Instead of running tasks one after another in a sequential order, a concurrent system allows several processes to progress at once. This is a property of a system, such as a program, a computer, or a network. In these systems, each process has its own separate execution point, often called a thread of control. A key feature of concurrency is that a computation can move forward without waiting for every other task to finish. This approach is a form of modular programming, where a large, complex computation is broken down into smaller subcomputations.

It is important to distinguish concurrency from parallel computing, as the two terms are often confused. In parallel computing, tasks occur at the exact same physical instant. This usually requires a multi-processor machine where different processors handle different tasks to speed up work. Parallelism is impossible on a single-core processor because only one computation can happen during any single clock cycle. In contrast, concurrent computing focuses on overlapping lifetimes. On a single core, concurrency is achieved through time-sharing slices. The system executes a small bit of one process, pauses it, and then moves to another. This interleaving makes it appear as though multiple processes are running, even though only one is active at any specific instant.

Concurrency can be implemented in several ways depending on the hardware and software. One method is to treat each execution as an operating system process. Another way is to use threads, which are smaller units of execution within a single operating system process. When these concurrent tasks need to interact, they generally use one of two communication styles: shared memory or message passing. In shared memory communication, components interact by changing data in a common location. Languages like Java and C# use this model. Message passing involves components exchanging specific messages. Languages like Erlang and Go use this style. Message passing is often considered more robust because it is easier for programmers to reason about.

Designing these systems presents significant challenges, primarily regarding concurrency control. This is the process of coordinating how different executions access shared resources. If not controlled, systems can suffer from race conditions, deadlocks, or resource starvation. A race condition occurs when the timing of events affects the correctness of the outcome. For example, if two threads try to withdraw money from a bank account at the same time, they might both see a high balance before either has finished subtracting the amount. This could result in a total withdrawal that exceeds the actual balance. To prevent this, programmers use tools like locks, mutexes, or semaphores to ensure thread safety.

To ensure that results remain predictable, programmers use a consistency model, also known as a memory model. This model defines the rules for how operations on computer memory occur. One famous example is Leslie Lamport's sequential consistency model. A program is sequentially consistent if its execution produces the same results as if all the operations were performed in some sequential order. This ensures that even though many things are happening at once, the final state of the computer makes sense. This mathematical rigor allows developers to build much more complex and reliable software systems.

The history of concurrent computing is rooted in much older engineering problems. The field grew out of 19th and early 20th-century work regarding railroads and telegraphy. Engineers had to figure out how to manage multiple trains on a single railroad without collisions. They also had to manage multiple transmissions over telegraph wires using methods like time-division multiplexing. The formal academic study of concurrent algorithms began in the 1960s. This era saw the development of important models like Petri nets in 1962. Later, researchers developed process calculi, such as Communicating Sequential Processes (CSP), to allow for algebraic reasoning about interacting components.

Today, concurrent computing is pervasive across all levels of technology. It exists in low-level hardware on single chips and in massive global networks. At the operating system level, we see it in multitasking and time-sharing. At the network level, almost all systems are concurrent because they consist of many separate devices working together. Using concurrency offers major advantages, such as increased program throughput. According to Gustafson's law, parallel execution of a concurrent algorithm can increase the number of completed tasks proportionally to the number of processors. It also provides high responsiveness for input/output tasks, as the computer can work on something else while waiting for data to arrive.

759 words

Where will your curiosity go next?

Keep exploring at your chosen reading level.

More to explore

What is Nepedia?

A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.