MGU Computer Science Series — Computer Science Foundations
Part IV: Computer Systems
Processes · Memory · File Systems · Permissions · CLI · Multitasking
Chapter 16 of 28
MGU Computer Science Series  ·  Computer Science Foundations  ·  Library Textbook Edition

Chapter 16:
Operating Systems

The invisible software layer that manages hardware, processes, memory, files, users, and devices — and makes everything else possible

■ Part IV: Computer Systems ■

■ 10 Sections  •  Chapter 16 of 28 ■

Follows Chapter 15: Hardware and Computer Architecture  ·  Prepares for Chapter 17: Software, Applications, and Development Tools

Purpose and Overview

Every program you have ever used depends on software you almost never think about. The operating system is the invisible manager underneath every app, every file, every click, and every connection. When you open a browser, play a game, or save a document, the operating system is doing the quiet, essential work of making it all possible — managing the CPU, controlling memory, organizing storage, handling input, and enforcing the rules that keep everything running safely.

This chapter explains what an operating system is, why it exists, and what it does. Students will learn how operating systems manage programs and processes, control memory, organize file systems, enforce permissions, communicate with hardware devices through drivers, and provide interfaces for both users and programs. By the end of this chapter, students should understand the operating system not as a brand name or a logo, but as a fundamental software layer that mediates between hardware and everything that runs on top of it.

This understanding connects to everything else in computing. Programmers write code that depends on the OS. Networks are managed by OS services. Databases run as OS processes. Security policies are enforced by OS permissions. The web servers that deliver web pages run on operating systems. Understanding the OS means understanding the foundation on which all modern computing is built.

Opening Question

You open five programs at once — a browser, a music player, a word processor, a game, and a file manager — on a computer with four CPU cores. How can all five programs appear to run at the same time? Who is managing the CPU, the memory, and the storage while all of this is happening? By the end of this chapter, you will know exactly how the operating system makes this possible — and why understanding it matters for every area of computing you study next.

10Sections
10Objectives
30+Key Terms
3Worked Examples

Learning Objectives

  1. 1Explain what an operating system is and describe its major responsibilities.
  2. 2Distinguish between a program and a process and describe the process lifecycle.
  3. 3Explain how the OS scheduler enables multitasking on limited CPU cores.
  4. 4Describe how the OS manages memory through address spaces, memory protection, and virtual memory.
  5. 5Explain the structure of a file system, including files, folders, paths, and metadata.
  6. 6Interpret basic file permission strings and explain how permissions protect data.
  7. 7Explain the role of device drivers in the OS hardware communication model.
  8. 8Compare graphical user interfaces and command-line interfaces and identify when each is appropriate.
  9. 9Explain why operating system updates are important for security and reliability.
  10. 10Describe the OS as an abstraction layer and explain why this concept matters across all of computing.

Sections at a Glance

Sections 16.1 – 16.3
The OS as a Manager: Processes, Memory, and Control
What an OS Does · Programs and Processes · Memory Management

What an Operating System Does

When you press the power button on a computer, something has to start first. Before any app opens, before any file loads, before the screen shows anything useful, a large and complex piece of software has to wake up, check the hardware, prepare the environment, and take control. That software is the operating system.

An operating system, often called an OS, is the software that manages a computer's hardware and provides a foundation for all other software to run on. It sits between the physical machine and everything a user or program wants to do.

Think of the operating system as a building manager. The building is the hardware: the CPU, the memory, the storage, the keyboard, the screen, the network card. The tenants are the programs: your browser, your word processor, your game, your music player. The building manager does not live in any one apartment. Instead, the manager controls access to shared resources — the elevator, the parking, the electrical system, the security doors — so that every tenant can work without crashing into every other tenant.

Without an operating system, each program would have to control the hardware directly. Every programmer would have to write code to talk to every possible keyboard, screen, hard drive, and network adapter ever made. Programs would conflict with each other over who controls the CPU. One program crashing would bring down the entire machine. The operating system exists to prevent all of this.

What an Operating System Manages

ResponsibilityWhat the OS DoesExample
Process managementDecides which programs run, when, and for how longSwitches between browser and music player rapidly
Memory managementControls which parts of memory belong to which programsPrevents one program from reading another's data
File system managementOrganizes data into files and folders on storageCreates, reads, writes, and deletes files
Device managementCommunicates with hardware through driversSends text to a printer; reads input from a keyboard
User managementTracks users, login sessions, and access rightsKeeps each user's files private from other users
SecurityEnforces rules about what programs and users can doRefuses to let a program delete system files

Familiar Operating Systems

Students encounter operating systems every day. Windows runs on most personal computers in offices and homes. macOS runs on Apple Mac computers. Linux runs on servers, supercomputers, scientific instruments, routers, Android phones, and many embedded systems. Android and iOS are mobile operating systems built on Linux and Unix foundations respectively. Despite their different appearances and names, all of these share the same fundamental responsibilities. A financial server running Linux and a smartphone running Android and a laptop running Windows are all doing the same categories of work under the surface.

