9618 Computer Science - System Software
An Operating System is a program that acts as an interface between user and computer hardware and controls execution of all kinds of programs. Without an OS, a computer would be unusable - you couldn't run applications, save files, or even boot up!
When a computer is first powered on, it takes its start-up instructions from ROM. The computer has a Basic Input Output System (BIOS) stored in ROM, which starts a bootstrap program.
BIOS (Basic Input Output System): Firmware stored in ROM that performs hardware initialization during booting and provides runtime services for OS and programs.
Bootstrap Program: A small program that loads the operating system into main memory (RAM) from the Hard Disk Drive (HDD) or Solid State Drive (SSD).
Bootstrapping: The process of loading the OS into memory when the computer is switched on.
Remember: BIOS is in ROM (non-volatile) and starts the bootstrap, which then loads the OS from disk (HDD/SSD) into RAM. The OS is stored on disk when computer is off!
One operating system task is to maximise utilisation of computer resources. Resource management can be split into three main areas:
Each program running on a computer is known as a process. The OS manages how software uses resources through scheduling to ensure efficient usage of CPU time.
RAM is allocated dynamically to active programs. If RAM is full, the OS may use virtual memory on disk to simulate extra memory, allowing more programs to run.
I/O devices are much slower than the CPU, so the OS optimizes their use through device drivers, interrupts, and Direct Memory Access (DMA).
A DMA controller allows hardware to access main memory independently of the CPU. This frees up the CPU to perform other tasks while slower I/O operations are taking place.
| Device | Typical Data Rate |
|---|---|
| Keyboard | ~50 bps (bits per second) |
| Mouse | ~120 bps |
| Laser Printer | ~1 Mbps |
| Hard Disk | ~100 Mbps |
| CPU (2.7 GHz) | Billions of operations/sec |
The kernel is the central component of an Operating System - the "heart" of the OS. It is responsible for communication between hardware, software, and memory.
The kernel is the portion of the operating system code that is always resident in memory. It facilitates interactions between hardware and software components. When a process makes a request to the kernel, it is called a System Call.
| Area | Responsibility |
|---|---|
| Process Management | Schedules processes, allocates CPU time, handles multitasking |
| Memory Management | Allocates RAM to processes, handles virtual memory, prevents clashes |
| Device Management | Controls I/O devices using device drivers |
| Interrupt Handling | Deals with interrupts from hardware (DMA, I/O devices) |
| File Management | Handles reading/writing from files and file systems |
One of the most important tasks of an OS is to hide the complexities of hardware from users:
Multitasking allows computers to carry out more than one task (process) at a time. The CPU can only execute one instruction at a time, but it processes billions per second, switching between tasks so quickly that it gives the illusion of programs running simultaneously.
Multitasking: Function allowing a computer to process more than one task/process at a time.
Process: A program that has started to be executed - includes program code, current data, register values, and memory space.
Scheduling: Process manager which handles removal of running programs from CPU and selection of new processes.
| Preemptive | Non-Preemptive |
|---|---|
| Resources allocated for a limited time | Process retains resources until completed or blocked |
| Process can be interrupted while running | Process cannot be interrupted while running |
| More flexible form of scheduling | More rigid form of scheduling |
| Examples: Round Robin, SRTF | Examples: FCFS, SJF |
A Process Control Block (PCB) is a data structure containing all data needed for a process to run:
The PCB is crucial for context switching - when CPU switches from one process to another, all current values must be saved in the PCB so the process can resume later!
A process can be in one of three states: Running, Ready, or Blocked. Understanding state transitions is crucial for understanding scheduling.
| State | Description | Characteristics |
|---|---|---|
| Running | Process is being executed by the processor | Only ONE process can be running at a time |
| Ready | Process is prepared to run but waiting for CPU | New processes always start in ready state |
| Blocked | Process is waiting for an event or resource | e.g., waiting for I/O completion |
Scheduling decides which processes should be carried out and for how long. Different algorithms have different uses, benefits, and drawbacks.
Non-preemptive algorithm using FIFO (First In First Out) principle. Jobs are executed in the order they arrive.
Non-preemptive algorithm that prioritizes the shortest job in the queue. Process requiring least CPU time is executed first.
Preemptive version of SJF. When a process with shorter burst time arrives, the existing process is removed and the shorter one executes.
Preemptive algorithm that allocates a fixed time quantum to each process. Processes are served in circular order.
| Algorithm | Benefits | Drawbacks |
|---|---|---|
| Round Robin | Fair share of CPU; Good for time-sharing; Predictable | Choosing quantum is difficult; High turnaround for long processes |
| FCFS | Simple and easy to understand; Fair order | Poor performance if long process arrives first; High waiting time |
| SJF | Minimizes waiting time; Efficient for short processes | Requires burst time in advance; Long processes may starve |
| SRTF | Ideal for shorter burst times; Preemptive flexibility | Requires burst time; High context switching overhead |
Turnaround Time = Completion time - Arrival time
Waiting Time = Turnaround time - Burst time
Average Waiting Time = Total waiting time / Number of processes
Process priority depends on:
An interrupt is a signal sent to the processor by hardware or software indicating that they require processor attention.
| IPL Level | Interrupt Type |
|---|---|
| 31 | Power fail interrupt (highest priority) |
| 24 | Clock interrupt |
| 20-23 | I/O devices |
Interrupt Dispatch Table (IDT): Data structure linking device descriptions with appropriate interrupt routines.
Interrupt Service Routine (ISR): Program code that handles the interrupt event.
| Interrupt Type | Scheduling Role |
|---|---|
| Timer Interrupts | Triggers context switch between processes (preemptive multitasking) |
| I/O Interrupts | Signals I/O task completion - unblocks waiting processes |
| Hardware Interrupts | Responds to urgent external events (power failure, input) |
| Software Interrupts | Requests system-level services (memory allocation) |
Memory management deals with allocation and deallocation of primary memory. When a process starts, memory is allocated; when completed, memory is deallocated.
Paging divides main memory into equal-sized blocks called frames, and processes into equal-sized pages.
Segmentation divides memory into variable-size blocks called segments. Each segment corresponds to different types of data (e.g., code segment, data segment, stack segment).
| Aspect | Paging | Segmentation |
|---|---|---|
| Block Size | Fixed-size blocks | Variable-size blocks |
| Fragmentation | Internal fragmentation (unused space in page) | External fragmentation (gaps between segments) |
| User Knowledge | Invisible to user | Visible to programmer |
| Address | Single value (page number) | Two values (segment number + offset) |
| Speed | Faster access | Slower access |
| Managed By | Operating System | Compiler calculates segment size |
Internal Fragmentation: Wasted space INSIDE a block (paging)
External Fragmentation: Wasted space OUTSIDE blocks (segmentation)
Virtual memory uses secondary storage (HDD/SSD) to extend RAM, giving the illusion of more memory than physically available.
Secondary storage is used to extend RAM so the CPU appears to access more memory space than available. Only data in use needs to be in main memory - other data can be swapped between RAM and virtual memory.
| Benefits | Drawbacks |
|---|---|
| Run larger programs than RAM allows | Slower than physical RAM |
| More programs can run simultaneously | Increased disk read/write operations |
| Cost savings (less RAM needed) | Can lead to disk thrashing |
| Data sharing between RAM and virtual memory | Complex algorithm implementation |
A page fault occurs when a process needs access to a page that is not in memory. The required page must be swapped in from secondary storage.
When more time is spent moving pages in and out of memory than actually processing, system performance degrades severely. This can lead to thrash point where execution halts.
When a page fault occurs and memory is full, a page must be replaced. Different algorithms decide which page to remove:
| Algorithm | Description | Pros/Cons |
|---|---|---|
| FIFO | Remove oldest page in memory | Simple but may suffer Belady's anomaly |
| LRU | Remove least recently used page | Often most efficient, requires tracking |
| Optimal | Remove page used farthest in future | Best efficiency but impossible to implement (needs future knowledge) |
Unexpected phenomenon where increasing number of frames can actually increase page faults in FIFO algorithm.
Answer:
Answer (any one):
Answer:
Answer:
Answer:
Answer:
Answer:
Answer:
Answer:
Answer:
| Term | Definition |
|---|---|
| BIOS | Basic Input Output System - firmware in ROM that initializes hardware during boot |
| Bootstrap | Small program that loads the OS into memory from disk |
| Blocked State | Process waiting for an event or resource (e.g., I/O completion) |
| Burst Time | Time when a process has control of the CPU |
| Context Switch | Saving state of one process and loading another |
| DMA | Direct Memory Access - allows hardware to access memory without CPU |
| Frames | Fixed-size physical memory blocks in paging |
| Internal Fragmentation | Unused space inside allocated memory block (paging) |
| External Fragmentation | Unused space between allocated blocks (segmentation) |
| Interrupt | Signal to CPU requiring immediate attention |
| Kernel | Core component of OS, always resident in memory |
| Multitasking | Ability to handle multiple processes simultaneously |
| Page Fault | Occurs when required page is not in memory |
| Pages | Fixed-size logical memory blocks in paging |
| PCB | Process Control Block - data structure for process information |
| Process | A program that has started to be executed |
| Quantum | Fixed time slice allocated to a process |
| Ready State | Process prepared to run but waiting for CPU |
| Running State | Process currently being executed by CPU |
| Scheduling | Deciding which process runs and for how long |
| Segmentation | Memory management with variable-size blocks |
| Virtual Memory | Using disk space to extend available RAM |
| Topic | Key Point |
|---|---|
| BIOS | In ROM, starts bootstrap |
| Kernel | Always in memory, manages resources |
| DMA | Transfers data without CPU involvement |
| PCB | Stores process state and information |
| Virtual Memory | Extends RAM using disk |
| Page Fault | Page not in memory |
| Disk Thrashing | Excessive page swapping |