Engineering Concurrency Models

Engineering concurrency models describe how multiple activities make progress and coordinate their work. You encounter them when software acquires sensor readings, processes independent simulation cases, or handles incoming measurements while saving earlier results. Choosing a model involves three questions: which activities can overlap, how they exchange information, and what prevents an incorrect result when their execution order changes.

Concurrency and execution models

Concurrency means that multiple activities make progress during overlapping periods. They need not execute at the same instant. On one processor core, a scheduler can alternate between tasks. Parallel execution occurs when tasks actually execute simultaneously, such as on different cores. Consequently, a concurrent program may remain correct on one core even though it gains little computational speed.


Task bars show interleaved execution on one core and overlapping execution on two cores.


A thread is a sequence of execution within a process. Threads in the same process normally share its memory, although each has its own execution state. Other models organize concurrency around separate processes, messages, or tasks that suspend while waiting.


Model

How activities communicate

Main coordination concern

Shared-memory threads

Read and write shared objects

Protect conflicting access and establish visibility

Message passing

Send values through communication channels

Match messages and manage waiting or buffering

Asynchronous tasks

Suspend at supported waiting operations and resume later

Respect dependencies and avoid blocking the task scheduler


These models can be combined. For example, asynchronous tasks might collect measurements while worker threads perform calculations. Asynchronous execution is especially useful for overlapping waits; it does not by itself make processor-intensive calculations execute in parallel. Messages reduce direct sharing, but a full communication buffer can still make a sender wait.

Correctness depends on coordination

A shared update can contain several operations even when its source code occupies one line. Incrementing a counter may require reading its current value, adding one, and writing the result. If two threads both read zero before either writes, each may write one. Two completed increments have then produced a count of one.


A critical section is a region that accesses a shared resource and requires coordinated access. One common solution is mutual exclusion: every conflicting access uses the same mutex, and the mutex protects the complete update. Protecting only the final write leaves the earlier read exposed. A suitable atomic increment can also protect this particular operation, but separate atomic operations do not automatically protect a larger multi-operation invariant.



Correctness also includes progress. Deadlock occurs when activities wait indefinitely for conditions that their own waiting prevents. A consistent order for acquiring multiple locks can prevent circular lock waiting. Bounded queues introduce another dependency: a producer may need a consumer to remove an item before it can continue. Trace both data dependencies and waiting conditions.

Estimating performance

For a fixed workload, a useful simplified model is


Tp=Ts+Tparallelp+Hp,Sp=T1Tp,Ep=Spp.T_p=T_s+\frac{T_{\mathrm{parallel}}}{p}+H_p, \qquad S_p=\frac{T_1}{T_p}, \qquad E_p=\frac{S_p}{p}.


Here, TsT_s is serial work, TparallelT_{\mathrm{parallel}} is parallelizable work measured on one worker, pp is the worker count, and HpH_p is additional elapsed-time overhead. All times use matching units. Speedup SpS_p and efficiency EpE_p are dimensionless; multiply efficiency by 100%100\% to express it as a percentage.


This model assumes enough execution resources, perfectly balanced parallel work, and no overlap between the listed time components. Actual overhead can include starting workers, exchanging messages, and waiting at synchronization points. With negligible overhead and serial fraction ff, the model gives Amdahl's relation:


Sp=1f+(1−f)/p.S_p=\frac{1}{f+(1-f)/p}.


For nonzero ff, increasing the worker count leaves a serial bottleneck. Growing overhead can even make additional workers slower.



What to remember

  • Concurrency permits overlapping progress; parallelism requires simultaneous execution.
  • Match communication and synchronization to the model you choose.
  • Protect complete shared updates and check whether waiting activities can still progress.
  • Estimate elapsed time using serial work, divided parallel work, and explicit overhead.

Example: Choosing workers for a simulation run

An engineering program evaluates independent operating cases. Its one-worker baseline has 1.20 s1.20\ \text{s} of serial setup and reporting, followed by 6.00 s6.00\ \text{s} of parallelizable calculation. The baseline has no additional worker-management overhead.


A four-worker configuration adds 0.30 s0.30\ \text{s} of total overhead. An eight-worker configuration adds 0.75 s0.75\ \text{s} of total overhead. Assume enough cores for simultaneous execution, equal division of the calculation, and no overlap between serial work, calculation, and overhead. Use these supplied times as exact model inputs and round final times to two decimal places.