Study Note

The operating system is often called the kernel plus surrounding services. The kernel is the innermost part — it runs with the highest privileges and manages the CPU, memory, and hardware directly. When this chapter says "the OS," it means this entire system, including the kernel.

Managing Programs and Processes

When you double-click an icon to open an app, what actually happens? The operating system reads the program's instructions from storage, copies them into memory, creates a structure called a process, and begins executing the program's instructions on the CPU. A process is a running instance of a program. It is not the program file itself — it is the active, living execution of that program.

Programs versus Processes

A program is a set of stored instructions — a file on disk. A process is what happens when those instructions are loaded into memory and executed. You can have one program file and many processes. If you open three browser windows, you may have three separate browser processes — or one process with many threads, depending on how the browser is built. Each process has its own memory space, its own state, and its own position in the execution stream.

What a Process Contains

Every process carries several pieces of information that the operating system tracks: the instructions being executed (copied from the program file); the current position in those instructions, called the program counter; the values of all variables currently in use; open files, network connections, and other resources the process is using; a unique process ID (PID); the process's owner (which user started it); and the process's current status.

The Process Lifecycle

Diagram 16-A  ·  The Process Lifecycle
  Created ──► Ready ──► Running ──► Terminated
                ▲          │
                │          ▼
                └────── Waiting
                   (I/O, network,
                    user input)
    

Questions About This Diagram

  1. During a large file download, which state is the downloading process most likely in?
  2. What causes a process to move from Running back to Ready?
  3. When does a process move to Terminated?
  4. If a process never enters the Waiting state, what might that suggest about its behavior?

Every process goes through this lifecycle. It is created when the program launches. It becomes ready when it is prepared to run but waiting for the CPU. It is running when actively executing on the CPU. It enters waiting when paused for something external — a file to load, a network response, a user click. While waiting, it does not use the CPU at all. Finally, it is terminated when finished, and the OS releases all memory and resources it held.

Most processes spend a surprising amount of time in the waiting state, not the running state. This is why multitasking is possible — the CPU is rarely fully occupied with a single task.

Multitasking and Scheduling

Modern computers appear to run many programs at the same time. Your browser, music player, email client, and file manager all seem to work simultaneously. But most consumer computers have only a handful of CPU cores. A four-core CPU cannot literally run fifty programs in parallel. The answer is multitasking: the OS rapidly switches between processes, giving each one a tiny slice of CPU time called a time slice or quantum. Each slice is so short — often just a few milliseconds — that humans cannot perceive the switching. The result feels like simultaneous execution.

The part of the OS responsible for deciding which process runs next is called the scheduler. A simple scheduler might rotate through all ready processes in order — called round-robin scheduling. More sophisticated schedulers assign priority levels. High-priority processes (such as the audio system) get CPU time before low-priority ones (such as a background software update).

Viewing Processes

Every major OS provides tools to see running processes: Task Manager on Windows (Ctrl+Shift+Esc), Activity Monitor on macOS, and the top or htop command on Linux. These show every process, its PID, CPU use, memory use, and owner. When a program freezes or a computer slows down, examining running processes often reveals the cause.

Managing Memory

Memory — specifically RAM (Random Access Memory) — is one of the most important and most limited resources a computer has. Programs need memory to store instructions, variables, data structures, and state while they run. The operating system's job is to allocate memory fairly, protect programs from each other, and make the most of what is physically available.

Without memory management, any program could read or write any location in memory. A buggy program could corrupt another program's data. A malicious program could steal passwords or private data from another program's memory. Memory management prevents all of this.

Address Spaces and Memory Protection

Each process receives its own address space — a range of memory addresses that the process can use. From the process's perspective, it appears to have the entire computer's memory to itself. In reality, the OS maps these apparent addresses to actual physical locations in RAM and keeps each process's space completely isolated. This isolation is called memory protection. If a process tries to access memory outside its own address space, the OS immediately stops it — producing errors like "segmentation fault" on Linux or "access violation" on Windows. The crashing program is stopped, but the rest of the system remains safe.

Virtual Memory

What happens when programs together need more memory than physically exists? The OS uses virtual memory — it treats part of the storage drive as an extension of RAM. When RAM fills up, the OS moves data that has not been used recently from RAM to the drive. This is called swapping or paging. When that data is needed again, the OS swaps it back into RAM, moving something else out if necessary. Virtual memory allows programs to run even when they collectively need more memory than is physically installed. The tradeoff is speed: storage is vastly slower than RAM. When a computer swaps constantly — called thrashing — performance degrades sharply. Adding more RAM is one of the most effective upgrades for a system that swaps heavily.

