Chapter 8: Data, Task and Job Management

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.

CharacteristicDetail
SizeLarge unit of work
ContentsMay contain multiple tasks
TimingSubmitted to OS before execution
ExamplePrint 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 ExampleTasks Inside
Print examination resultRead database
Calculate GPA
Generate PDF
Print report

Job vs Task vs Process

FeatureJobTaskProcess
DefinitionComplete work submitted to OSSmall activity within a jobProgram currently executing
SizeLargeSmallActive unit
TimingBefore executionDuring job executionRunning in memory
ExampleWrite a thesisLiterature review, data collectionMS Word running

Job Scheduling & Types of Processing

Job scheduling (handled by the Long-Term Scheduler) determines which jobs enter memory.

Processing TypeDescriptionExampleAdvantageDisadvantage
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

StageOutputTool
Source ProgramHigh-level code (C, Java)—
↓ Compile / AssembleObject File (.obj / .o)Compiler / Assembler
↓ LinkExecutable (.exe / a.out)Linker
↓ LoadProgram in RAMLoader
↓ ExecuteRunning processCPU

📌 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.

CharacteristicDetail
InputHigh-level source code (C, C++, Java)
OutputObject file (machine code)
TranslationEntire program at once
ExecutionFaster (already translated)
ErrorsReported after full compilation

5. Assembler

An assembler converts assembly language into machine language (binary instructions).

FeatureCompilerAssembler
InputHigh-level language (C, Java)Assembly language (MOV, ADD)
OutputObject fileObject file (machine code)
LevelHigh-level → MachineAssembly → 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 TypeDescriptionAdvantageDisadvantage
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
FeatureStatic LinkingDynamic Linking
LibraryCopied into executableShared at runtime
Executable sizeLargeSmall
Execution speedFasterSlight overhead
UpdatesDifficult (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 TypeDescription
Absolute LoaderLoads program into a fixed memory location; simple but no relocation
Relocating LoaderProgram may be loaded anywhere; adjusts addresses; used in modern OS
Dynamic LoaderLoads routines only when required; saves memory

Linker vs Loader

FeatureLinkerLoader
PurposeCreates an executable from object filesLoads executable into RAM
WhenBefore execution (link time)At execution time
InputObject files + librariesExecutable file
OutputExecutable fileRunning 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 CategoryExamples
Input DevicesKeyboard, Mouse, Scanner, Microphone
Output DevicesMonitor, Printer, Speaker
Storage DevicesHDD, SSD, USB Drive

Device Controller & Device Driver

FeatureDevice ControllerDevice Driver
TypeHardwareSoftware
RoleControls the physical device directlyAllows OS to communicate with the controller
ExamplesDisk Controller, USB Controller, Printer ControllerPrinter Driver, Graphics Driver, Sound Driver
LocationPart of the device / motherboardInstalled 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.

StepAction
1CPU starts I/O operation and continues other work
2Device completes its task
3Device sends interrupt signal to CPU
4CPU handles the interrupt (ISR runs)
5CPU 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.

StepAction
1CPU gives DMA controller the source, destination, and size
2DMA controller transfers data between device and RAM directly
3CPU is free for other tasks during transfer
4DMA sends interrupt to CPU when done

I/O Methods Comparison

FeatureProgrammed I/OInterrupt-Driven I/ODMA
CPU InvolvementConstant (busy-wait loop)Interrupted when doneMinimal (only initiates)
EfficiencySlowBetterFastest
CPU UtilizationPoor (CPU busy checking)GoodBest
ComplexitySimpleModerateMore 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.

ExampleWhy Needed
YouTube video playbackVideo loads ahead into buffer so playback stays smooth even if network slows
Keyboard inputKeystrokes buffered before OS processes them
AdvantageDisadvantage
Smooths data transfer between mismatched speedsAdds a small delay (buffer fill time)
Prevents data lossUses memory

Caching

Caching stores frequently accessed data in fast memory so future access is faster.

TypeExampleBenefit
CPU Cache (L1/L2/L3)Recently used instructions and dataAvoids slow RAM access
Browser CacheDownloaded web pages and imagesFaster page reload
Disk CacheRecently read disk blocksAvoids 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

StepAction
1Job A sent to printer spool
2Job B sent to printer spool
3Job C sent to printer spool
4Printer 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

FeatureBufferCacheSpool
PurposeTemporary transfer storageFast copy of frequent dataWaiting queue for slow device
GoalMatch speed differencesImprove access speedDevice sharing & queuing
ExampleVideo stream bufferCPU cache, browser cachePrinter queue
Data lifetimeUntil transferredUntil evictedUntil 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.

AlgorithmStrategyAdvantageDisadvantage
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

MnemonicFull 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

QuestionAnswer
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