0% found this document useful (0 votes)
3 views11 pages

OS_Revision_Guide_Expanded

The document serves as an expanded revision guide for postgraduate operating systems, detailing key concepts such as the role of the operating system, process management, CPU scheduling algorithms, memory management, deadlocks, file system management, device management, secondary storage management, and security. It provides definitions, examples, and explanations of various topics, structured to aid in exam preparation. The guide emphasizes the importance of understanding both theoretical concepts and practical applications within operating systems.

Uploaded by

nechemanuel101
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views11 pages

OS_Revision_Guide_Expanded

The document serves as an expanded revision guide for postgraduate operating systems, detailing key concepts such as the role of the operating system, process management, CPU scheduling algorithms, memory management, deadlocks, file system management, device management, secondary storage management, and security. It provides definitions, examples, and explanations of various topics, structured to aid in exam preparation. The guide emphasizes the importance of understanding both theoretical concepts and practical applications within operating systems.

Uploaded by

nechemanuel101
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Postgraduate Operating Systems — Expanded Revision Guide

This is an expanded version of your revision manual, with deeper explanations, worked
examples, diagrams (in text form), and exam-ready model answers. Use the Model Essay
Structure (Define → Functions → Examples → Importance → Advanced/Challenges →
Conclude) for every theory question.

1. Introduction to Operating Systems


Simple definition: An OS is the “manager” sitting between you (the user), your apps, and
the physical machine. You never talk to the hardware directly — the OS translates your
requests into something the hardware understands.
Analogy: Think of a hotel. Guests (applications) want rooms, food, and services. They don’t
go into the kitchen or boiler room themselves — the hotel manager (OS) coordinates staff
(hardware) to fulfil requests fairly and safely.

Core Objectives — explained


Objective What it means Example
Convenience Hides hardware complexity You click “Print” — you
from the user don’t write driver code
Efficiency Makes the best use of CPU, Scheduling so the CPU is
memory, disk rarely idle
Resource Management Allocates limited resources Sharing one CPU among 50
among many programs running processes
Reliability System keeps working OS recovers from a crashed
correctly over time app without rebooting
Security Protects data and processes Login passwords, file
from unauthorized access permissions
Scalability Works whether on a small Same OS family (Linux)
phone or a huge server runs on a Raspberry Pi and
a data centre server

Exam tip: When asked “discuss functions of an OS,” structure your answer around these
objectives PLUS the management areas below (process, memory, file, device, security).
Markers reward breadth + examples.

2. Basic Structure of a Computer System


Users

Application Software (Word, Chrome, games)

Operating System ← the "translator/manager"

Hardware (CPU, RAM, Disk, Devices)

Why this matters: Every layer only talks to the layer directly next to it. Applications never
touch hardware directly — they make system calls to the OS, and the OS talks to hardware
via drivers. This layering is what allows the same app (e.g., Chrome) to run on different
hardware without being rewritten.

3. Process Management (Deep Dive)


3.1 What is a process?
A process = a program in execution + its current activity (registers, program counter,
stack, data).
Difference between a program and a process (common exam trick question): - A
program is a passive file on disk (e.g., [Link]) — just code. - A process is that program
loaded into memory and actively running, with its own resources.

3.2 Process States


Every process moves through states during its life:
admit scheduler dispatch
New ────────► Ready ─────────────────► Running
▲ │
│ I/O or event wait │
└────────── Waiting ◄──────┘


Terminated

• New: Process is being created.


• Ready: Waiting in the queue for the CPU.
• Running: Currently executing on the CPU.
• Waiting/Blocked: Waiting for I/O or an event (e.g., file read).
• Terminated: Finished execution.

3.3 Process Control Block (PCB)


The PCB is a data structure the OS keeps for every process — think of it as the process’s
“ID card + medical record.”
Contains: - Process ID (PID) - Process state (ready/running/waiting) - Program counter
(next instruction to execute) - CPU registers - Memory management info (page tables,
segment tables) - I/O status (open files, devices) - Scheduling info (priority, queue
pointers)
Exam tip: Always mention the PCB when discussing context switching — it’s the thing
being saved and reloaded.

3.4 Context Switching


When the CPU switches from running Process A to Process B: 1. Save A’s CPU state
(registers, program counter) into A’s PCB. 2. Load B’s saved state from B’s PCB into the
CPU. 3. B resumes exactly where it left off.
Overhead: Context switching itself does no useful work — it’s “pure overhead.” Too-
frequent switching (e.g., very short time slices in Round Robin) wastes CPU time on
switching rather than running programs.

3.5 Threads and Multithreading


A thread is a lightweight unit of execution within a process. Multiple threads in one process
share the same memory/code but have their own registers and stack.
Analogy: A process is a restaurant; threads are the chefs working in the same kitchen
(shared resources = ingredients/equipment), but each chef (thread) works on their own
dish independently.