LevelNameSpeedSizeManaged by
1CPU RegistersFastestBytesCPU hardware
2CacheVery fastKB to MBCPU hardware
3RAMFastGigabytesOperating system
4Virtual memory (swap)SlowGigabytesOperating system
5Storage (SSD/HDD)SlowestTerabytesOS + File system
Sections 16.4 – 16.6
Files, Permissions, and Hardware Communication
File Systems · Permissions and Accounts · Device Drivers

File Systems

Data that needs to survive beyond a single session must be stored permanently. The file system is the part of the operating system that organizes data on storage devices — hard drives, solid-state drives, USB drives — into a structure that both humans and programs can navigate.

A file is a named collection of data stored on a device. Files hold programs, documents, images, audio, video, configuration settings, logs, databases, and every other kind of persistent information. A folder (also called a directory) is a container that holds files and other folders. Folders organize files into groups, making it possible to find things in a large storage system.

The Directory Tree

Every major operating system organizes its file system as a tree. At the top is the root. On Windows, each drive has its own root (C:\, D:\). On Linux and macOS, the entire system has a single root written as /. A location in the tree is described by a path — a sequence of folder names leading to a file or folder. Paths starting from the root are absolute paths; paths starting from the current location are relative paths.

Diagram 16-B  ·  File System Tree (Linux)
/ (root)
├── home/
│   ├── alex/
│   │   ├── Documents/
│   │   │   ├── report.txt
│   │   │   └── project/
│   │   │       └── main.py
│   │   └── Downloads/
│   └── jamie/
│       └── Documents/
├── etc/          ← system configuration
├── usr/
│   └── bin/      ← installed programs
│       ├── python3
│       └── bash
└── tmp/          ← temporary files
    

Questions About This Diagram

  1. Write the absolute path to the file main.py.
  2. If Alex is working inside /home/alex/Documents/project/, what is the relative path to report.txt?
  3. If Jamie wants to read Alex's report.txt, what would have to be true about its permissions?
  4. Which directory would you expect to find system-wide installed programs?

File Metadata and File System Formats

Every file has metadata — information about the file rather than its content. Metadata includes the file's name, size, type (often indicated by extension like .txt, .jpg, .py), created date, modified date, owner, and permissions. File extensions are conventions, not technically enforced — renaming a file from photo.jpg to photo.txt does not change the actual data inside, only the label. Different operating systems use different file system formats to organize this data on storage devices.

FormatUsed ByNotable Characteristics
NTFSWindowsSupports large files, permissions, encryption
FAT32USB drives, older systemsWidely compatible; 4 GB file size limit
exFATUSB drives, flash storageNo 4 GB limit; broadly compatible
ext4LinuxStandard Linux file system
APFSmacOSOptimized for SSDs; strong encryption support

Permissions and User Accounts

Not everyone who uses a computer should have access to everything on it. A student should be able to use a school computer but not delete the operating system. An employee should be able to open their own files but not a colleague's private documents. Operating systems handle these restrictions through user accounts and permissions.

Every person who uses a computer has a user account — a collection of settings, files, and access rights associated with a specific username. Most operating systems distinguish between standard user accounts, which have limited permissions and cannot install system-wide software or change system files, and administrator accounts (called root on Linux and macOS), which have full access to the entire system.

Running as an administrator all the time is a security risk. If a malicious or buggy program runs under an administrator account, it can damage or take over the entire system. Best practice is to use a standard account for daily work and escalate privileges only when needed. On Linux, users escalate temporarily using the sudo command ("superuser do"), which prompts for the administrator password and runs just that one command with elevated permissions.

File Permissions

Every file and folder has a set of permissions that determine who can do what with it. Permissions are divided into three types — read (r), write (w), and execute (x) — and three groups: the owner, a group, and others. Linux and macOS display permissions as a compact string of characters.

Worked Example 16.1
Reading a Linux file permission string
  • ProblemA file shows the permission string -rw-r--r--. Explain exactly what each part means.
  • Break It Down - rw- r-- r-- │ │ │ │ │ │ │ └── Others: r-- = read only │ │ └────── Group: r-- = read only │ └────────── Owner: rw- = read and write └──────────── Type: - = regular file
  • ConcludeThe owner can read and write the file. Group members can only read it. All other users can only read it. No one except the owner can modify it.
  • ContextThis pattern (-rw-r--r--) is common for documents that should be readable by anyone on the system but editable only by their creator.
Owner: read + write. Group: read only. Others: read only. No execute permission for anyone.
Security Note

Permissions are one of the fundamental defenses against both accidents and attacks. If a malicious program runs under a limited user account, it cannot modify system files — the OS will refuse. When a web server's files are owned by the web server user and not writable by others, an attacker who compromises the server cannot easily install malicious code. Understanding permissions is not just a system administration skill — it is a security skill.

Device Drivers

A computer system connects to an enormous variety of hardware — dozens of keyboard models, hundreds of printers, thousands of USB devices, multiple generations of graphics cards, various network adapters, and countless specialized components. How can an operating system possibly talk to all of them?

