Chapter 2.1: Software and Operating Systems
Introduction
Learning Outcomes
Tell system software from application software.
Explain how the OS sits between the user, applications and hardware.
Interpret process, memory, file and device management.
Compare kinds of operating systems against requirements.
Software
What Is Software?
Software is the set of programs, data and documentation that defines what a computer does.
Software
Software Quality Attributes
Does the expected tasks correctly.
Easy to learn and effective to use.
Uses time and resources efficiently.
Behaves predictably when things go wrong.
Resists unauthorized access and changes.
Fixes and improvements stay manageable.
Software
Software and Hardware
- The user only interacts with the top layers.
- Each layer hides the details below it and offers simpler services to the layer above (abstraction).
- Thanks to drivers, the same application runs on different hardware.
Requests travel down; results (services) travel back up.
Software
Kinds of Software
Manages the hardware and provides a platform for other software.
Does specific jobs for the user.
Support writing, translating, testing and debugging code.
Embedded software that runs a device's basic functions.
Software
System and Application Software
| Type | Examples | Main purpose |
|---|---|---|
| System | Operating system, driver, utility | Manage the computer and its resources |
| Application | Word processor, browser, game | Carry out the user's task |
| Middleware | Database access layer, message queue | Help applications talk to the system and to each other |
| Programming tools | Compiler, integrated development environment (IDE), debugger | Build new software |
Operating System
What Is an Operating System?
An operating system is the core system software that manages hardware resources and provides common services to applications.
- Hides hardware details from applications.
- Lets several programs share resources safely.
- Gives the user a graphical or command-line interface.
Operating System
What an Operating System Does
Operating System · Step by step
How Does a Computer Start? Booting Step by Step
The power button is pressed; once voltages settle, the power supply sends the motherboard a “power good” signal. RAM is empty; the OS is still sitting on disk.
The CPU starts running the firmware (UEFI, or the older BIOS) stored in non-volatile memory (ROM/flash) on the motherboard.
POST (power-on self-test): basic hardware such as memory, keyboard and disk is checked. Errors are reported with beeps or a message.
The boot order from the settings is tried (e.g. USB first, then SSD); missing devices are skipped. The boot loader (e.g. Windows Boot Manager: bootmgfw.efi, or GRUB) is loaded into RAM from the small EFI system partition (FAT32) on the disk.
The boot loader loads the kernel into RAM (on Windows, ntoskrnl.exe via winload.efi) and hands over control. The kernel loads drivers and starts the first processes and system services.
The sign-in screen appears; once the user is authenticated, their desktop and startup apps open.
Operating System · Security
Secure Boot and TPM
Modern firmware that replaces BIOS: large disks, fast startup and signature checking.
Only a boot loader and kernel with a trusted digital signature may run; forged or tampered boot code is blocked.
A security chip (on the motherboard, in the CPU or in firmware) that stores encryption keys and boot measurements; used by tools such as BitLocker.
Requires UEFI with Secure Boot and TPM 2.0 to install; see Microsoft's current requirements page for details.
OS Components
The Kernel
The kernel is the privileged core of the operating system. Applications don't touch the hardware directly; they ask the kernel for services through system calls.
OS Components · Step by step
A System Call Step by Step: Reading a File
A text editor wants to read report.txt. It cannot access the disk itself, so it makes the read system call.
The CPU switches from user mode to kernel mode. Now only kernel code runs.
The file system finds where the file lives on disk and checks that the user has read permission.
The disk driver sends a read command to the disk. When the disk is done, it notifies the CPU with an interrupt.
Memory management: the kernel copies the data into the editor's own memory area in RAM.
The call returns and the CPU switches back to user mode. The editor shows the data. The application never touched the hardware.
OS Components
Kinds of Kernels
| Type | Idea | Example |
|---|---|---|
| Monolithic kernel | Processes, memory, file system and drivers all in one privileged kernel; fast but large | Linux (loadable modules) |
| Microkernel | Only the essentials in the kernel; drivers and file system run in user mode; strong isolation | MINIX 3, QNX |
| Hybrid kernel | Starts from a microkernel design but keeps some services in the kernel for speed | Windows NT kernel, macOS/iOS (XNU) |
The Android stack
Resource Management
Process Management
Instructions and data stored on disk.
A running instance of a program.
A flow of execution inside a process.
Decides which process gets the CPU and when.
Moves the CPU state from one process to another.
Lets several jobs make progress together.
Resource Management
Program, Process and Thread
A program is a file sitting on disk; a process is a running instance of it, identified by a process ID (PID). Each process has its own memory space, while threads share the memory of their process.
Resource Management
Process States
- On a single core, only one process is Running at a time; the other ready processes wait their turn.
- A Waiting process never gets the CPU; when the event it waits for (disk, keyboard, network) happens, it becomes Ready again.
Resource Management · Step by step
Process State Transitions Step by Step
Process P1 is being created (e.g. the user double-clicked a program): state New.
New → Ready: the OS admits the process; memory is allocated and it joins the ready queue.
Ready → Running: the scheduler picks P1; its context is loaded and the CPU executes P1's instructions.
Running → Waiting: P1 asks for data from the disk. Rather than hold the CPU idle until it arrives, it moves to Waiting.
Waiting → Ready: the disk is done (an interrupt arrives). P1 doesn't run right away; it goes back to the Ready queue first.
Ready → Running: when its turn comes, P1 is picked again and continues where it left off.
Running → Ready: P1's time slice is up; a timer interrupt gives the CPU to another process.
Ready → Running: P1 is picked again and runs the rest of its work.
Running → Terminated: P1 finishes and exits; the OS reclaims its memory and resources.
Resource Management · Step by step
Two Processes, One CPU: Tracing States
Two processes, one core. P1 will compute for 3 ms, read from disk (3 ms), then compute 2 ms more. P2 just computes for 4 ms. Both are Ready; the scheduler picks P1.
t = 0–3: P1 is Running; P2 waits in the ready queue.
t = 3: P1 asks to read from disk (a system call). The disk is slow, so P1 goes to Waiting and gives up the CPU. Context switch.
t = 3–6: P2 is Running while the disk reads P1's data. CPU and disk work in parallel.
t = 6: the disk finishes and signals with an interrupt. P1 becomes Ready but doesn't run yet: P2 has the CPU.
t = 7: P2 completes its 4 ms and is Terminated. Only P1 is left in the ready queue.
t = 7–9: P1 is Running; it finishes its last 2 ms and is Terminated.
Total: 9 ms, and the CPU was never idle. Had the CPU sat idle while P1 waited for the disk, it would have taken 3 + 3 + 2 + 4 = 12 ms. Running another process during I/O (multiprogramming) saves time.
P1: compute 3 ms P1: read disk (I/O 3 ms) P1: compute 2 ms, exit P2: compute 4 ms, exit
Resource Management · Step by step
Time Sharing: Round-Robin CPU Allocation
Three processes are ready: P1 needs 5 ms, P2 3 ms, P3 2 ms. Round-robin scheduling gives each one at most 2 ms in turn.
t = 0–2: the CPU runs P1. Its time slice expires; P1 goes to the back of the queue (3 ms left). Context switch.
t = 2–4: the CPU runs P2. Its time slice expires; P2 goes to the back of the queue (1 ms left). Context switch.
t = 4–6: the CPU runs P3. P3 finishes (t = 6) and leaves the system.
t = 6–8: the CPU runs P1. Its time slice expires; P1 goes to the back of the queue (1 ms left). Context switch.
t = 8–9: the CPU runs P2. P2 finishes (t = 9) and leaves the system.
t = 9–10: the CPU runs P1. P1 finishes (t = 10) and leaves the system. Completion: P3 = 6, P2 = 9, P1 = 10 ms. Because switches are fast, all three seem to run “at the same time”.
Resource Management · Step by step
Deadlock
Process A has acquired the printer and is using it (solid arrow).
Process B has locked the file and is using it.
Process A wants the file without releasing the printer (dashed arrow); B has the file, so A waits.
Process B wants the printer without releasing the file; A has the printer, so B waits.
A → File → B → Printer → A: a circular wait. Neither lets go, so both wait forever: deadlock.
Resource Management
Memory Management
Gives each program the memory it needs.
Stops one process from changing another's memory.
Gives programs an address space independent of physical RAM.
Manages memory in fixed-size pieces.
Moves some data to disk temporarily when needed.
Lets processes share code or data.
Resource Management · Step by step
Memory Management Step by Step: Allocation, Protection, Swapping
Start: the operating system (kernel) sits at the start of RAM; the rest is free.
Allocation: 200 KB from 100 to 300 is set aside for A. In this simple model a region is described by base and limit registers (real systems use paging).
B gets 150 KB from 300 to 450. Each process has its own register pair; the OS loads it on every switch.
Valid access: A's address 150 is below the limit (200), so the hardware goes to physical address base + 150 = 250.
Protection fault: A asks for 250; since 250 ≥ 200, the hardware blocks the access and control passes to the kernel. A real system would kill A with an “access violation / segmentation fault”; in the example A's region stays put. B's memory is safe.
Swapping: there is no room for C (190 KB < 250 KB). The waiting process B is written to disk, leaving 340 KB of contiguous free RAM. Disk is far slower than RAM.
C is loaded at 300–550. B waits on disk and is brought back into RAM when it runs again; if there is no room, some other process is swapped out.
Resource Management
Virtual Memory and Paging
- Each process sees its own virtual address space starting at 0; memory is split into 4 KB pages, and a page table records which frame holds each page.
- Pages need not be contiguous in RAM; rarely used pages can be moved out to disk (swapped).
- The swap area is called the page file on Windows and swap on Linux and macOS. Reading from disk (SSD ≈ 0.1 ms) is orders of magnitude slower than RAM (50–100 ns); heavy swapping makes a computer noticeably slow.
Resource Management · Step by step
Address Translation Step by Step: 4100 and 8200
Process A wants to read the data at virtual address 4100. The CPU's memory management unit (MMU) has to translate it.
The address splits in two: page = 4100 / 4096 = 1, offset = 4100 mod 4096 = 4.
Table: page 1 → frame 5. Physical address = 5 × 4096 + 4 = 20484.
Process A wants to read the data at virtual address 8200. The CPU's memory management unit (MMU) has to translate it.
The address splits in two: page = 8200 / 4096 = 2, offset = 8200 mod 4096 = 8.
The table says page 2 is not in RAM → page fault. The program is paused and the OS steps in.
The OS loads the page from disk into free frame 3 and updates the page table.
Table: page 2 → frame 3. Physical address = 3 × 4096 + 8 = 12296. The instruction is restarted and succeeds this time.
Resource Management · Step by step
Page Replacement (LRU) Step by Step
The process has only 3 frames in RAM and requests pages in the order 7, 0, 1, 2, 0, 3, 0, 4. When RAM is full, which page goes to disk? The LRU (least recently used) rule.
Page 7 is not in RAM → page fault; there is a free frame, so it is loaded there from disk.
Page 0 is not in RAM → page fault; there is a free frame, so it is loaded there from disk.
Page 1 is not in RAM → page fault; there is a free frame, so it is loaded there from disk.
Page 2 is missing → page fault; no free frame. Page 7 was used longest ago → evict it, load 2.
Page 0 is already in RAM → hit; only its last-use time is updated.
Page 3 is missing → page fault; no free frame. Page 1 was used longest ago → evict it, load 3.
Page 0 is already in RAM → hit; only its last-use time is updated.
Page 4 is missing → page fault; no free frame. Page 2 was used longest ago → evict it, load 4.
6 page faults in 8 requests. FIFO (first in, first out) gives 7 faults on the same string: it evicts the busy page 0 too when its turn comes. Every fault means a slow disk read.
page in RAM? Yes → hit No → page fault free frame? Yes → load No → evict least recent, load
Resource Management
Devices and Drivers
Hardware devices differ in their commands and features. A device driver translates the OS's generic requests into device-specific operations.
Detects a compatible device and sets up the right driver.
A device signals an event to the CPU.
Holds data temporarily between parts running at different speeds.
Resource Management
File System
A file system defines how data on a storage device is named, organized and found.
A unit of data with a name and contents.
Groups files and subfolders.
Gives a file's location in the folder tree.
Properties such as size, date, owner and permissions.
Read, write and execute rights.
Helps keep things consistent after a crash or power loss.
Resource Management
Kinds of File Systems
| File system | Platform | Journaling | When to use it |
|---|---|---|---|
| NTFS | Windows (macOS read-only) | Yes | Windows system drive; when you need large files, permissions or encryption |
| FAT32 | Almost every device and OS | No | Older devices, cameras, simple memory cards; 4 GB maximum file size |
| exFAT | Windows, macOS and recent Linux | No | USB drives and SD cards with large files; moving data across platforms |
| ext4 | Linux | Yes | Linux system and data disks |
| APFS | macOS, iOS, iPadOS | No classic journal; copy-on-write keeps it consistent | Default file system on Apple devices |
Resource Management
The File System Tree and Paths
- A file system is a tree: the root at the top, folders as branches, files as leaves.
- An absolute path starts at the root; a relative path starts at the current folder (from ali:
documents/report.txt). - Windows writes the same idea with a drive letter:
C:\Users\Ali\Documents\report.txt.
Resource Management · Step by step
Opening and Reading a File Step by Step
The editor makes the open system call. The kernel resolves the path one piece at a time, starting at the root folder /.
It looks for home in the root, then for ali inside it. Each folder is a list of the names it contains and where they live on disk.
report.txt is found in ali. The metadata says: size 150 bytes; does the user have read permission? Yes. (Otherwise open returns an error and the file stays closed.)
The kernel creates an open-file entry and gives the process the lowest free number: fd = 3. Numbers 0, 1 and 2 are always open in every process for standard input, output and error.
read asks for 100 bytes; bytes 0–99 are read, n = 100. The offset moves to 100 on its own; the application never sees addresses, only the fd.
Again 100 bytes are requested, but only 50 are left: n = 50, offset 150.
The third read returns n = 0: end of file. The program stops reading here.
close: the entry is removed and number 3 is free again. The OS closes any files left open when the process ends, but a long-running program can run out of descriptors. Windows calls the same idea a handle.
fd = open("/home/ali/report.txt", O_RDONLY)
n = read(fd, buf, 100)
n = read(fd, buf, 100)
n = read(fd, buf, 100)
close(fd)OS Components
User Interfaces
Windows, icons, menus and a mouse.
Text commands: fast, repeatable, easy to automate.
Taps, swipes and gestures.
Screen reader, magnifier, high contrast.
OS Components
Command-Line Basics
| Task | Linux / macOS | Windows (cmd) |
|---|---|---|
| Show current folder | pwd | cd (no arguments) |
| List folder contents | ls | dir |
| Change folder | cd folder | cd folder |
| Create folder | mkdir new | mkdir new |
| Copy file | cp a.txt b.txt | copy a.txt b.txt |
| Delete file | rm a.txt | del a.txt |
For each of three groups, add r=4 (read), w=2 (write), x=1 (execute): owner · group · others.
chmod 644 file
6 = rw- (owner) · 4 = r-- (group) · 4 = r-- (others)
rm and del don't send files to the Recycle Bin; check the path and name before you run them.Security
Users and Permissions
- A standard account limits system changes in everyday use; an administrator account can make system-wide changes.
- Least privilege: give users only the rights their job needs.
- Logging lets important events be reviewed later.
- In the example, a standard user can open their own file but cannot change a system setting.
Kinds of Operating Systems
Personal Computer Systems
Huge hardware and software ecosystem.
Desktop system integrated with Apple hardware.
Systems tailored to different desktops and uses.
Built around web and cloud use.
Kinds of Operating Systems
Mobile Operating Systems
A broad mobile ecosystem running on many makers' devices.
Integrated system for Apple mobile devices.
Touch interface, power management, sensors and wireless connectivity.
Limits what apps can reach with permissions and sandboxes.
Kinds of Operating Systems
Server Operating Systems
Serves many users and services at once.
Provides web, database, file and identity services.
Built to run for long periods without interruption and be managed remotely.
Permissions, logging, updates and network control come first.
Linux distributions, Windows Server and Unix variants.
Repeatable administration with the command line and configuration tools.
Kinds of Operating Systems
Embedded and Real-Time Systems
Runs a specific device task with limited CPU, memory and power.
Examples: router, car control unit, medical device.
Must deliver the right result within a set deadline.
Examples: industrial control and safety systems.
Kinds of Operating Systems
Choosing an Operating System
| Requirement | What to evaluate |
|---|---|
| Application | Whether the required software and versions are available |
| Hardware | Driver and architecture support |
| Security | Update lifetime, permission model and management tools |
| Usability | Interface, accessibility and learning curve |
| Cost | Licensing, support, training and maintenance combined |
Licensing
Open-Source Software
Can be studied under the license terms.
Can be adapted to your needs if the license allows.
Sharing original or modified versions depends on the license.
Development and support can come from individuals, institutions and companies.
Licensing
Commercial and Closed-Source Software
You don't buy the software itself; usually you get a license to use it under certain terms.
Usually kept closed by the developer.
Official support and service-level agreements may be offered.
There may be license, subscription, maintenance and upgrade fees.
Licensing
Comparing License Models
| Criterion | Open source | Proprietary (closed source) |
|---|---|---|
| Source access | Open under the license | Usually closed |
| Customization | Possible within the license | Limited to the vendor's options |
| Support | Community or paid provider | Vendor or authorized partner |
| Cost | License may be free; running costs remain | License or subscription may be required |
| Example license | GPL, MIT, Apache | End-user license agreement (EULA) |
| Example product | Linux, Firefox, LibreOffice | Windows, Microsoft Office, Adobe Photoshop |
Maintenance
Updates and Support
Closes known vulnerabilities.
Brings new functions and interface changes.
Can improve hardware compatibility or stability.
The period during which the vendor ships updates.
Makes major changes reversible.
In organizations, updates are tested before wide rollout.
Operating System
Virtualization and Containers
Runs isolated operating system instances on one physical computer.
Gives virtual machines CPU, memory and device resources.
Isolates applications and their dependencies at the process level; shares the kernel.
Testing, server consolidation, cloud and portable app deployment.
Operating System
Virtual Machines vs Containers
Carries a full guest OS: strong isolation, but more memory and slower startup.
Just the app and its dependencies on a shared kernel: light and fast, weaker isolation.
Summary
Chapter Summary
- Software defines the work the hardware carries out.
- The operating system is a management and abstraction layer between applications and hardware.
- The kernel manages process, memory, device and file resources.
- Personal, mobile, server, embedded and real-time systems have different priorities.
- Choosing an OS means weighing applications, hardware, security, support and total cost together.
- The license sets the rights for open and closed source.
Summary
Review Questions
- What is the difference between system software and application software?
- Why does the kernel run in privileged mode?
- How do a program and a process differ?
- What problem does virtual memory solve?
- How do the priorities of server and mobile operating systems differ?
- Why isn't open-source software always free of charge?
Summary
Exercises
- Round-robin scheduling, time slice 2 ms: P1 = 4, P2 = 2, P3 = 3 ms. Draw the Gantt chart and find each process's completion time.
- Page size is 4096 bytes. Which page and offset does virtual address 12300 fall in? If page 3 is in frame 1, what is the physical address?
- What state is a process in while it waits for keyboard input? Which state does it move to when a key is pressed, and then which? Show the transitions on the diagram.
- Why won't a modified boot loader run when Secure Boot is on? Explain using the signature checks in the chain of trust.
- For a test setup that needs both Windows and Linux, would you choose virtual machines or containers? Explain in terms of kernel sharing.
- Walk through an application writing to a file, step by step: system call, kernel mode, file system, disk driver.
Summary
References
- Silberschatz, Galvin and Gagne, Operating System Concepts.
- Tanenbaum and Bos, Modern Operating Systems.
- License resources from The Linux Foundation and the Free Software Foundation.