Syllabus 9.4 — Loading, Linking, I/O Control, Buffering, Spooling & Disk Scheduling
Part I: Job Management
1. What is a Job?
A Job is a complete unit of work submitted to the OS for execution. It usually consists of a program, input data, control information, and output requirements.
| Characteristic | Detail |
| Size | Large unit of work |
| Contents | May contain multiple tasks |
| Timing | Submitted to OS before execution |
| Example | Print 10,000 mark sheets — the entire request is one job |
2. What is a Task?
A Task is an individual activity performed within a job.
| Job Example | Tasks Inside |
| Print examination result | Read database |
| Calculate GPA |
| Generate PDF |
| Print report |
Job vs Task vs Process
| Feature | Job | Task | Process |
| Definition | Complete work submitted to OS | Small activity within a job | Program currently executing |
| Size | Large | Small | Active unit |
| Timing | Before execution | During job execution | Running in memory |
| Example | Write a thesis | Literature review, data collection | MS Word running |
Job Scheduling & Types of Processing
Job scheduling (handled by the Long-Term Scheduler) determines which jobs enter memory.
| Processing Type | Description | Example | Advantage | Disadvantage |
| Batch Processing |
Jobs collected and executed one after another without user interaction |
Electricity bill generation, payroll |
Efficient for repetitive work |
Long waiting time; no user interaction |
| Interactive Processing |
User communicates directly with the system |
ATM, online banking |
Immediate feedback |
Requires constant user attention |
| Time-Sharing |
CPU rapidly switches among multiple users |
Multiple users on one server |
Many users share one system |
Response degrades with many users |
Part II: Program Execution
Program Execution Flow
| Stage | Output | Tool |
| Source Program | High-level code (C, Java) | — |
| ↓ Compile / Assemble | Object File (.obj / .o) | Compiler / Assembler |
| ↓ Link | Executable (.exe / a.out) | Linker |
| ↓ Load | Program in RAM | Loader |
| ↓ Execute | Running process | CPU |
📌 Memory Trick — CALL: C → Compiler | A → Assembler | L → Linker | L → Loader
4. Compiler
A compiler translates an entire high-level language program into machine code at once.
| Characteristic | Detail |
| Input | High-level source code (C, C++, Java) |
| Output | Object file (machine code) |
| Translation | Entire program at once |
| Execution | Faster (already translated) |
| Errors | Reported after full compilation |
5. Assembler
An assembler converts assembly language into machine language (binary instructions).
| Feature | Compiler | Assembler |
| Input | High-level language (C, Java) | Assembly language (MOV, ADD) |
| Output | Object file | Object file (machine code) |
| Level | High-level → Machine | Assembly → Machine |
6. Linker
The Linker combines object files and required libraries into one executable program. Without the linker, a program cannot become executable.
Example: A C program uses printf(). The linker connects the program with the standard C library that contains printf().
| Linking Type | Description | Advantage | Disadvantage |
| Static Linking |
Library code copied into the executable at link time |
Independent executable; faster execution |
Larger executable file; harder to update |
| Dynamic Linking |
Library loaded into memory at runtime when needed |
Smaller executable; easier to update shared libraries |
Library must exist on the system at runtime |
| Feature | Static Linking | Dynamic Linking |
| Library | Copied into executable | Shared at runtime |
| Executable size | Large | Small |
| Execution speed | Faster | Slight overhead |
| Updates | Difficult (recompile needed) | Easy (update the shared library) |
7. Loader
The Loader loads the executable program from disk into RAM for execution.
| Responsibility |
| Allocate memory for the program |
| Load the executable code and data into RAM |
| Relocate addresses if needed |
| Transfer control to the program start address |
| Loader Type | Description |
| Absolute Loader | Loads program into a fixed memory location; simple but no relocation |
| Relocating Loader | Program may be loaded anywhere; adjusts addresses; used in modern OS |
| Dynamic Loader | Loads routines only when required; saves memory |
Linker vs Loader
| Feature | Linker | Loader |
| Purpose | Creates an executable from object files | Loads executable into RAM |
| When | Before execution (link time) | At execution time |
| Input | Object files + libraries | Executable file |
| Output | Executable file | Running process in memory |
Part III: I/O Management
8. I/O Control
I/O Control manages communication between the CPU and input/output devices. Goals: efficient data transfer, device independence, and error handling.
| I/O Category | Examples |
| Input Devices | Keyboard, Mouse, Scanner, Microphone |
| Output Devices | Monitor, Printer, Speaker |
| Storage Devices | HDD, SSD, USB Drive |
Device Controller & Device Driver
| Feature | Device Controller | Device Driver |
| Type | Hardware | Software |
| Role | Controls the physical device directly | Allows OS to communicate with the controller |
| Examples | Disk Controller, USB Controller, Printer Controller | Printer Driver, Graphics Driver, Sound Driver |
| Location | Part of the device / motherboard | Installed in the OS |
Flow: CPU ↓ Device Driver ↓ Device Controller ↓ Hardware Device
Interrupt-Driven I/O
Instead of the CPU continuously checking device status, the device sends an interrupt when its work is complete.
| Step | Action |
| 1 | CPU starts I/O operation and continues other work |
| 2 | Device completes its task |
| 3 | Device sends interrupt signal to CPU |
| 4 | CPU handles the interrupt (ISR runs) |
| 5 | CPU resumes previous task |
Advantage: CPU is free to do other work while I/O proceeds.
Direct Memory Access (DMA)
Problem without DMA: CPU must transfer every byte between device and RAM — very slow and inefficient.
DMA Solution: A dedicated DMA controller transfers data directly between the device and RAM. The CPU only initiates the transfer and is notified when done.
| Step | Action |
| 1 | CPU gives DMA controller the source, destination, and size |
| 2 | DMA controller transfers data between device and RAM directly |
| 3 | CPU is free for other tasks during transfer |
| 4 | DMA sends interrupt to CPU when done |
I/O Methods Comparison
| Feature | Programmed I/O | Interrupt-Driven I/O | DMA |
| CPU Involvement | Constant (busy-wait loop) | Interrupted when done | Minimal (only initiates) |
| Efficiency | Slow | Better | Fastest |
| CPU Utilization | Poor (CPU busy checking) | Good | Best |
| Complexity | Simple | Moderate | More complex |
📌 Memory Trick — PID: P → Programmed I/O | I → Interrupt I/O | D → DMA
Part IV: Buffering, Caching & Spooling
Buffering
Buffering is temporary storage used while data moves between devices of different speeds.
| Example | Why Needed |
| YouTube video playback | Video loads ahead into buffer so playback stays smooth even if network slows |
| Keyboard input | Keystrokes buffered before OS processes them |
| Advantage | Disadvantage |
| Smooths data transfer between mismatched speeds | Adds a small delay (buffer fill time) |
| Prevents data loss | Uses memory |
Caching
Caching stores frequently accessed data in fast memory so future access is faster.
| Type | Example | Benefit |
| CPU Cache (L1/L2/L3) | Recently used instructions and data | Avoids slow RAM access |
| Browser Cache | Downloaded web pages and images | Faster page reload |
| Disk Cache | Recently read disk blocks | Avoids slow disk access |
Spooling
Spooling (Simultaneous Peripheral Operations On-Line) stores jobs temporarily in a queue before processing by a slow device.
Classic Example: Printer Queue
| Step | Action |
| 1 | Job A sent to printer spool |
| 2 | Job B sent to printer spool |
| 3 | Job C sent to printer spool |
| 4 | Printer processes them one by one in order |
| Advantage |
| Better device utilization — device never waits for next job |
| Multiple users can share one slow device |
| Users get control back immediately after submitting |
Buffer vs Cache vs Spool
| Feature | Buffer | Cache | Spool |
| Purpose | Temporary transfer storage | Fast copy of frequent data | Waiting queue for slow device |
| Goal | Match speed differences | Improve access speed | Device sharing & queuing |
| Example | Video stream buffer | CPU cache, browser cache | Printer queue |
| Data lifetime | Until transferred | Until evicted | Until processed |
📌 Memory Trick — BCS: B → Buffer | C → Cache | S → Spool
Part V: Disk Scheduling
The hard disk receives many I/O requests. The OS must decide the order in which to serve them to minimise seek time.
| Algorithm | Strategy | Advantage | Disadvantage |
| FCFS |
Serve requests in arrival order |
Simple and fair |
High seek time; not efficient |
| SSTF (Shortest Seek Time First) |
Serve the nearest request first |
Low average seek time |
Starvation of far requests |
| SCAN (Elevator Algorithm) |
Disk arm moves in one direction serving requests, then reverses |
Fair; no starvation |
Far end may wait longer |
| C-SCAN (Circular SCAN) |
Moves in one direction only; jumps back to start without serving on return |
More uniform waiting time |
Slightly more seek time than SCAN |
📌 SCAN is also called the Elevator Algorithm because it works like an elevator — serves floors in one direction, then reverses.
Memory Tricks
| Mnemonic | Full Form |
| Program Translation — CALL |
C → Compiler A → Assembler L → Linker L → Loader |
| I/O Techniques — PID |
P → Programmed I/O I → Interrupt I/O D → DMA |
| Buffering Concepts — BCS |
B → Buffer C → Cache S → Spool |
| Disk Scheduling — FSS C |
F → FCFS S → SSTF S → SCAN C → C-SCAN |
Frequently Asked Exam Questions
| Question | Answer |
| Difference between linker and loader? | Linker creates executable; Loader loads executable into RAM |
| Difference between compiler and assembler? | Compiler: high-level → machine code. Assembler: assembly → machine code. |
| Difference between buffering and caching? | Buffering matches transfer speeds; Caching speeds up repeated access |
| What is DMA? | Direct Memory Access transfers data between I/O device and RAM without continuous CPU involvement |
| What is spooling? | Temporary queuing of jobs for slow devices (e.g., printer queue) |
| Which disk scheduling is the Elevator Algorithm? | SCAN |
| Difference between static and dynamic linking? | Static: library copied into executable. Dynamic: library loaded at runtime. |
| What is a device driver? | Software that allows the OS to communicate with a hardware device |
Practice MCQs
-
1. Which component combines object files into an executable?
A. Compiler B. Loader C. Linker D. Scheduler
✅ Answer: C — Linker
-
2. Which component loads an executable into memory?
A. Linker B. Loader C. Compiler D. Assembler
✅ Answer: B — Loader
-
3. DMA primarily reduces:
A. RAM size B. CPU involvement in data transfer C. Hard disk size D. Process scheduling
✅ Answer: B — CPU involvement in data transfer
-
4. Which technique is commonly used for printer queues?
A. Paging B. Buffering C. Spooling D. Swapping
✅ Answer: C — Spooling
-
5. Which disk scheduling algorithm is also known as the Elevator Algorithm?
A. FCFS B. SSTF C. SCAN D. FIFO
✅ Answer: C — SCAN