The answer is the device driver. A device driver is a piece of software that allows the operating system to communicate with a specific hardware device. The driver translates between the generic instructions the OS sends and the specific commands that a particular device understands. Think of a driver as a translator: the operating system speaks a standard language ("send data to the printer"), and the driver translates that into the exact commands this particular printer requires.

Diagram 16-C  ·  How Device Drivers Fit the Layer Model
  ┌────────────────────────────────────┐
  │         Your Program               │
  └──────────────┬─────────────────────┘
                 │  (asks OS to do something)
  ┌──────────────▼─────────────────────┐
  │    Operating System                │
  │  (abstract interface for devices)  │
  └──────────────┬─────────────────────┘
                 │  (translates to device commands)
  ┌──────────────▼─────────────────────┐
  │        Device Driver               │
  │  (device-specific translation)     │
  └──────────────┬─────────────────────┘
                 │
  ┌──────────────▼─────────────────────┐
  │       Hardware Device              │
  │   (printer, GPU, network card...)  │
  └────────────────────────────────────┘
    

Questions About This Diagram

  1. Why are device drivers placed between the OS and hardware rather than between the OS and programs?
  2. If a new hardware device is invented, which layer needs to be updated to support it?
  3. If the OS provides a standard interface, can the same program work with many different printers? Why?

Device drivers are among the most common causes of system instability and security vulnerabilities. Because drivers run at a very privileged level inside the OS, a buggy or malicious driver can crash the entire system — producing the "blue screen of death" on Windows or a kernel panic on Linux and macOS. When a hardware device stops working after a software update, the cause is often driver incompatibility. When a peripheral stops responding, reinstalling or updating the driver is a common fix. Modern operating systems increasingly manage driver updates automatically, downloading and installing them without requiring user intervention.

Sections 16.7 – 16.10
Interfaces, Multitasking, Maintenance, and the OS as a Layer
GUI vs. CLI · Multitasking · Updates · Abstraction

Graphical Interfaces and Command Lines

Users interact with operating systems through interfaces — systems that translate human actions into instructions the OS can act on. Two major types exist: graphical user interfaces and command-line interfaces.

The Graphical User Interface

A graphical user interface, or GUI (pronounced "gooey"), presents the OS as a visual environment of windows, icons, menus, buttons, and pointers. GUIs made computing accessible to people without technical training. The introduction of commercial GUIs in the 1980s — popularized by the Apple Macintosh and later by Windows — transformed computing into a mass technology. Every GUI has characteristic elements: windows (resizable rectangular areas for each program), icons (visual symbols for files, folders, and programs), menus (hierarchical lists of commands), taskbars and docks (bars of icons showing running programs), dialog boxes (pop-ups that ask for input or confirmation), and file managers (tools like Windows Explorer or macOS Finder for browsing the file system visually).

GUIs are intuitive and easy to learn for basic tasks. But they have limits. Complex, repetitive tasks are often much faster to automate with typed commands. Remote administration of servers over slow network connections works better without a GUI. Scripting — writing sequences of commands to automate workflows — requires text. This is where the command-line interface excels.

The Command-Line Interface

A command-line interface, or CLI, accepts typed text commands and produces text output. The user types a command, presses Enter, and the OS executes it. The CLI goes by several names: terminal or terminal emulator (the window that hosts it), shell (the program that interprets commands — bash, zsh, PowerShell), and command prompt (the Windows name).

CLI Session — Linux Terminalalex@laptop:~$ ls Documents Downloads Music Pictures Videos alex@laptop:~$ cd Documents alex@laptop:~/Documents$ ls report.txt notes.md project/ alex@laptop:~/Documents$ cat report.txt This is the content of the report file.
CommandWhat It DoesExample
lsList files in current directoryls
cdChange directorycd Documents
pwdPrint current directory pathpwd
mkdirMake a new directorymkdir projects
rmRemove a filerm old_file.txt
cpCopy a filecp report.txt backup.txt
mvMove or rename a filemv draft.txt final.txt
catDisplay file contentscat notes.txt
manShow the manual for a commandman ls
Why the CLI Matters
  • Automation: CLI commands can be written into scripts — text files of commands that run entire workflows automatically.
  • Efficiency: A single command can rename, move, or process hundreds of files at once. The same task in a GUI might require hundreds of individual clicks.
  • Remote access: Servers in data centers are managed entirely through CLI connections. No GUI is involved.
  • Scripting: Programming tools, build systems, version control, package managers, and testing frameworks all use the CLI.
  • Precision: The CLI requires exact syntax, forcing precision and revealing exactly what the OS is doing.
For Students New to the CLI

The command line can feel intimidating compared to the GUI. This is normal. Learning to navigate the CLI is one of the most valuable practical skills in computer science. Start with ls, cd, and pwd. Use man to read help pages. Practice until file navigation feels natural — it will pay dividends in every programming course you take.

Multitasking

