11 Operating-System Concepts

OPERATING SYSTEMSREVIEWED: 2026-09-13

Many surprises in parallel R come from the operating system, not from R. A forked worker’s memory grows after its first garbage collection because of copy-on-write page faults. Thirty-two CPU-bound workers on a four-core machine can finish later than four because of context switches. A forked child that closes an inherited database connection can end its parent’s session, and Ctrl-C reaches some workers and not others. This section covers the mechanisms behind each of these (virtual memory, process creation, scheduling, file descriptors and signals) as far as they explain R’s behavior.

Several pages in this corpus already rely on this material. The Processes vs Threads page explains isolation and communication costs at the OS level. The Shared Memory page covers synchronization built on OS primitives.

After this section

You understand what page faults are and when they trigger. You can reason about copy-on-write and why it works on fork but breaks under garbage collection. You know what a context switch costs and why oversubscription hurts. You understand file descriptor inheritance and why forked workers should open their own connections. You know when signals are safe and how user interruptions reach R code.

The pages

  1. Virtual Memory, Pages, and Page Faults explains address spaces, page tables, and why copy-on-write saves memory only if writes are rare.

  2. Process Creation: Fork, Spawn, and Exec shows what fork duplicates, what Windows offers in its place, and what a forked child inherits.

  3. OS Scheduling and Context Switches covers how the scheduler switches threads, the costs of preemption, and why too many threads hurt.

  4. Files, Sockets, Pipes, and Descriptors explains file descriptors as the common I/O abstraction and why inheriting them from fork is dangerous.

  5. Signals, Interrupts, and Cancellation covers asynchronous notification, what signal handlers can safely do, and how Ctrl-C reaches R.

Before this section

Reading this section requires no prerequisites. Familiarity with what processes and threads are helps, but it is not required. That page teaches the concepts from the programmer’s side. This section teaches from the OS side.

Where this leads

Four pages build on these mechanisms.

The Processes vs Threads page uses the OS mechanisms explained here to argue the tradeoffs of parallel design.

The Thread Pools page applies OS scheduling to explain why a fixed thread pool beats creating one thread per task.

The Fork, Copy-on-Write, and the First GC page measures how garbage collection defeats copy-on-write, a result that makes sense once page faults and private pages are clear.

Dynamic Linking and Symbol Resolution explains how shared libraries load and resolve symbols.

NUMA memory placement and real-time scheduling are left out of this section.

Back to top