andersch.dev

<2024-07-03 Wed>

Concurrency

Concurrency is the ability of a program to have parts of it be executed out-of-order in parallel.

Granularities of Concurrency

Process:

  • Scheduling done by OS
  • Own virtual address space
  • Can communicate with other processes using IPC methods
  • Each process can have multiple states of code executions, i.e. threads

Thread:

  • Has its own instruction pointer
  • Has a state of the registers in the processor

Fiber:

  • A "manual version" of a thread, i.e. without hardware backing
  • A software method of overlapping work

Concurrency in C

  • libdill: C library that makes writing structured concurrent programs easy
  • libcsp: concurrency in C using Communicating sequential processes (CSP) model