Multitasking is the ability to run multiple programs at the same time — or more precisely, to manage many processes so they appear to run simultaneously even when sharing limited CPU resources.

Cooperative multitasking (historical) required each program to voluntarily give up the CPU when done with its turn. If a program refused to yield, or if it froze, the entire system froze. Early versions of Mac OS and Windows used cooperative multitasking. It was fragile. Preemptive multitasking allows the OS to forcibly remove a program from the CPU when its time slice expires, regardless of whether the program is ready. This means one frozen program does not freeze the entire system. All modern operating systems use preemptive multitasking.

Threads

A thread is a smaller unit of execution within a process. A single process can have multiple threads, all sharing the same memory space but executing different parts of the program concurrently. A web browser, for example, might use separate threads for downloading a page, rendering it, running JavaScript, playing video, and responding to input. Each thread can progress independently. If the download thread stalls, the rendering thread can still update the screen. Threads are efficient but require careful design — if two threads modify the same data simultaneously without coordination, they can corrupt it. Managing threads correctly is one of the more complex areas of systems programming.

Foreground and Background Processes

Operating systems distinguish between foreground processes (which the user is actively interacting with) and background processes (which run silently without direct user interaction). Background processes — called daemons on Linux or services on Windows — handle essential tasks: checking email automatically, keeping the clock synchronized, managing printers, monitoring battery levels, updating software, and logging system events. They start when the system boots and run continuously until shutdown.

Updates and System Maintenance

An operating system is not a static product. It is maintained continuously, with updates released regularly to fix bugs, patch security vulnerabilities, add features, and improve performance.

Security is the most urgent reason to keep an OS updated. When researchers or attackers discover a vulnerability — a weakness in the OS code that could be exploited — the OS developer releases a patch (a targeted fix) to close it. Every day between a vulnerability's discovery and the installation of its patch is a window of risk. Attackers who learn of a vulnerability will attempt to exploit it quickly. Unpatched systems are one of the primary ways malware spreads and attackers gain access to networks.

Update TypeWhat It DoesPriority
Security patchFixes a specific vulnerability without changing other behaviorApply immediately
Cumulative updateBundles many smaller fixes togetherApply regularly
Feature updateAdds new capabilities; may redesign interfacesPlan and schedule
Driver updateRefreshes hardware device softwareApply when hardware issues arise

For personal computers, the inconvenience of an update — downloading data, restarting — is minor compared to the security risk of not updating. For servers that must never be interrupted — hospital monitoring systems, airline flight management, stock exchanges — applying updates requires careful planning during scheduled maintenance windows.

Beyond updates, operating systems require other regular maintenance: checking storage for errors, removing unnecessary files, reviewing logs of system events, managing backups, and keeping installed software current. On Linux servers, much of this is automated through cron jobs — scheduled commands that run automatically at set times — and through package managers that handle software installation, updates, and removal automatically.

Operating Systems as a Layer

Everything covered in this chapter points toward one central insight: the operating system is a layer.

Computer science is full of layers. Hardware is the lowest. On top of hardware sits the operating system. On top of the OS sit programs, tools, languages, databases, and frameworks. On top of those sit the applications users see. Each layer hides complexity from the layers above it and exposes a simplified interface. The operating system hides the differences between hardware devices. Programs do not need to know whether a file is stored on a magnetic hard drive or a solid-state drive or a USB stick. They ask the OS to open the file, and the OS handles the details.

This abstraction is enormously valuable. It means a Python program written on one computer behaves the same way on any other computer running the same OS, regardless of underlying hardware differences. It means developers can write software for "Windows" or "Linux" without writing different code for every motherboard, CPU model, and storage device ever made.

Diagram 16-D  ·  The Operating System Layer
  ┌──────────────────────────────────────────┐
  │           User Applications              │
  │  Browser · Word Processor · Game · ...   │
  ├──────────────────────────────────────────┤
  │    Programming Languages & Runtimes      │
  │         Python · Java · Node.js          │
  ├──────────────────────────────────────────┤
  │           Operating System               │
  │  Process │ Memory │ Files │ Security     │
  │  Devices │ Users  │ Net   │ CLI / GUI    │
  ├──────────────────────────────────────────┤
  │             Device Drivers               │
  ├──────────────────────────────────────────┤
  │               Hardware                   │
  │  CPU · RAM · Storage · Display · Network │
  └──────────────────────────────────────────┘
    

Questions About This Diagram

  1. Where in this diagram does a Python program run?
  2. When a Python program opens a file, which layers does the request pass through?
  3. Why are device drivers placed between the OS and hardware rather than between the OS and applications?
  4. If a new type of storage device is invented, which layer must be updated to support it?

The OS layer is also the primary enforcement point for security. Because all programs must go through the OS to access hardware, files, memory, and the network, the OS can intercept and evaluate every request. If a program tries to delete a system file, the OS can refuse. If a program tries to access memory it does not own, the OS can stop it. This is why malware often tries to gain kernel-level access — code that runs at the OS level can bypass many protections. It is also why OS vulnerabilities are so serious: a hole in the OS layer potentially exposes everything above it.

