warming up your workspace

Operating Systems

Learn C through operating-system models: process state, scheduling, synchronization, allocation, virtual memory, replacement, files, I/O, a bounded command interpreter and an instruction-driven mini-kernel.

11 projects, 275 hands-on levels, run in your browser.

Syllabus

  • Foundations: code through operating systems: Start with typed C functions, variables, integer and decimal arithmetic, choices, loops and arrays. Small operating-system examples give each language feature a purpose. Finish by combining helpers into a resource summary; no previous programming experience is assumed.
  • Processes: Represent process records, save and restore execution context, validate lifecycle transitions and manage a bounded process table. Then follow parent-child relationships and model numbered system calls and file descriptors. These array-based exercises explain process bookkeeping without creating host processes.
  • CPU Scheduling: Simulate CPU scheduling and compare completion, waiting, response and turnaround measures. Build FCFS, shortest-job selection, round-robin and priority/aging rules, with explicit assumptions about arrival times and ties. The outputs describe modeled workloads rather than measurements of a host scheduler.
  • Synchronization & Deadlock: Trace shared-state interleavings, lock and semaphore transitions, bounded-buffer operations and deadlock conditions. Use wait-for graphs and a safety algorithm to reason about progress. The C functions simulate these decisions sequentially; they are not thread-safe synchronization primitives for a real concurrent program.
  • Memory Allocation: Represent a finite heap as blocks, select holes with placement policies, split allocations and coalesce adjacent free space. Measure internal and external fragmentation, then study aligned power-of-two buddies. The project manipulates allocation metadata in arrays rather than replacing the host malloc implementation.
  • Virtual Memory: Split addresses into page numbers and offsets, encode page-table flags, track free frames and cache translations in a TLB. Finish by assembling a bounded two-level virtual-memory model with demand allocation, access flags, unmapping and cache invalidation. It models translation metadata, not hardware execution or stored page contents.
  • Page Replacement: Run page-reference traces through FIFO, LRU, Clock and the offline optimal policy. Compare observable fault counts, study FIFO anomalies and LRU inclusion, and relate a working set to available frames. These trace results depend on the specified workload and do not establish universal runtime performance rankings.
  • File Systems: Build block arithmetic, inode-style pointers, allocation bitmaps, FAT links, path lookup and permission selection. Finish with an in-memory named-file store that creates, reads and removes actual text while keeping its metadata consistent. Real filesystems persist data; this bounded model does not write a disk image or survive a restart.
  • Disk & I/O: Model mechanical head movement under FCFS, SSTF, SCAN and C-SCAN, then study cache accounting, read-ahead, striping, mirroring and XOR parity. Queue, throughput and percentile exercises make the assumed units explicit. These calculations describe chosen models, not measured SSD or disk latency.
  • The Shell & IPC: Learn space-based tokenization, pipe capacity, status selection, modeled signals and job transitions. Assemble a bounded command interpreter with real text pipelines, in-memory redirection and an injectable input/output loop. Its finite course demo uses supplied programs and model jobs; it does not fork or execute host commands.
  • Capstone: A Mini Kernel: Assemble a mini-kernel simulator from process loading, round-robin dispatch, frame allocation, FIFO eviction and syscall transitions. Execute bounded instruction streams, advance through blocked-only intervals, reclaim memory at exit and account for instruction and idle ticks. This is an ordinary C simulation, not a bootable or privileged kernel.

