Process¶
Category: Units of execution · Status: stub · Lessons: chapter 08, Processes (planned)
One line: A running program with its own address space, open files and at least one thread; two processes share nothing unless they arrange to.
Also called: OS process.
How it connects¶
flowchart LR
n_subprocess["Child process"]
n_ipc["Inter-process communication"]
n_mpi["MPI"]
n_multiprocessing["Multiprocessing"]
n_process["Process"]
n_thread["Thread"]
n_ipc -->|uses| n_process
n_mpi -->|uses| n_process
n_multiprocessing -->|uses| n_process
n_process ---|vs| n_thread
n_subprocess -->|is a| n_process
classDef center stroke-width:3px
class n_process center
classDef outside stroke-dasharray: 4 3
class n_subprocess,n_ipc,n_mpi,n_multiprocessing,n_thread outside
- Kinds: Child process
- Is used by: Inter-process communication, MPI, Multiprocessing
- Often confused with: Thread
- See also: Context switch, Inter-process communication, Multiprocessing
In each language¶
| Rust | std::process::Command ↗ spawns a child process and returns a Child ↗ |
| Go | os/exec ↗ runs an external command |
| C | fork ↗ copies the calling process but only the thread that called it; posix_spawn ↗ starts a new program |
| Java | ProcessBuilder ↗ starts a Process ↗; ProcessHandle ↗ (Java 9) inspects any process |
| Python | subprocess ↗ runs programs; multiprocessing ↗ runs Python functions in child processes |
| C# | Process.Start ↗ |
| Erlang and Elixir | An external program is reached through a port ↗, and runs in another OS process |
| The operating system | fork(2) ↗ and execve(2) ↗; on Linux clone(2) ↗ creates processes and threads alike |
Where to read more¶
- In this library: Who waits when main returns?
- In a sibling library: Linux: head closes the pipe early ↗
- In the books: The Little Elixir & OTP Guidebook, Benjamin Tan Wei Hao — ch. 3, 'Processes 101'
- In the books: Learn Concurrent Programming with Go, James Cutajar — ch. 2, 'Dealing with threads' → 'Abstracting concurrency with processes and threads'
- In the books: Async Rust, Maxwell Flitton, Caroline Morton — ch. 1, 'Introduction to Async' → 'Introduction to Processes'
- In the books: Mastering C++ Multithreading, Maya Posch — ch. 2, 'Multithreading Implementation on the Processor and OS' → 'Defining processes and threads'
- In the books: Learning Concurrent Programming in Scala, Aleksandar Prokopec — ch. 2, 'Concurrency on the JVM and the Java Memory Model' → 'Processes and threads'
- In the books: Python Concurrency with asyncio, Matthew Fowler — ch. 1, 'Getting to know asyncio' → 'Understanding processes, threads, multithreading, and multiprocessing'
- Notes: processes and the operating system ↗
- Notes: process - rust ↗
- Notes: exit - function - rust - std::process::exit ↗
- Notes: how the CPU interacts with processes and threads ↗
- Reference: Wikipedia: Process (computing) ↗