a) Calculate the one-worker baseline elapsed time.


The baseline includes the serial work and the complete calculation on one worker. There is no additional overhead in this reference configuration, so add the two supplied durations directly.


T1=Ts+Tparallel=1.20 s+6.00 s=7.20 sT_1=T_s+T_{\mathrm{parallel}}=1.20\ \text{s}+6.00\ \text{s}=7.20\ \text{s}


The baseline elapsed time is 7.20 s7.20\ \text{s}. This complete baseline, including serial work, is the numerator used when calculating speedup.


b) Calculate the four-worker elapsed time, speedup, and efficiency. Report speedup to two decimal places and efficiency to one decimal place as a percentage.


Only the parallelizable calculation divides among the workers. The four-worker calculation time is


Tparallel,4=6.00 s4=1.50 s.T_{\mathrm{parallel},4}=\frac{6.00\ \text{s}}{4}=1.50\ \text{s}.


Add the unchanged serial time and the four-worker overhead:


T4=1.20 s+1.50 s+0.30 s=3.00 s.T_4=1.20\ \text{s}+1.50\ \text{s}+0.30\ \text{s}=3.00\ \text{s}.


Speedup compares the complete baseline with the complete four-worker elapsed time:


S4=T1T4=7.20 s3.00 s=2.40.S_4=\frac{T_1}{T_4}=\frac{7.20\ \text{s}}{3.00\ \text{s}}=2.40.


Efficiency compares that speedup with the worker count:


E4=S44=2.404=0.600=60.0%.E_4=\frac{S_4}{4}=\frac{2.40}{4}=0.600=60.0\%.


The four-worker configuration takes 3.00 s3.00\ \text{s}, achieves a speedup of 2.402.40, and has efficiency 60.0%60.0\%. Serial work and overhead explain why four workers do not provide a speedup of four.


c) Calculate the eight-worker elapsed time and its percentage time reduction relative to four workers. Which configuration meets a requirement to finish within 2.80 s2.80\ \text{s}?


The eight workers divide the same calculation into equal shares:


Tparallel,8=6.00 s8=0.75 s.T_{\mathrm{parallel},8}=\frac{6.00\ \text{s}}{8}=0.75\ \text{s}.


Use the eight-worker overhead, which replaces the four-worker overhead:


T8=1.20 s+0.75 s+0.75 s=2.70 s.T_8=1.20\ \text{s}+0.75\ \text{s}+0.75\ \text{s}=2.70\ \text{s}.


The elapsed-time saving relative to four workers is


ΔT=T4−T8=3.00 s−2.70 s=0.30 s.\Delta T=T_4-T_8=3.00\ \text{s}-2.70\ \text{s}=0.30\ \text{s}.


Use the four-worker time as the denominator because it is the comparison baseline:


Time reduction=0.30 s3.00 s×100%=10.0%.\text{Time reduction}=\frac{0.30\ \text{s}}{3.00\ \text{s}}\times100\%=10.0\%.


Doubling the worker count reduces the calculation time by 0.75 s0.75\ \text{s}, but overhead increases by 0.45 s0.45\ \text{s}, leaving a net saving of 0.30 s0.30\ \text{s}. Among the two configurations, eight workers meet the 2.80 s2.80\ \text{s} requirement because 2.70 s<2.80 s2.70\ \text{s}<2.80\ \text{s}; four workers take 3.00 s3.00\ \text{s} and exceed it.

Two engineering computers process vibration recordings. Each computer has its own address space, and the computers exchange summary values over a network. Which concurrency model directly describes this exchange?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

An engineering application acquires sensor readings while analysing earlier measurements. Match each programming term to its definition, distinguishing how execution is organized from how shared access is controlled.

Match each term
A.

Simultaneous execution of operations on separate processing resources

B.

Execution path within a process that shares the process's memory with other such paths

C.

Organization of multiple activities so their progress can overlap in time, including through interleaved execution on one processor

D.

Synchronization object that allows at most one execution path at a time to hold ownership of a lock

Concurrency

Thread

Mutex

Parallelism

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

Four worker threads process measurement batches in one process. After each completed batch, a worker increments a shared integer counter. Assume each increment consists of a separate read, addition, and write; none of these compound increments is automatically atomic. All counter accesses occur in these updates, and the main thread reads the result only after joining every worker.


Which strategy guarantees that every completed batch is counted, assuming the synchronization operations provide their documented memory-visibility guarantees?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

Extra Practice