The habit of thinking in layers — asking "what does this layer expose?" and "what does this layer hide?" — is one of the most valuable intellectual tools in all of computing. Students will encounter this pattern in networking (the TCP/IP stack), in databases, in web development (frontend vs. backend vs. database), and in every other area of the field.

Worked Example 16.2
Tracing a file access through OS layers
  • ProblemA Python program runs the line file = open("/home/alex/Documents/report.txt", "r"). Trace the steps the OS takes.
  • Step 1Program asks the OS. The Python runtime makes a system call asking the OS to open the file with read permission.
  • Step 2OS checks the path. The OS follows the path through the directory tree, verifying each folder exists.
  • Step 3OS checks permissions. The OS looks at the current user and the file's permissions. If read permission is not granted, the OS returns an error and stops.
  • Step 4OS creates a file descriptor. If everything checks out, the OS creates an internal record — a file descriptor — representing this open file connection and returns it to the program.
  • Step 5Driver retrieves data. When the program reads, the OS uses the appropriate storage driver to retrieve bytes from the physical device and copy them into the program's memory.
Each step happens in fractions of a millisecond, invisibly to the user — but the OS is doing all of it on every file access.
Worked Example 16.3
Understanding virtual memory with a concrete scenario
  • ProblemA computer has 8 GB of RAM. Four programs need: A = 3 GB, B = 2 GB, C = 2 GB, D = 2 GB. Total = 9 GB — more than 8 GB available. How does the OS handle this?
  • Step 1Assign virtual address spaces. Each program receives a virtual space large enough for its needs. None knows about the shortage — each appears to have its own private memory.
  • Step 2Keep active data in RAM. Programs in the Waiting state do not need their data in RAM immediately. The OS keeps only currently used data in physical memory.
  • Step 3Swap idle data to storage. When RAM fills up, the OS moves least-recently-used pages to the swap space on the storage drive to free RAM for programs that need it.
  • Step 4Swap back on demand. If a program accesses swapped-out data, the OS pauses it, reads the data back from swap (possibly swapping something else out first), and resumes the program.
  • TradeoffAll four programs can technically run. But if all are actively competing for RAM simultaneously, the OS will swap frequently — and storage is orders of magnitude slower than RAM. The user notices sluggishness. The real fix: add more RAM or close a program.
Virtual memory makes it possible but not free. Heavy swapping degrades performance significantly. Adding physical RAM is the most effective solution.

Chapter Summary

Key Terms Review

operating system (OS)
The software that manages a computer's hardware and provides the foundation for all other software.
process
A running instance of a program, including its instructions, data, state, resources, and process ID.
process ID (PID)
A unique number assigned by the OS to identify each running process.
scheduler
The part of the OS that decides which process runs on the CPU and when.
time slice / quantum
The short period of CPU time allocated to a process before the scheduler switches to another.
preemptive multitasking
A multitasking model in which the OS can forcibly remove a process from the CPU when its time slice expires.
thread
A unit of execution within a process; a process can have multiple threads sharing the same memory space.
address space
The range of memory addresses assigned to a process, isolated from other processes by the OS.
memory protection
The OS mechanism that prevents a process from accessing memory that does not belong to it.
virtual memory
A technique that uses storage as an extension of RAM, allowing programs to use more memory than physically exists.
swapping / paging
Moving data between RAM and storage as part of virtual memory management.
thrashing
Excessive swapping that severely degrades performance because the OS spends more time moving data than doing useful work.
file system
The OS component that organizes data on storage devices into files and folders.
directory / folder
A container in the file system that holds files and other directories, organized in a tree structure.
path
A string that describes the location of a file or folder in the directory tree.
absolute path
A path that starts from the root of the file system (e.g., /home/alex/report.txt).
relative path
A path that starts from the current working directory.
metadata
Information about a file — name, size, type, dates, owner, permissions — rather than the file's content.
permissions
Rules that determine who can read, write, or execute a file or folder.
user account
A set of credentials, settings, and access rights associated with a specific user on the system.
administrator / root
A user account with unrestricted access to the entire system.
sudo
A Linux command that allows a user to run a single command with administrator privileges after password verification.
device driver
Software that allows the OS to communicate with a specific hardware device by translating generic OS commands into device-specific instructions.
GUI
Graphical user interface — an interface using windows, icons, menus, and visual controls.
CLI
Command-line interface — an interface that accepts typed text commands and returns text output.
shell
A program that interprets CLI commands (examples: bash, zsh, PowerShell).
daemon / service
A background process that runs continuously, performing system tasks without direct user interaction.
kernel
The innermost core of the OS — the part that runs with the highest privileges and manages hardware directly.
patch
A targeted software update that fixes a specific bug or closes a specific security vulnerability.
abstraction layer
A level in a system that hides complexity below it and exposes a simplified interface to the layer above.