Type Description Pros Cons


User-level threads Managed by a Fast to If one thread blocks
library in user create/switch, on I/O, whole
space; OS unaware portable process can block
Kernel-level Managed directly by OS can schedule Slower to
threads OS each thread on create/switch
different CPUs (true (kernel
parallelism) involvement)

Why multithreading matters: A browser uses separate threads for rendering,


downloading, and UI — so a slow download doesn’t freeze the whole interface.

4. CPU Scheduling Algorithms (with Worked Examples)


The CPU scheduler picks which Ready process runs next. Key metrics: - Waiting Time
(WT) = Turnaround Time − Burst Time - Turnaround Time (TAT) = Completion Time −
Arrival Time - Average WT/TAT = sum ÷ number of processes

4.1 First-Come, First-Served (FCFS)


Processes run strictly in arrival order — like a queue at a bank.
Example: Processes with burst times: P1=5, P2=3, P3=8 (all arrive at time 0)
| P1 (0-5) | P2 (5-8) | P3 (8-16) |

• P1: WT=0, TAT=5


• P2: WT=5, TAT=8
• P3: WT=8, TAT=16
• Average WT = (0+5+8)/3 = 4.33
Downside (Convoy Effect): If P3 (long job) arrived first, short jobs P1/P2 wait
unnecessarily — like a slow customer holding up a queue.

4.2 Shortest Job First (SJF)


Run the process with the smallest burst time next.
Using the same processes (P1=5, P2=3, P3=8), order becomes P2, P1, P3:
| P2 (0-3) | P1 (3-8) | P3 (8-16) |

• Average WT = (3+0+8)/3 = 3.67 (better than FCFS!)


Downside: Requires knowing burst times in advance (often estimated). Can cause
starvation of long jobs if short jobs keep arriving.

4.3 Round Robin (RR)


Each process gets a fixed time quantum (e.g., 2ms), then moves to back of queue if not
finished. Fair and good for time-sharing systems.
Example: P1=5, P2=3, P3=8, quantum=2
| P1(2) | P2(2) | P3(2) | P1(2) | P2(1) | P3(2) | P1(1) | P3(2) |
P3(2) |
0------2------4------6------8------9-----11-----12-----14-----16

Trade-off: Small quantum → fair but more context-switch overhead. Large quantum →
behaves like FCFS.

4.4 Priority Scheduling


Each process assigned a priority number; highest priority runs first. - Problem: Starvation
— low priority processes may never run. - Solution: Aging — gradually increase priority
of waiting processes over time.

Quick Comparison Table (great for exams)


Algorithm Preemptive? Best For Main Weakness
FCFS No Simple batch Convoy effect
systems
SJF Can be either Minimizing avg wait Needs burst-time
time prediction;
starvation
Algorithm Preemptive? Best For Main Weakness
Round Robin Yes Time-sharing/ Choosing quantum
interactive systems size
Priority Can be either Real-time/critical Starvation (fixed by
tasks aging)

5. Memory Management (Deep Dive)


5.1 Why memory management matters
RAM is limited and shared by all running processes. The OS must allocate it efficiently,
protect one process’s memory from another, and create the illusion of more memory than
physically exists (virtual memory).

5.2 Paging
Memory is divided into fixed-size blocks: - Frames — fixed-size blocks of physical RAM. -
Pages — fixed-size blocks of a process’s logical memory.
A page table maps each page to a frame. This avoids needing contiguous memory — pages
can be scattered anywhere in RAM.
Analogy: Think of a book (process) split into equal-sized pages, stored in random shelf
slots (frames) of a library (RAM). A catalogue (page table) tells you which slot holds which
page.

5.3 Segmentation
Memory divided into variable-sized segments based on logical units of a program — e.g.,
code segment, data segment, stack segment. More intuitive for programmers but can cause
fragmentation.

5.4 Fragmentation
• External fragmentation: Free memory exists but in small, scattered chunks — no
single chunk is big enough for a new process (common in segmentation).
• Internal fragmentation: A process is allocated more memory than it needs (e.g., a
4KB page for a 1KB program), wasting the leftover space (common in paging).
Analogy: External = many small empty parking spaces, none big enough for a bus. Internal
= a huge parking space given to a motorbike — the extra space is wasted.

5.5 Demand Paging


Pages are only loaded into RAM when actually needed (on demand), not all at once. If a
needed page isn’t in RAM, a page fault occurs, and the OS fetches it from disk.
Benefit: A program can start running even if not fully loaded — saves memory and speeds
up startup.
5.6 Virtual Memory
Virtual memory lets the system run programs larger than physical RAM by using disk space
(the swap/page file) as an extension of RAM.
Analogy: Your desk (RAM) is small, but you have a filing cabinet (disk). You keep only the
documents you’re currently working on the desk; the rest stay in the cabinet until needed.
To you, it feels like you have unlimited desk space.
Thrashing: If too many processes compete for too little RAM, the system spends more time
swapping pages in/out than doing actual work — performance collapses. Fix: reduce
running processes or add RAM.

