CS2006 – Operating Systems
Chapter 1: Introduction
Comprehensive Study Notes
Instructor: Dr. Usman Ali Shah
FAST-NUCES, Peshawar • Spring 2026
Topics Covered in This Chapter
✔ What is an Operating System?
✔ Computer System Structure & Organization
✔ Interrupts & I/O Operations
✔ Storage Structure & Hierarchy
✔ OS Operations & Dual-Mode
✔ Process & Memory Management
✔ File System & Mass Storage
✔ Caching, Protection & Security
✔ Computer Architecture (Multi-processor, Clustered)
✔ Kernel Data Structures
CS2006 Operating Systems • Chapter 1 Notes • FAST-NUCES Peshawar Page 1
Section 1: What is an Operating System?
■ Operating System (OS)
A program that acts as an intermediary between a user of a computer and the computer
hardware. It controls and coordinates the use of hardware among various applications and users.
■ Kernel
The one program running at all times on the computer. It is the core of the OS. The kernel starts
executing the moment the computer boots and runs until shutdown.
■ System Program
A program that ships with the operating system but is not part of the kernel. Examples include
compilers, file utilities, and shell programs.
■ Middleware
A set of software frameworks that provide additional services to application developers.
Examples include databases, multimedia, and graphics frameworks (e.g., ODBC, DirectX in
Windows).
Goals of an OS
• Execute user programs and make solving user problems easier.
• Make the computer system convenient to use.
• Use the computer hardware in an efficient manner.
Computer System Structure — 4 Components
• Hardware – Provides basic computing resources: CPU, memory, I/O devices.
• Operating System – Controls and coordinates use of hardware among applications and users.
• Application Programs – Define ways system resources are used (word processors, browsers,
games).
• Users – People, machines, or other computers.
■ Key Point: The OS acts as both a resource allocator (deciding who gets what resource)
and a control program (managing execution of programs to prevent errors).
Different Viewpoints of an OS
User View
CS2006 Operating Systems • Chapter 1 Notes • FAST-NUCES Peshawar Page 2
• Focused on ease-of-use, performance, and security.
• Does not care about resource utilization.
• Workstation users have dedicated resources.
• Mobile users (smartphones/tablets) expect optimized usability and battery life.
System View
• OS is a resource allocator — manages CPU, memory, I/O.
• OS is a control program — manages execution of user programs.
• Embedded computers (e.g., in cars, appliances) run with little or no user interface.
■ Note: Mobile devices have touch screens and voice recognition interfaces. Embedded systems
run primarily without user intervention.
Section 2: Computer System Organization &
Interrupts
■ Device Controller
A hardware component that is in charge of a particular device type (e.g., disk controller, USB
controller). Each has a local buffer and communicates with the CPU via the system bus.
■ Device Driver
An OS software component that manages a specific hardware device controller. It provides a
uniform interface between the controller and the kernel.
■ Interrupt
A signal sent to the CPU by hardware or software indicating that an event needs immediate
attention. It causes the CPU to pause its current task and execute an Interrupt Service Routine
(ISR).
■ Interrupt Vector
A table that contains the addresses of all Interrupt Service Routines (ISRs). When an interrupt
occurs, the OS uses this table to find and execute the correct ISR.
■ Trap / Exception
A software-generated interrupt caused either by an error (e.g., division by zero) or by a user
request (e.g., system call). The OS is said to be 'interrupt-driven'.
CS2006 Operating Systems • Chapter 1 Notes • FAST-NUCES Peshawar Page 3
How Computer-System Operation Works
• One or more CPUs and device controllers are connected through a common bus to shared
memory.
• CPUs and devices execute concurrently, competing for memory cycles.
• Each device controller has its own local buffer storage.
• The CPU moves data between main memory and local buffers of device controllers.
• I/O operations move data from a device to the controller's local buffer.
• When finished, the device controller informs the CPU via an interrupt.
Interrupt Handling Steps
• OS preserves the state of the CPU — stores registers and the Program Counter (PC).
• OS determines which type of interrupt has occurred.
• OS transfers control to the correct Interrupt Service Routine (ISR) using the interrupt vector.
• ISR executes and handles the event.
• OS restores the saved CPU state and resumes the interrupted program.
■ Key Point: The Program Counter (PC) is a CPU register that holds the address of the next
instruction to execute. It must be saved on interrupt so execution can resume correctly.
I/O Structure — Two Methods
Synchronous I/O Asynchronous I/O
Control returns to user program only after I/O is Control returns to user program immediately
complete. without waiting for I/O.
CPU is idle (wait loop) until the operation CPU continues executing other tasks; interrupt
finishes. signals when I/O is done.
At most ONE I/O request outstanding at a time. Multiple I/O requests can be outstanding
simultaneously.
■ Note: Device-status table: Maintained by OS for each I/O device. Contains the device type, ID,
current state, and the ID of the process using it.
CS2006 Operating Systems • Chapter 1 Notes • FAST-NUCES Peshawar Page 4
Section 3: Computer Startup & Storage Structure
Bootstrap Program & Computer Startup
■ Bootstrap Program
A simple program loaded at power-up or reboot. Typically stored in EEPROM (firmware). It
initializes CPU registers, device controllers, and memory, then loads the OS kernel.
■ Firmware
Software permanently stored in hardware (e.g., EEPROM). The bootstrap program lives here. It
is the very first code that runs when a computer is turned on.
■ Daemon
A process that runs continuously in the background without direct user interaction. Started by the
'init' process (now called 'systemd' in modern Linux) after the kernel loads.
Boot Sequence Steps
• Power-on → Bootstrap program loaded from firmware.
• Bootstrap initializes CPU registers, device controllers, and memory.
• Bootstrap loads the OS kernel from disk into memory.
• Kernel starts executing; launches first process ('init' / 'systemd', PID=1).
• Init/systemd starts system daemons (background services).
• System waits for events (interrupts from hardware or software).
■ Key Point: Hardware triggers interrupts via the system bus. Software triggers interrupts
(traps) via system calls or monitor calls.
Storage Structure
■ Main Memory (RAM)
The only large storage medium that the CPU can directly access. It is volatile (data lost on
power-off), randomly accessible, and typically implemented as DRAM (Dynamic RAM).
■ Secondary Storage
Extension of main memory. Provides large, non-volatile storage. Includes Hard Disk Drives
(HDD) and Non-Volatile Memory (NVM) devices like SSDs.
CS2006 Operating Systems • Chapter 1 Notes • FAST-NUCES Peshawar Page 5
■ Hard Disk Drive (HDD)
Uses rigid metal or glass platters covered with magnetic recording material. Disk surface is
logically divided into tracks, which are subdivided into sectors.
Storage Units (Size Reference)
Unit Abbreviation Size
Kilobyte KB 1,024 bytes (2¹■)
Megabyte MB 1,024² bytes
Gigabyte GB 1,024³ bytes
Terabyte TB 1,024■ bytes
Petabyte PB 1,024■ bytes
■ Note: The basic unit is the bit (0 or 1). A byte = 8 bits. A word = native data unit of the CPU
architecture (e.g., 64-bit word = 8 bytes on modern CPUs). Networking speeds are measured in
bits, not bytes.
Storage Hierarchy
Storage systems are organized in a hierarchy based on three factors:
• Speed – Faster storage at the top (registers), slower at the bottom (HDD).
• Cost – Faster storage is more expensive per byte.
• Volatility – Upper levels (registers, cache, RAM) are volatile; lower levels (HDD, SSD) are
non-volatile.
■ Cache
A smaller, faster storage area that stores copies of frequently used data from slower storage.
When the CPU needs data, it checks the cache first. If found (cache hit), it is used directly. If not
(cache miss), data is fetched from slower storage and copied into the cache.
■ Key Point: Cache size and replacement policy are critical OS design decisions. In
multiprocessor systems, cache coherency must be maintained so all CPUs see the most
recent value.
Direct Memory Access (DMA)
CS2006 Operating Systems • Chapter 1 Notes • FAST-NUCES Peshawar Page 6
■ DMA (Direct Memory Access)
A mechanism that allows high-speed I/O devices to transfer blocks of data directly to/from main
memory without CPU intervention. Only ONE interrupt is generated per block (instead of one per
byte), greatly reducing CPU overhead.
• Used for high-speed I/O devices that can transfer data at near-memory speeds.
• Device controller transfers entire blocks directly to main memory.
• CPU is free to do other work during the transfer.
• One interrupt per block (much more efficient than one interrupt per byte).
CS2006 Operating Systems • Chapter 1 Notes • FAST-NUCES Peshawar Page 7
Section 4: OS Operations — Multiprogramming
& Dual-Mode
Multiprogramming (Batch System)
■ Multiprogramming
A technique where the OS keeps multiple programs (jobs) in memory simultaneously. When one
job has to wait (e.g., for I/O), the OS switches the CPU to another job, keeping the CPU busy at
all times.
• A single user cannot always keep the CPU and I/O devices busy.
• A subset of total jobs is kept in memory at all times.
• One job is selected and run via job scheduling.
• When a job has to wait (e.g., for I/O), the OS switches to another job.
■ Key Point: Multiprogramming improves CPU utilization by ensuring the CPU is never idle
waiting for I/O.
Multitasking (Time-Sharing)
■ Multitasking / Time-Sharing
A logical extension of multiprogramming where the CPU switches between jobs so rapidly that
each user perceives their program as running continuously. Enables interactive computing.
• CPU switches jobs so frequently that users can interact with each running program.
• Response time should be less than 1 second.
• Each user has at least one process executing in memory.
• If multiple jobs are ready, CPU scheduling decides which runs next.
• If processes don't fit in memory, swapping moves them in and out.
• Virtual memory allows execution of processes not completely in memory.
■ Note: Difference: Multiprogramming = maximize CPU utilization (batch). Time-sharing =
minimize response time (interactive).
Dual-Mode Operation
■ Dual-Mode Operation
A hardware-supported mechanism where the CPU operates in one of two modes: User Mode or
Kernel Mode. This protects the OS from accidental or malicious damage by user programs.
CS2006 Operating Systems • Chapter 1 Notes • FAST-NUCES Peshawar Page 8
■ User Mode
Mode in which user applications run. Restricted access to hardware. Mode bit = 1 (user). Cannot
execute privileged instructions.
■ Kernel Mode (Supervisor Mode)
Mode in which the OS kernel runs. Full access to all hardware and instructions. Mode bit = 0
(kernel). Can execute privileged instructions.
■ Privileged Instructions
Instructions that can only be executed in Kernel Mode. Examples: modifying the mode bit,
performing I/O operations directly, managing memory allocation. If a user program tries to
execute one, a trap is triggered.
Mode Transition Flow
• User program runs in User Mode (mode bit = 1).
• User program makes a System Call to request OS service.
• Hardware switches mode bit to Kernel (0); OS handles the request.
• OS finishes; mode bit switched back to User (1); control returns to user program.
■ Key Point: System calls are the only legal way for user programs to request kernel
services. This enforces the boundary between user and kernel mode.
Timer — Preventing Infinite Loops
■ Timer
A hardware device used by the OS to prevent a user process from monopolizing the CPU. The
OS sets a counter that is decremented by the system clock. When it reaches zero, an interrupt is
generated and the OS regains control.
• OS sets the timer counter before scheduling a process (privileged instruction).
• Physical clock decrements the counter.
• When counter reaches zero, interrupt fires → OS regains control.
• Used to terminate or reschedule programs that exceed their allotted time.
CS2006 Operating Systems • Chapter 1 Notes • FAST-NUCES Peshawar Page 9
Section 5: Resource Management
Process Management
■ Process
A program in execution. It is an active entity (unlike a program, which is passive). A process
requires resources: CPU, memory, I/O, files, and initialization data.
■ Program Counter (PC)
A CPU register that holds the address of the next instruction to be executed. A single-threaded
process has one PC; a multi-threaded process has one PC per thread.
OS Responsibilities for Process Management
• Creating and deleting both user and system processes.
• Suspending and resuming processes.
• Providing mechanisms for process synchronization.
• Providing mechanisms for process communication (IPC).
• Providing mechanisms for deadlock handling.
■ Key Point: Program = passive (a file on disk). Process = active (program loaded in
memory and executing). Multiple processes can be instances of the same program.
Memory Management
■ Memory Management
The OS function that determines what data is in memory and when, optimizing CPU utilization
and response time. The OS must track all parts of memory, decide what to load/unload, and
allocate/deallocate space.
Memory Management Activities
• Keeping track of which parts of memory are currently being used and by whom.
• Deciding which processes (or parts) and data to move into and out of memory.
• Allocating and deallocating memory space as needed.
File-System Management
CS2006 Operating Systems • Chapter 1 Notes • FAST-NUCES Peshawar Page 10
■ File
The OS abstraction of physical storage into a uniform, logical storage unit. It hides the details of
the physical medium (disk, tape, etc.) from the user.
OS Activities for File Systems
• Creating and deleting files and directories.
• Providing primitives (operations) to manipulate files and directories.
• Mapping files onto secondary storage.
• Backing up files to stable (non-volatile) storage media.
• Controlling access (permissions) to determine who can access what.
Mass-Storage Management
Disks store data that does not fit in main memory or must be preserved long-term. The OS manages:
• Mounting and unmounting storage devices.
• Free-space management (tracking available disk space).
• Storage allocation (deciding where files are stored).
• Disk scheduling (optimizing the order of disk read/write operations).
• Partitioning and Protection.
■ Key Point: Disk subsystem performance directly affects the entire speed of computer
operation.
I/O Subsystem
■ I/O Subsystem
The OS component responsible for managing I/O devices and hiding their complexity from users.
■ Buffering
Storing data temporarily in memory while it is being transferred between devices or between a
device and application, to smooth out speed differences.
■ Spooling
Overlapping the output of one job with the input of another. Used by printers and similar devices
that cannot accept interleaved data streams.
Protection and Security
CS2006 Operating Systems • Chapter 1 Notes • FAST-NUCES Peshawar Page 11
■ Protection
Any mechanism for controlling access of processes or users to resources defined by the OS.
Focus is internal — preventing unauthorized access within the system.
■ Security
Defense of the system against internal and external attacks, including denial-of-service, worms,
viruses, identity theft, and theft of service. Focus is external.
User Identification
• User ID: A unique identifier (name + number) for each user. Associated with all that user's files
and processes.
• Group ID: Allows sets of users to be defined; access controls can be applied to groups.
• Privilege Escalation: Allows a user to temporarily assume an effective ID with more rights (e.g.,
sudo in Linux).
CS2006 Operating Systems • Chapter 1 Notes • FAST-NUCES Peshawar Page 12
Section 6: Computer-System Architecture
Single-Processor vs. Multi-Processor Systems
■ Multiprocessor System
A system with two or more CPUs sharing the computer bus, clock, memory, and peripherals.
Also called parallel systems or tightly-coupled systems.
Advantages of Multiprocessors
• Increased Throughput – More work done in the same time.
• Economy of Scale – Cheaper than multiple separate systems.
• Increased Reliability – If one CPU fails, others continue (graceful degradation / fault tolerance).
Asymmetric Multiprocessing (AMP) Symmetric Multiprocessing (SMP)
Each processor is assigned a specific task. Each processor performs all tasks. All
One master CPU controls the system. processors are peers. Most common modern
approach.
Multi-Core Design
■ Multi-Core Processor
A single chip containing multiple processor cores. More efficient than multiple separate chips
because on-chip communication is faster and power consumption is lower.
Clustered Systems
■ Clustered System
Multiple complete systems working together, usually sharing storage via a Storage-Area Network
(SAN). Provides high availability — the system survives individual node failures.
Asymmetric Clustering Symmetric Clustering
One machine is in hot-standby mode, ready to Multiple nodes run applications and monitor
take over if the active machine fails. each other simultaneously.
■ Note: Some clusters are used for High-Performance Computing (HPC). Applications must be
written to use parallelization. Distributed Lock Manager (DLM) prevents conflicting operations.
CS2006 Operating Systems • Chapter 1 Notes • FAST-NUCES Peshawar Page 13
Distributed Systems
■ Distributed System
A collection of separate, possibly heterogeneous systems networked together. Creates the
illusion of a single system to users.
• LAN – Local Area Network (campus, office building).
• WAN – Wide Area Network (country, globe — the Internet).
• MAN – Metropolitan Area Network (city).
• PAN – Personal Area Network (Bluetooth devices).
CS2006 Operating Systems • Chapter 1 Notes • FAST-NUCES Peshawar Page 14
Section 7: Kernel Data Structures
The OS kernel uses standard data structures internally. Understanding these is essential for
understanding how the OS manages processes, memory, and other resources.
Linked Lists
■ Singly Linked List
Each node contains data and a pointer to the next node. Traversal is one-directional (forward
only).
■ Doubly Linked List
Each node has pointers to both the next and previous nodes. Allows traversal in both directions.
Used extensively in the Linux kernel (e.g., process lists).
■ Circular Linked List
The last node points back to the first node, forming a circle. Useful for scheduling algorithms like
Round-Robin CPU scheduling.
Trees
■ Binary Search Tree (BST)
A tree where the left subtree contains nodes with values <= parent, and right subtree has values
> parent. Search time is O(n) in the worst case (unbalanced).
■ Balanced Binary Search Tree
A BST that automatically keeps its height minimized. Search time is O(log n). The Linux kernel
uses Red-Black Trees (a type of balanced BST) — defined in .
Hash Maps & Bitmaps
■ Hash Map
Uses a hash function to map keys to indices in an array, allowing O(1) average-time lookup.
Useful for quickly finding processes, files, or memory pages by ID.
CS2006 Operating Systems • Chapter 1 Notes • FAST-NUCES Peshawar Page 15
■ Bitmap
A string of n binary digits representing the status of n items (e.g., 1 = in use, 0 = free). Compact
and efficient for tracking free disk blocks or memory frames.
■ Note: Linux kernel data structures: (linked lists), (queues), (red-black trees).
CS2006 Operating Systems • Chapter 1 Notes • FAST-NUCES Peshawar Page 16
Chapter 1 Quiz — Test Your Knowledge
Q What is an Operating System and what are its two main roles?
1.
■ Answer: An OS is a program that acts as an intermediary between users and hardware. Its two
main roles are: (1) Resource Allocator — manages and distributes hardware resources, and (2)
Control Program — manages execution of programs to prevent errors.
Q What is the difference between a program and a process?
2.
■ Answer: A program is a passive entity — it is a file stored on disk. A process is an active entity —
it is a program loaded into memory and currently executing.
Q What is an interrupt? How does it differ from a trap?
3.
■ Answer: An interrupt is a hardware-generated signal sent to the CPU when a device finishes an
operation. A trap (or exception) is a software-generated interrupt caused by an error (e.g., division
by zero) or a deliberate system call. Both cause the OS to pause the current task and execute an
ISR.
Q What is the difference between User Mode and Kernel Mode?
4.
■ Answer: User Mode (mode bit=1): restricted mode for user applications, no direct hardware
access. Kernel Mode (mode bit=0): privileged mode for the OS, full hardware access. The transition
occurs via system calls (user→kernel) and returns (kernel→user).
Q What is multiprogramming and how does it improve CPU utilization?
5.
■ Answer: Multiprogramming keeps multiple jobs in memory simultaneously. When one job waits
for I/O, the OS switches the CPU to another job. This prevents the CPU from being idle, maximizing
utilization.
Q What is the difference between Symmetric (SMP) and Asymmetric Multiprocessing (AMP)?
6.
■ Answer: In AMP, each processor has a specific assigned task with one master CPU controlling
others. In SMP, all processors are equal peers and can perform any task. SMP is the most common
modern approach.
CS2006 Operating Systems • Chapter 1 Notes • FAST-NUCES Peshawar Page 17
Q What is DMA and why is it important?
7.
■ Answer: Direct Memory Access allows I/O device controllers to transfer data directly to/from main
memory without CPU involvement. It generates only one interrupt per block (not per byte),
dramatically reducing CPU overhead for high-speed I/O.
Q What is the difference between Protection and Security in an OS?
8.
■ Answer: Protection has an internal focus — controlling access of processes/users to OS-defined
resources. Security has an external focus — defending the system against external attacks like
viruses, denial-of-service, and identity theft.
Q What is the role of the Bootstrap program?
9.
■ Answer: The bootstrap program is firmware that runs at power-up. It initializes CPU registers,
device controllers, and memory contents, then locates and loads the OS kernel into memory, and
starts the first process (init/systemd).
Q What is the Storage Hierarchy and what are its three organizing factors?
10
.
■ Answer: The storage hierarchy organizes storage from fastest/smallest/most-expensive
(registers, cache) to slowest/largest/cheapest (HDD, tape). The three factors are: (1) Speed, (2)
Cost, and (3) Volatility.
Q What is a Clustered System? How does it differ from a Multiprocessor System?
11
.
■ Answer: A clustered system consists of multiple complete, separate computer systems working
together, usually sharing storage via a SAN. A multiprocessor system has multiple CPUs within a
single system sharing the same memory and bus. Clustered systems provide high availability
across machines.
Q Why does the OS need a Timer, and how does it work?
12
.
■ Answer: The OS uses a timer to prevent any single process from monopolizing the CPU (infinite
loop). The OS sets a counter (privileged instruction); the clock decrements it. When it reaches zero,
an interrupt fires and the OS regains control to terminate or reschedule the process.
CS2006 Operating Systems • Chapter 1 Notes • FAST-NUCES Peshawar Page 18
Quick Reference — Key Terms at a Glance
Term Meaning
OS Intermediary between user and hardware. Resource allocator + control program.
Kernel Core of OS; runs continuously from boot to shutdown.
Interrupt Signal to CPU that an event needs attention. OS-driven.
Trap/Exception Software-generated interrupt (error or system call).
System Call Legal way for user programs to request kernel services.
Bootstrap Firmware program that initializes system and loads kernel.
Daemon Background process started by init (systemd).
Multiprogramming Multiple jobs in memory; CPU switches on I/O wait.
Multitasking CPU switches so fast users interact with jobs in real time.
Virtual Memory Run processes not fully in RAM; disk used as extension.
Dual-Mode User mode (restricted) vs Kernel mode (privileged).
Privileged Inst. Instructions only executable in Kernel mode.
Timer Hardware that interrupts CPU to prevent process hogging.
DMA I/O data transfer directly to RAM; one interrupt per block.
Cache Fast temporary storage; checked before slower storage.
Buffer Temp memory area used during data transfer.
Spool Overlap output of one job with input of another (e.g., printing).
SMP Symmetric Multiprocessing — all CPUs are equal peers.
AMP Asymmetric Multiprocessing — CPUs have specific assigned tasks.
Clustered System Multiple complete systems sharing storage (SAN) for high availability.
Protection Internal access control (OS-defined resources).
Security Defense against external/internal attacks.
User ID Unique identifier per user, linked to files/processes.
Group ID Set of users; controls managed at group level.
Bitmap String of bits representing status of n items (0=free, 1=used).
Hash Map Key→index mapping for O(1) average lookups.
BST Binary Search Tree; balanced = O(log n) search.
CS2006 Operating Systems • Chapter 1 Notes • FAST-NUCES Peshawar Page 19