liveBook · Manning

Multiprocessing

As explained in Learn Concurrent Programming with Go

An operating-system capability in which multiple tasks are managed so that more than one can make progress on available processor resources.

Multiprocessing lets an operating system manage multiple tasks so more than one can make progress on available processor resources. When one task waits for input or file I/O, the system can run another task and keep the CPU productive. section 2.1

A task can move through several operating-system states:

  • Enter the job queue after submission when it is not yet ready to run. section 2.1
  • Move to the ready queue, then run when the CPU becomes available. section 2.1
  • Enter an I/O waiting queue when it requests file input, allowing another ready task to use the CPU. section 2.1
  • Resume after the I/O operation returns data, or terminate when execution finishes. section 2.1

A concurrent command pipeline

The command `curl -s https://www.rfc-editor.org/rfc/rfc1122.txt | wc` runs `curl` and `wc` as separate concurrent processes. A pipe buffers curl's output for wc's input: curl blocks when the buffer is full, while wc blocks when it is empty. After curl finishes, an end-of-data marker allows wc to terminate. section 2.2.3

Figure 2.4 Curl and wc running concurrently using a pipe

Use the process-and-pipe diagram to trace how separate commands exchange data while running concurrently. section 2.2.3

How Learn Concurrent Programming with Go covers it

How deep it goes
Explains job, ready, running, and I/O waiting states, then demonstrates process coordination through a buffered pipe.
Examples
Uses a large-file string search and a curl-to-wc UNIX pipeline to illustrate scheduling, process IDs, buffering, and termination.
What it assumes
Assumes basic command execution and introduces job states, process coordination, and pipe behavior through concrete UNIX examples.
What you can do after
Evaluate/understand how operating systems schedule tasks and coordinate command-line processes through pipes.
How it connects
Connects operating systems, CPU scheduling, processes, concurrency, interprocess communication, and pipes.

Also explained in

Compare how 3 books explain multiprocessing →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Concurrent Programming with Go. The section links point to the parts of the book it draws on.