6. Deadlocks (Deep Dive — Very Examinable)


6.1 Definition
A deadlock occurs when two or more processes are stuck, each waiting for a resource held
by another, so none can proceed.
Classic analogy: Two cars meet on a single-lane bridge, each going opposite directions.
Neither can move forward because the other is blocking; neither will reverse. Total
standstill.

6.2 The Four Necessary Conditions (Coffman Conditions)


All four must hold simultaneously for deadlock: 1. Mutual Exclusion: At least one resource
is held in a non-shareable mode. 2. Hold and Wait: A process holds one resource while
waiting for another. 3. No Preemption: Resources can’t be forcibly taken away — only
released voluntarily. 4. Circular Wait: A circular chain of processes, each waiting for a
resource held by the next.
Memory aid: “My House Needs Cleaning” (Mutual exclusion, Hold and wait, No
preemption, Circular wait).

6.3 Handling Deadlocks — Four Strategies


Strategy Idea Trade-off
Prevention Design the system so at Can reduce resource
least one Coffman condition utilization
can never hold (e.g., request
all resources at once)
Avoidance Allow requests, but only Needs advance knowledge
grant if it keeps the system of max resource needs
in a “safe state” (e.g.,
Banker’s Algorithm)
Detection & Recovery Let deadlocks happen, Overhead of periodic
Strategy Idea Trade-off
detect via resource- checking; recovery can be
allocation graphs, then costly
recover (kill a process, or
preempt a resource)
Ignore (Ostrich Do nothing — assume Used by many general-
Algorithm) deadlocks are rare enough purpose OSes (e.g., UNIX)
because overhead of
prevention isn’t worth it

6.4 Banker’s Algorithm (briefly)


Before granting a resource request, the OS checks: “If I grant this, can all processes still
eventually finish (a safe sequence exists)?” If yes → grant. If no → make the process wait.
Named after a banker who won’t lend money if it risks being unable to satisfy all
customers.

7. File System Management (Deep Dive)


7.1 Core idea
A file system organizes data on storage so it can be stored, retrieved, and managed
efficiently — like an index/filing system for a library.

7.2 Common File Systems


File System Used By Key Feature
FAT (FAT32) Older Windows, USB drives Simple, widely compatible,
but max file size 4GB, no
journaling
NTFS Modern Windows Supports permissions,
encryption, large files,
journaling
ext4 Linux Journaling, supports very
large files/volumes, good
performance

7.3 Journaling File Systems


A journal is a log where the file system records changes before actually making them.
Why it matters: If the system crashes mid-write (e.g., power cut), the OS can replay the
journal on reboot to complete or roll back the operation — preventing corruption.
Analogy: Like writing “I am about to transfer $100 from A to B” in a notebook before doing
it. If interrupted halfway, you can check the notebook and finish or undo the transfer
correctly.

8. Device Management (Deep Dive)


The OS communicates with hardware (keyboard, mouse, printer, monitor, etc.) through
device drivers — small programs that translate generic OS commands into device-specific
instructions.
Why drivers matter: The OS doesn’t need to know the internal workings of every printer
model — it just sends a generic “print” command, and the driver translates it for that
specific printer.
• Input devices: keyboard, mouse, touchscreen — send data to the system.
• Output devices: monitor, printer, speakers — receive data from the system.

9. Secondary Storage Management (Deep Dive)


9.1 Disk Scheduling Algorithms (often tested alongside CPU scheduling)
The disk head must move across tracks to read/write data — minimizing head movement =
better performance.

Algorithm How it works


FCFS Serve requests in arrival order — simple
but can cause long seek times
SSTF (Shortest Seek Time First) Always go to the closest request next —
efficient but can starve far-away requests
SCAN Head moves in one direction servicing
requests, then reverses (like an elevator)
C-SCAN Like SCAN, but jumps back to the start
without servicing on the return trip —
more uniform wait times

Analogy: Think of an elevator (SCAN) — it doesn’t go back down immediately after the top
floor request; it continues to the top then comes back, picking up everyone along the way in
order.

9.2 Functions recap


• Space allocation: deciding where on disk a file’s blocks go (contiguous, linked, or
indexed allocation).
• Free-space management: tracking which blocks are free (e.g., via bitmaps or free
lists).
10. Security and Protection (Deep Dive)
Term Meaning Example
Authentication Verifying who you are Password, fingerprint
Authorization Verifying what you’re File permissions
allowed to do (read/write/execute)
Access Control Enforcing authorization Linux chmod permissions
rules
Encryption Scrambling data so only BitLocker, file encryption
authorized parties can read
it
Malware protection Detecting/blocking Antivirus scanning
malicious software