Concept Check

Answer each question in one to three sentences before moving to the practice questions.

  1. What is the difference between a program and a process?
  2. Why does multitasking not require each program to have its own dedicated CPU core?
  3. What would happen if there were no memory protection between processes?
  4. What is the purpose of a device driver? Why does each hardware device need its own?
  5. What is the difference between a GUI and a CLI? When is each more appropriate?
  6. Why is it a security risk to run daily computing tasks as an administrator?
  7. What is virtual memory, and what problem does it solve?
  8. Why are OS security patches important to apply quickly after release?

Practice Questions

Section AVocabulary in Context
  1. A program is opened. The OS creates a ___?___ to track its execution, identified by a ___?___.
  2. A file path that begins with / on Linux is called a(n) ___?___ path. A path starting from the current location is called a(n) ___?___ path.
  3. The OS component that decides which process runs next on the CPU is called the ___?___.
  4. Software that translates OS commands into instructions for a specific hardware device is called a ___?___.
  5. A program running without a visible window, performing background tasks automatically, is called a ___?___ on Linux or a ___?___ on Windows.
  6. The technique of using storage space to extend available RAM is called ___?___. When used excessively and causing slowdowns, this is called ___?___.
Section BExplanation Questions
  1. A classmate says: "If I close all my programs, my computer should have no processes running." Is this accurate? Explain what is actually running on a typical system at any given time.
  2. Explain why two users on the same computer might see different files in their file managers even when browsing the same storage drive.
  3. A web server's files are accidentally set to the permission pattern -rwxrwxrwx. Describe the security risk this creates and explain what safer permissions might look like.
  4. Explain the difference between preemptive and cooperative multitasking. Why did operating systems transition from cooperative to preemptive?
Section CComparison Questions
  1. Compare a GUI and a CLI for each of the following tasks. Which is better suited to each, and why?

    a. Opening a photo to view it  ·  b. Renaming 500 files to add a date prefix  ·  c. Navigating an unfamiliar computer for the first time  ·  d. Managing a server over a slow network connection
  2. Compare RAM and virtual memory (swap) in terms of speed, purpose, and the consequences of heavy use.
  3. A program crashes. Compare the behavior of a cooperative multitasking OS versus a preemptive multitasking OS when this happens. Which handles it better, and why?
Section DScenario Questions
  1. You notice your computer is very slow. You open the task manager and see that one process is using 98% of the CPU. Give two possible reasons for this behavior and describe what actions you might take.
  2. A student wants to share a project file with another student on the same Linux computer. The file currently has permissions -rw-------. What change should the first student make to allow the second student to read but not modify the file, assuming they share the same user group?
  3. A programmer is building software for a hospital that must run 24/7 without planned restarts. How might the hospital's IT team manage the challenge of keeping the OS patched for security while maintaining continuous availability?
  4. An OS security patch is released that closes a critical vulnerability. A user says, "I'll install it next month — I'm too busy right now." Evaluate the risk of this decision. What factors should influence when to apply critical patches?

Debugging and Error Analysis

Each item contains an error in reasoning or a mistaken description. Identify the error and write the correct explanation.

Error 1
"When I run a Python program, the Python program talks directly to my CPU and hard drive. The operating system is only needed for the graphical interface."

What is wrong with this statement? What does the OS actually do when a Python program runs?

Error 2
"A file path home/alex/Documents/report.txt is an absolute path because it starts with the folder 'home'."

What is wrong? What makes a path absolute? How would you write this as a true absolute path on Linux?

Error 3
"Virtual memory solves the memory problem completely. The amount of RAM a computer has doesn't really matter — virtual memory can compensate for any shortage with no meaningful cost."

What is wrong with this reasoning? What does virtual memory actually trade off?

Error 4
"My computer has four CPU cores, so it can run exactly four programs at the same time. Opening a fifth program will completely pause one of the other four."

What does the OS actually do when more programs are running than there are CPU cores? What is the correct explanation?

Error 5
A student configures a file with permissions set to allow the web server to read it, allow the owner to read and write it, and block all other users. The student concludes: "This file is now fully secure — no unauthorized user can read it."

What is the potential gap in this reasoning? (Hint: think about what "other users" means if the web server runs as its own dedicated system account.)

Design and Application Questions

DesignApply What You Know
  1. Library Public Computer. A public library installs a computer for patron use. Design a basic permission structure: What account type should patrons use? What should they be able to do? What should be restricted? What type of account should library staff use for maintenance?
  2. Analogy Design. You are explaining the OS to a younger student who has never heard the term before. Write a one-paragraph analogy using a setting from everyday life — not computers — that accurately captures the OS's role as a manager of shared resources.
  3. CLI Command Planning. A developer wants to write a script that: (1) creates a folder named backup, (2) copies all .txt files from the current folder into it, and (3) prints "Done" when finished. List the CLI commands (by name and purpose) the script would use, in order.