Key concepts

  • Aging: Gradually improving a waiting task's scheduling priority to reduce starvation. A guarantee of eventual service also depends on the complete policy and work…
  • Allocator: A manager of a program's dynamic memory. The course represents blocks and practices placement, splitting and merging; real allocators may use many addition…
  • Atomic operation: An operation whose specified effects are indivisible to other relevant observers. Real C concurrency requires supported atomic operations or synchronization; a…
  • Banker's algorithm: Deadlock avoidance: grant a request only if some completion order still exists afterward (the state stays 'safe'). Pretend-finish processes one by one;…
  • Belady's anomaly: Belady's anomaly is an increase in page faults when more frames are supplied under some policies and traces, including FIFO. Stack policies such as LRU avo…
  • Blocked (waiting): A process that cannot run until some event happens, usually I/O finishing or a lock freeing. Blocking frees the CPU for someone else, the heart of multiprogram…
  • Buddy system: An allocator that splits aligned power-of-two blocks into equal halves. A block's same-size buddy is located by XORing its relative offset with its size; m…
  • Buffer cache: Memory used to retain storage blocks and track modified data awaiting writeback. Hits can avoid device reads; durability operations and cache behavior depend o…
  • Clock (second chance): A second-chance replacement policy with reference bits and a circular hand. It approximates aspects of recency with less bookkeeping than exact LRU, but can ch…
  • Coalescing: Combining physically adjacent free blocks into a larger free block. It can reduce external fragmentation but cannot merge across a live allocation.
  • Coffman conditions: The four prerequisites of deadlock: mutual exclusion, hold-and-wait, no preemption, circular wait. Prevention strategies each attack one.
  • Context switch: Saving execution context for one task and restoring context for another. Its cost depends on the architecture and workload; a slice expiry alone need not chang…
  • Convoy effect: Delay experienced by shorter or otherwise ready work queued behind a long-running job, notably in nonpreemptive FCFS scheduling.
  • Critical section: A region accessing shared state whose required invariants need coordination. Mutual exclusion admits at most one holder for the protected resource; other synch…
  • Deadlock: A set of participants unable to progress because each waits for an event or resource another in the set must provide. Resource-allocation deadlocks are analyze…
  • Demand paging: Establishing page residency when an access first requires it rather than loading every page in advance. Startup, fault costs and resident memory depend on the…
  • Directory: A filesystem structure associating names with object identifiers. Directory traversal resolves components one at a time; the final course store has one root an…
  • Disk block: A filesystem allocation or I/O unit. In the course's full-block model, a nonempty file rounds up to a whole number of blocks and may leave final-block slac…
  • Disk scheduling: Selecting request order to pursue goals such as reduced movement, latency or fairness. The course models a mechanical head with explicit tie and endpoint rules.
  • Error codes (errno): A C library error-reporting value, commonly set when a wrapper returns -1. The course models several syscall failures directly as negative numbers; that differ…
  • Exit status: A value describing how a process terminated. Zero conventionally means success. The lessons use a specified packed status and shell-style signal mapping; real…
  • File allocation table (FAT): A file allocation table stores links between a file's clusters in an indexed table. The teaching model uses -1 for end and zero for free; on-disk FAT forma…
  • File descriptor: A small nonnegative per-process handle for an open resource such as a file, pipe or socket. Unix-like open and duplication operations use descriptor allocation…
  • First / best / worst fit: Placement policies for a request among free holes: first fit takes the earliest, best fit the tightest (smallest leftover), worst fit the roomiest. Each shapes…
  • First-come, first-served (FCFS): Run jobs in arrival order, each to completion. Simple, but one long job at the front makes everyone wait, the convoy effect.
  • Five-state lifecycle: A teaching lifecycle with NEW, READY, RUNNING, BLOCKED and TERMINATED states. A waiting event such as I/O completion, a timer or resource availability can make…
  • fork(): On Unix-like systems, fork creates a child process from the caller. If every existing process successfully performs each of n successive forks, with no exits o…
  • Fragmentation: External fragmentation leaves free space in separate holes too small for a particular contiguous request. Internal fragmentation is unused space inside an allo…
  • Free-space bitmap: A bit array tracking block availability. This course uses one for allocated and zero for free; the convention and accounting structures differ across filesyste…
  • I/O overlap: Allowing another ready task to compute while one task waits for I/O. Saved elapsed time depends on the available independent work and wait duration, not on eli…
  • Indirect block: In a classic pointer-based file layout, a block containing addresses of data blocks or further pointer blocks. The number of entries depends on block and point…
  • init (pid 1): The initialization process with PID1 in a Unix-like PID namespace. It has special lifecycle and reaping responsibilities; details vary by operating system and…
  • Inode: A filesystem object record holding metadata and information locating file data in inode-based designs. Directory entries associate names with inode identifiers…
  • Job control: Managing foreground, background, stopped and completed jobs. Real shell jobs may contain process groups; the course records bounded job states and remaining mo…
  • Kernel mode vs user mode: A privileged CPU execution mode used by operating-system code. User mode restricts privileged operations; system calls, interrupts and exceptions can transfer…
  • LRU: Least recently used replacement evicts the resident page whose last access is oldest. Exact LRU needs recency bookkeeping and has the stack-inclusion property;…
  • Multi-level feedback queue (MLFQ): A family of schedulers using several priority queues and feedback about task behavior. Demotion, promotion and priority boosts are policy choices rather than o…
  • Mutex: A mutual-exclusion lock, normally with ownership rules that require the holder to release it. A binary semaphore can model some exclusion patterns but does not…
  • Orphan process: A process whose parent has exited. The course reparents it to PID1. Real Unix-like systems may use a designated subreaper or namespace-specific reaper.
  • Page & frame: Memory in fixed chunks: virtual pages map onto physical frames. An address splits into page number (translated) and offset (untouched).
  • Page fault: An exception or modeled event when an access cannot proceed under the current mapping or permissions. Handling may allocate or fetch a page, resolve a protecti…
  • Page replacement: Choosing a resident page to evict when a new page needs a full frame pool. Policies trade bookkeeping cost and fault behavior; OPT is an offline lower-bound be…
  • Page table: A structure describing virtual-page mappings and access metadata. Multiple levels can avoid allocating leaf tables for large unmapped regions, while still requ…
  • Page table entry (PTE): A page-table entry encodes a mapping and flags defined by its format. The course packs a frame with valid, dirty and referenced bits; real hardware formats and…
  • Path resolution: Resolving a path by looking up its components from a starting directory. The course's simple resolver skips empty slash components; real systems also handl…
  • Permission bits (rwx): Ordinary Unix-style owner/group/other triplets contain read4, write2 and execute1. The course selects exactly one triplet by identity and checks requested bits…
  • PID: A process identifier. The course allocates one above the current maximum; real systems have bounded PID spaces and may reuse identifiers. PID1 has a special in…
  • Pipe: A unidirectional byte channel. In a blocking model, an empty pipe waits while writers remain open; after all writers close, remaining data is read before EOF.…
  • Process: A program execution together with operating-system state such as its address space, open resources and identity. A process can contain one or more threads.
  • Process control block (PCB): A process control block stores management and saved execution information, such as identity, state and registers. Its fields depend on the operating system; th…
  • Process table: A collection of process records. The course uses a fixed array with a free-slot sentinel. A PID names a process and need not equal its position in that array.
  • Producer-consumer: A pattern in which producers add work and consumers remove it. A bounded queue needs capacity and availability rules; a ring buffer is one common implementatio…
  • Race condition: A bug whose outcome depends on interleaving: two unsynchronized increments can lose one update, because counter++ is really load, add, store.
  • RAID: Redundant array designs combine drives with striping, mirroring or parity. The course uses RAID0 capacity n*size, one n-way RAID1 mirror set with capacity size…
  • Read-ahead: Fetching data before an explicit request based on predicted access. It may help sequential workloads, but wrong predictions can waste bandwidth and cache space.
  • Ring buffer: A fixed array with wrapping head and tail indices: put at the tail, get at the head, both modulo capacity. Constant-time FIFO in constant space.
  • Round Robin: A scheduling policy that gives ready jobs bounded turns and revisits unfinished jobs cyclically. Response and overhead depend on quantum, ready workload and sw…
  • SCAN / C-SCAN: SCAN serves requests along a sweep and reverses direction; C-SCAN serves in one direction and returns to the start. Movement and waiting depend on endpoint con…
  • Scheduler: The component that chooses which eligible task runs next. Scheduling policy affects waiting, response, throughput and fairness under the workload being conside…
  • Seek time: The time a mechanical drive spends moving its head. Cylinder-distance models approximate one component of I/O latency; SSDs have no mechanical seek arm.
  • Semaphore: A synchronization object representing permits and waiting operations. A wait consumes an available permit or blocks; a signal supplies a permit or wakes a wait…
  • Shell: A command interpreter that evaluates input and manages execution and I/O. Real Unix-like shells often use fork/exec and pipes; the course assembles a bounded i…
  • Shortest job first (SJF): Nonpreemptive shortest-job-first selects the smallest available CPU burst and runs it to completion. With all jobs ready initially and known bursts, it minimiz…
  • Signal: An asynchronous notification with a disposition and mask rules. Real POSIX SIGKILL and SIGSTOP cannot be caught, ignored or blocked. The course uses explicitly…
  • Spinlock: A lock acquired by retrying while it is held. Spinning consumes CPU time and is appropriate only under suitable scheduling and contention assumptions.
  • Starvation: A runnable job waiting indefinitely because the policy always prefers others, SJF's long jobs, low priorities under strict priority scheduling.
  • System call: A controlled request from a program to operating-system services, such as reading a file or creating a process. The lessons dispatch ordinary C functions to mo…
  • Test-and-set: An atomic read-modify-write primitive that returns an old flag and sets it. In the course's sequential lock model, an old zero indicates successful acquisi…
  • Thrashing: Excessive paging that leaves little useful progress. Capacity, workload concurrency, locality and replacement/admission policies can all affect it.
  • Thread: A schedulable execution stream inside a process. Threads share the process's memory but each has its own registers and stack, which is why they race on sha…
  • Throughput: Jobs completed per unit time. Often traded against responsiveness: batch systems chase throughput, desktops chase response time.
  • Time quantum: The maximum length of a round-robin turn before unfinished work yields. A smaller quantum can improve initial response while increasing scheduling overhead; un…
  • TLB: A cache of address translations and related attributes that can avoid page-table walks. Its effect on cost depends on hit rate, lookup design and table-walk be…
  • Turnaround, waiting, response: Turnaround is completion minus arrival; response is first execution minus arrival. For the CPU-only jobs here, waiting is turnaround minus burst time. In a mod…
  • umask: The bits REMOVED from a new file's requested mode: effective = mode & ~umask. The classic 022 strips group and other write.
  • Virtual memory: An address-space abstraction that maps virtual pages to physical frames and applies access rules. Separate address spaces can share selected pages; isolation a…
  • Wait-for graph: A directed graph from a waiting process to a process it depends on. In the course's single-successor resource-wait model, a directed cycle is a deadlock. M…
  • Working set: The set of distinct pages referenced during a chosen recent interval. It estimates active memory demand; the interval and workload affect the estimate.
  • XOR parity: XOR of data blocks can reconstruct one missing data block from the surviving data and parity. This simple scheme does not recover two unknown blocks.
  • Zombie process: An exited child whose termination information has not yet been collected by a waiting parent or reaper. Most execution resources have been released, but bookke…