CIA Triad (core security goals — very examinable): - Confidentiality: Only authorized
users see the data. - Integrity: Data isn’t altered without authorization. - Availability:
Data/systems are accessible when needed.
Advanced concepts: - ACL (Access Control List): A list attached to a resource specifying
which users/groups have which permissions. - RBAC (Role-Based Access Control):
Permissions assigned to roles (e.g., “Admin,” “Editor”), and users are assigned roles —
easier to manage at scale. - MFA (Multi-Factor Authentication): Combines something you
know (password), something you have (phone/token), and/or something you are
(fingerprint).

11. Networking, Distributed, Cloud & Mobile OS


• Networking: Modern OSes have built-in support for TCP/IP stacks, enabling
internet access, file sharing, and client-server communication.
• Client-Server systems: One machine (server) provides resources/services; others
(clients) request them — e.g., email servers.
• Distributed OS: Manages a group of independent computers and makes them
appear as a single coherent system to users. Key challenges: synchronization,
communication, fault tolerance.
• Cloud computing & OS role: The OS (often via hypervisors/virtualization) allows
multiple virtual machines to share physical hardware, enabling on-demand scalable
resources (e.g., AWS, Azure).
• Mobile OS (Android/iOS): Optimized for battery life, touch input, app sandboxing
(security isolation between apps), and limited resources compared to desktops.
12. Performance Monitoring, Resource Management & Error Handling (Quick
Recap)
• Performance monitoring: OS tracks CPU/memory/disk/network usage to detect
bottlenecks and optimize scheduling.
• Resource management goal: Maximum efficiency with fairness — no single
process should starve others.
• Error detection: OS catches crashes, hardware faults, memory errors, and disk
errors, often logging them and isolating the failure so the whole system doesn’t go
down.

13. Model Answers — Likely Exam Questions


Q1: Discuss the major functions of an OS with relevant examples.
Answer outline: 1. Define: OS as intermediary managing hardware/software (Section 1).
2. Functions: Process management (multitasking), Memory management (allocating RAM),
File system management (organizing data), Device management (drivers), Security
(authentication/encryption), Networking (internet access). 3. Examples: Running Word +
browser simultaneously (process mgmt); browser using more RAM than Notepad (memory
mgmt); USB file transfer (device mgmt). 4. Importance: Without these functions, hardware
would be unusable directly by average users. 5. Advanced: Mention virtual memory,
journaling file systems, RBAC for postgraduate depth. 6. Conclude: OS functions
collectively ensure efficient, secure, user-friendly computing.

Q6: Discuss CPU Scheduling Algorithms.


Cover FCFS, SJF, Round Robin, Priority (Section 4) — define each, give a small Gantt chart
example, state pros/cons, and conclude that real OSes (e.g., Linux’s CFS) often combine
ideas from several algorithms for balance.

Q7: Explain Deadlocks and methods of handling them.


Define deadlock → state the 4 Coffman conditions → explain prevention, avoidance
(Banker’s algorithm), detection & recovery, and the “ignore” approach → conclude that
prevention is theoretically ideal but avoidance/detection are more practical.
(Apply the same Define → Functions → Examples → Importance → Advanced → Conclude
pattern to Q2–Q5, Q8–Q10 using the relevant sections above.)

14. Final Quick-Revision Flashcards


• Process vs Program: Program = static file; Process = program in execution.
• PCB: Stores everything needed to pause/resume a process (registers, PC, state,
memory info).
• Context switch: Saving/restoring PCBs when CPU changes processes — pure
overhead.
• Paging vs Segmentation: Paging = fixed-size blocks (internal fragmentation);
Segmentation = variable-size logical units (external fragmentation).
• Demand paging: Load pages only when needed → page fault if missing.
• Thrashing: Excessive swapping due to insufficient RAM → system slows drastically.
• Deadlock conditions (MHNC): Mutual exclusion, Hold & wait, No preemption,
Circular wait — ALL four needed.
• Banker’s Algorithm: Avoidance technique — only grants requests that keep
system in a “safe state.”
• Journaling: Logs changes before applying them → crash recovery.
• CIA Triad: Confidentiality, Integrity, Availability — core security goals.
• RBAC vs ACL: RBAC assigns permissions via roles (scalable); ACL assigns
permissions directly to users/resources.

Study strategy for Emmanuel: For each “Likely Exam Question,” practice writing a full
answer in ~10–12 minutes using the Model Essay Structure, then check it against the
relevant section above. Focus extra time on CPU Scheduling (worked Gantt charts) and
Deadlocks (Coffman conditions + Banker’s Algorithm), as these are the most
calculation/analysis-heavy and most postgraduate-examinable topics.

You might also like