📘 How does an operating system run a machine?
An operating system performs two complementary roles. As a resource manager it multiplexes the CPU, memory, and I/O devices among competing programs, deciding who gets what and when. As an extended machine it hides messy hardware behind cle
What you’ll learn
- What an Operating System Is: Abstraction, Mechanism, and the Kernel BoundaryExplain the operating system's role as a resource manager and abstraction layer, and distinguish user mode from kernel mode and the system-call interface that separates them.An operating system is the software layer that manages a computer's hardware resources and provides programs with clean, portable abstractions such as processes, files, and address spaces. The CPU enforces a hardware boundary between an unprivileged user mode and a privileged kernel mode, and applications cross that boundary only through the controlled entry point of a system call. Understanding this dual role, manager and abstraction provider, and the mode boundary that enforces protection, frames every other topic in the course.
- Processes and Threads: Creating, Controlling, and Coordinating ExecutionDescribe the process abstraction and its lifecycle, contrast processes with threads, and trace how POSIX fork, exec, and wait create and manage running programs.A process is a program in execution, bundling an address space, open files, and at least one thread of control, all tracked by the kernel in a process control block. Processes move through a small set of states (new, ready, running, waiting, terminated) driven by scheduling and I/O. Under POSIX, fork creates a child as a near-copy of the parent, exec replaces the program image, and wait lets a parent collect a terminated child's status, which is the classic shell command-execution pattern. Threads share an address space within a process, trading isolation for cheap communication and concurrency.
- CPU Scheduling: Sharing the Processor Fairly and EfficientlyCompare classic CPU scheduling algorithms and reason about how they trade off throughput, turnaround time, response time, and fairness.The CPU scheduler decides which ready process runs next, optimizing metrics such as CPU utilization, throughput, turnaround time, waiting time, and response time. Non-preemptive policies like FCFS and SJF are simple but can starve or delay processes, while preemptive policies like round robin and priority scheduling improve responsiveness at the cost of context-switch overhead. Shortest-job-first is provably optimal for average waiting time but requires predicting burst lengths, and priority schemes risk starvation that aging can mitigate. No single algorithm wins on every metric, which is why real systems combine ideas, often with multilevel feedback queues.
- Concurrency, Synchronization, and DeadlockIdentify race conditions and critical sections, apply locks and semaphores to enforce correct synchronization, and analyze deadlock using its four necessary conditions.When concurrent threads access shared data without coordination, the outcome depends on timing, producing race conditions; the code touching shared state is a critical section that must be executed under mutual exclusion. Locks, semaphores, and monitors provide that mutual exclusion, but blocking primitives introduce the risk of deadlock, where a set of threads each waits forever for resources held by the others. Deadlock requires four conditions to hold simultaneously, mutual exclusion, hold-and-wait, no preemption, and circular wait, so breaking any one prevents it. Systems handle deadlock by prevention, avoidance (for example the banker's algorithm), detection and recovery, or by ignoring it when rare.
- Memory, Virtual Memory, and the Storage HierarchyExplain address translation through paging, the role of the TLB and page faults in demand paging, and how page-replacement policy and the working set govern performance.Virtual memory gives each process a private, contiguous virtual address space that the hardware MMU translates to physical frames via page tables, with a TLB caching recent translations to make translation fast. Demand paging loads pages only when first referenced, so a reference to a not-present page triggers a page fault that the kernel services by fetching the page from disk. When memory is full the kernel must choose a victim using a replacement policy; LRU and optimal are stack algorithms immune to Belady's anomaly, while FIFO can suffer it. Keeping each process's working set resident avoids thrashing, the pathological state where the system spends most of its time paging rather than computing.
- Guided Project: A Shell with Process Tracing and a Scheduling SimulatorBuild and document a portfolio artifact that demonstrates operating-systems concepts in code: a minimal command shell using fork/exec/wait plus a CPU-scheduling simulator that compares algorithms.This capstone consolidates the course into one portfolio artifact in two parts. Part A is a minimal interactive shell that parses a command line, uses fork to create a child, exec to run the program, and wait to reap it and report exit status, directly exercising the process model from Lesson 2. Part B is a CPU-scheduling simulator that, given a list of processes with arrival and burst times, computes average waiting and turnaround time under FCFS, SJF, and round robin, making the trade-offs from Lesson 3 concrete. You will document design decisions, include test cases, and write a short reflection connecting your code to the synchronization and memory concepts from Lessons 4 and 5.
Questions this course answers
What mechanism prevents a user-mode program from directly executing a privileged instruction such as loading the page-table base register?
Protection is enforced at runtime by hardware: a mode bit records the current privilege level, and attempting a privileged instruction in user mode causes the CPU to trap to the kernel rather than execute it. The instruction set is the same in both modes; the difference is what the hardware permits.
Which of the following is the correct characterization of a system call?
A system call is the sanctioned way for user code to request kernel services. It executes a trap instruction that switches the CPU to kernel mode and jumps to a fixed, validated kernel entry point. It is synchronous and deliberate, unlike a hardware interrupt, and it crosses the protection boundary, unlike an ordinary function call.
A divide-by-zero error during program execution is best classified as which kind of kernel-entry event?
A divide-by-zero is synchronous (it is caused directly by the executing instruction) and is an error condition, which makes it an exception or fault. It is not asynchronous like a device interrupt, and the program did not voluntarily request it as it would with a system call.
Immediately after a successful fork(), how does code distinguish whether it is running in the parent or the child?
fork() returns twice: in the parent it returns the new child's process ID (a positive number), and in the child it returns 0. Comparing the return value against 0 is the standard way each branch determines its role. A negative return indicates failure in the parent.
Why does a successful call to a member of the exec family normally not return to the calling code?
exec overwrites the calling process's text, data, heap, and stack with a new program while keeping the same PID. On success the original instructions are gone, so there is nothing to return to; exec only returns if it fails to load the new program. It does not create a new process, which is fork's job.
What is a zombie process?
A zombie is a process that has terminated but whose exit status has not yet been reaped via wait/waitpid. It holds no address space, only a process-table entry retaining the status. An orphan (parent gone, reparented to init) is a different condition, and a CPU-bound loop is not a zombie at all.
Grounded in trusted sources
- Silberschatz, Galvin, and Gagne, Operating System Concepts, 10th Edition (Wiley, 2018), Chapters 1-2
- Tanenbaum and Bos, Modern Operating Systems, 4th Edition (Pearson, 2014), Chapter 1
- Silberschatz, Galvin, and Gagne, Operating System Concepts, 10th Edition (Wiley, 2018), Chapters 3-4
- IEEE Std 1003.1-2017 (POSIX.1-2017), The Open Group Base Specifications Issue 7, System Interfaces (fork, execve, waitpid)
- Silberschatz, Galvin, and Gagne, Operating System Concepts, 10th Edition (Wiley, 2018), Chapter 5
- Tanenbaum and Bos, Modern Operating Systems, 4th Edition (Pearson, 2014), Chapter 2
Every Wunder lesson is built from real, reputable sources — never invented.
Related courses
Wunder is a personalized learn-anything platform — tell it any topic and it builds a beautiful, fact-checked course in minutes, with narration, a knowledge check, and a college-style University track.
© 2026 Wunder Learning LLC · Terms & Privacy