Real-World Applications

  1. Smartphones. Android and iOS are both operating systems. Name two responsibilities covered in this chapter that your smartphone's OS must handle. Give a specific example of each from your phone's behavior.
  2. Gaming Consoles. Game consoles like PlayStation and Xbox run operating systems. How does the console OS likely manage the tradeoff between running the game (which needs most CPU and memory) and background tasks like downloading updates or handling chat?
  3. Cloud Servers. When you use a cloud service, your files are stored on servers running operating systems. Why is the OS especially important on a server that might host thousands of users simultaneously?
  4. Medical Devices. Some medical devices — insulin pumps, ventilators, heart monitors — run embedded operating systems. What OS characteristics are most critical for these devices? How does this differ from what matters most on a personal computer?
  5. Critical Infrastructure. Researchers have documented cases where attackers exploited unpatched OS vulnerabilities in power grids and water treatment systems. What does this suggest about the relationship between routine OS maintenance and public safety?

Mixed Review

These questions draw on material from earlier chapters.

  1. (Chapter 4) When the OS stores a file on a drive, the file's contents are stored as patterns of bits. If a text file contains the word "Linux" using ASCII encoding, how many bytes does it require?
  2. (Chapter 15) Describe how the CPU's fetch-decode-execute cycle relates to the OS process scheduler. How does the scheduler influence what instructions the CPU fetches next?
  3. (Chapter 9) The OS itself is a very large program built using functions and abstraction. Give one example from this chapter of a function or abstraction the OS provides to programs running on top of it.
  4. (Chapter 12) When the OS searches the directory tree to find a file at a given path, it traverses a tree data structure. If the tree has many levels, what algorithmic challenge does this present? How do file systems address it in practice?
  5. (Chapter 13) The OS itself is a model — an abstraction that hides hardware complexity. What are two things the OS simplifies or hides from application programs? What assumptions does this model make?

Chapter 16 Checkpoint

Chapter 16 Checkpoint
Complete without assistance — assesses all key skills and concepts from Chapter 16
Section 1 — Vocabulary and Concepts
  1. Define operating system and list four major responsibilities it handles.
  2. Explain the difference between a program and a process.
  3. What does the OS scheduler do? Why does multitasking require a scheduler?
  4. What is memory protection and why is it important?
Section 2 — File Systems and Permissions
  1. Write the absolute path to a file called data.csv stored in a folder called projects inside the home folder of a user named sam on a Linux system.
  2. A file has permission string -rwxr-x---. Who can execute this file? Who cannot?
  3. What is the difference between a standard user account and an administrator account? When should administrator-level access be used?
  4. What does sudo do, and why is it preferable to working as root all the time?
Section 3 — Interfaces and Multitasking
  1. Name two advantages the CLI has over the GUI for system administration tasks.
  2. What is the difference between cooperative and preemptive multitasking?
  3. What is a thread, and how does it differ from a process?
  4. What is a daemon? Give one example of a task a daemon might perform.
Section 4 — Systems Thinking
  1. A computer has 16 GB of RAM and is running programs that together need 20 GB. What technique does the OS use to handle this? What is the tradeoff?
  2. Explain what the OS layer abstracts and why this abstraction enables software portability.
  3. Why is the OS the primary security enforcement point for a computer system?
Section 5 — Error Analysis
  1. A student claims: "Running as an administrator all the time is fine — it just means you can do more things." What is the security problem with this reasoning?
  2. A student says: "If a computer has more virtual memory, it's just as fast as having more RAM." What is wrong with this claim?
Looking Ahead
Chapter 17: Software, Applications, and Development Tools

Chapter 16 explained the operating system as the software foundation that manages hardware, processes, memory, files, users, and devices. Every program depends on the OS for these services. Chapter 17 moves upward in the software stack to examine the ecosystem that developers use to build, manage, and maintain programs. Students will encounter applications, libraries, frameworks, APIs, code editors, integrated development environments, package managers, version control, open-source software, and software licenses. These are the tools every programmer uses, and understanding them is essential for moving from single scripts to real software projects. The theme connecting Chapters 15, 16, and 17 is the same in each: a layer that provides services to the layer above it and depends on the layer below. By Chapter 17, students will have a complete picture of what sits between the transistors in a CPU and the apps they see on their screens every day.

MGU Library Connection
  • Computer Systems Reference — Appendix G of this textbook
  • Command Line Guide — MGU Companion Resources
  • File Paths Guide — MGU Companion Resources
  • Chapter 15: Hardware and Computer Architecture — prerequisite for this chapter
  • Chapter 17: Software, Applications, and Development Tools — continues from this chapter
  • Chapter 21: Cybersecurity Foundations — builds on permissions and OS security concepts from this chapter
  • MGU Dictionary entries: operating system, process, kernel, file system, permissions, virtual memory, shell