System software


1. Need for operating systems


Operating system provides an interface between the user and the hardware


features:

Multitasking

  • when you have more than one program open and running at the same time

the processor allocates a small amount of time to each process and cycles between them. As this happens so quickly, it appears as if multiple programs are executed simultaneously


File management: moving, editing, deleting files and folders


Memory management: paging, segmentation, virtual memory


Resource management: scheduling


Input/output management: device drivers


Interrupt management


Utility software: disk defragmentation, backup formatting etc


Security: firewall


User interface


Virtual memory

A portion of secondary storage used as an extension of RAM when the RAM becomes full


Advantage:

  • allows larger programs to run

  • supports multitasking

  • prevents memory shortages


Disadvantages:

  • slower than RAM

  • can reduce system performance


Paging

A memory management technique that divides memory into fixed-size pages and frames


Advantages

  • efficient memory allocation

  • supports virtual memory

  • reduces external fragmentation


Disadvantages

  • requires page tables

  • processing overhead

  • internal fragmentation possible


Segmentation

A memory management technique that divides a program into logical variable-sized segments


Advantages

  • reflects program structure

  • improved protection and sharing

  • flexible organisation


Disadvantages

  • external fragmentation

  • more complex management



Interrupts

A signal sent by the hardware or software requesting immediate attention from the CPU. The CPU temporarily suspends the current task to deal with the interrupt.


Interrupt service routine: A program containing instructions for handling a specific interrupt. After execution, control returns to the interrupted process.


Purpose of Interrupts

Interrupts allow the CPU to respond to events efficiently without continuously checking for device.


They are used for:

  • inputs/output device communication

  • error handling'

  • multitasking

  • real-time processing


Examples:

  • keyboard input

  • mouse movement

  • printer completion

  • disk errors


🔹 Why Interrupts Are Needed

Without interrupts, the CPU would use:

Polling

Polling is when the CPU constantly checks devices to determine whether they require attention.

  • Interrupts improve efficiency because devices only notify the CPU when action is required


🔹 Types of Interrupts

  • Hardware interrupts

generated by hardware devices like keyboard press, mouse click, printer finished etc

  • Software interrupts

generated by software like division by zero, file request, program error etc


🔹 Interrupt Priority

each interrupt is assigned a priority level

higher priority interrupts are serviced before lower priority interrupts

this ensures that critical events are handled first


🔹 Interrupt Service Routine (ISR)

An ISR is a special program that contains the instructions required to deal with a specific interrupt

once the ISR finishes, the CPU returns to the interrupt program


🔹 Interrupt Handling Process:

  1. interrupt occurs. a device or software generates an interrupt signal.

  2. the CPU completes the current instruction. the CPU does not normally stop halfway through an instruction

  3. the current context is saved. the CPU stores PC and register content

  4. the interrupt priority is checked. the CPU determines whether the interrupt should be serviced immediately.

  5. Interrupt vector table consulted . the IVT stores the memory addresses of ISRs

  6. ISR executed . The required interrupt task is carried out

  7. context restored

  8. the original process is resumed


Context switching is the process of saving the current CPU state and later restoring it so execution can continue

The CPU state includes:

  • Program Counter

  • Registers

  • Current execution information

Context switching allows multitasking and interrupt handling


🔹 Role of the Stack During Interrupts


the stack temporarily stores PC and register values while the ISR executes.




🔹 Role of Interrupts in the FDE Cycle

At the end of each:

  1. Fetch

  2. Decode

  3. Execute

cycle,

the CPU checks whether an interrupt has occurred.

If a higher-priority interrupt exists:

  • Current context saved

  • ISR executed

  • Context restored

  • FDE cycle resumes

Interrupts therefore modify the normal sequential execution of instructions.


🔹 Advantages of Interrupts

  • More efficient than polling

  • Faster response to external events

  • Better CPU utilisation

  • Supports multitasking

  • Enables real-time processing



🔹 Disadvantages of Interrupts

  • Context switching overhead

  • Increased system complexity

  • Excessive interrupts reduce performance

  • Priority management required

  • ISR design must be efficient


Scheduling

Scheduling is the process of allocating CPU time to processes and determining the order in which processes execute

The operating system scheduler manages scheduling.


Purposes:

  • Efficient use of the CPU

  • fair resource allocation

  • multitasking

  • Good response times


Process state

Running: process currently executing on CPU

Ready: Process prepared to execute but waiting for CPU allocation

Blocked: process waiting for an external event before continuing


Ready queue

  • Stores processes that are ready to execute

  • The scheduler selects processes from the ready queue


First come first served

  • process execute in order of arrival

Advantages:

  • simple

  • low overhead

Disadvantages:

  • poor response time

  • long processes delay shorter ones

  • convoy effect possible


Round Robin

  • Each process receives a fixed time slice

When each time slice expires:

  • Timer interrupt occurs

  • context switch performed

  • Next process executes

Advantages:

  • Fair allocation

  • Good responsiveness

  • Suitable for multitasking

Disadvantages:

  • Context switching overhead

  • performance depends on time slice size


Time slice

  • The maximum amount of CPU time allocated to a process before it is pre-empted

Large time slice:

  • Fewer context switches

  • worse responsiveness

Small time slice:

  • Better responsiveness

  • More overhead


Multi-Level Feedback Queue

Uses multiple priority queues.

Processes move between queues based on behaviour and CPU usage.

Advantages:

  • Flexible

  • Prioritises interactive processes

Disadvantages:

  • Complex implementation

  • Higher overhead


🔹 Context Switching

Process of saving the state of one process and restoring another.

Saved information:

  • Program Counter

  • Registers

  • Process state

Purpose:

  • Enables multitasking

  • Allows interrupted processes to resume correctly


🔹 Scheduling and Interrupts

Timer interrupts allow pre-emptive scheduling.

When a time slice expires:

  • Interrupt generated

  • Scheduler selects next process

  • Context switch occurs


🔹 Advantages of Scheduling

  • Efficient CPU usage

  • Supports multitasking

  • Fair process allocation

  • Improves responsiveness


🔹 Disadvantages of Scheduling

  • Context switching overhead

  • Complex management

  • Poor algorithm choice reduces performance



BIOS

BIOS is a firmware stored in non-volatile memory on the motherboard. It is the first software executed when a computer starts

Functions of BIOS:

  • Initialises hardware

  • Run POST

  • Load system setting

  • Locate boot device

  • Start OS


POST(Power on self test)

A diagnostic process performed during startup to verify that hardware components are functioning correctly.

checks may include:

  • CPU

  • RAM

  • keyboard

  • storage service


Bootstrap Loader

A small program executed by the BIOS that loads the OS kernel into RAM.


Boot Sequence

  1. power on

  2. BIOS executes

  3. POST performed

  4. Hardware initialised

  5. Boot device located

  6. Bootstrap loader executed

  7. OS loaded into RAM

  8. OS takes control


DEVICE DRIVER

A device driver is system software that enables communication between the OS and specific hardware device.


Function of a device driver

  • controls hardware devices

  • translate OS commands

  • Provides an interface between OS and hardware

  • Handles communication with peripherals

  • allows hardware to be used corrctly


Why device Drivers are needed

  • Different hardware devices use different command sets

  • the OS cannot communicate directly with every device type

  • device drivers provide a standard interface and translate instructions between the OS and hardware



Virtual machines

A virtual machine is a software that emulates the functionality of a physical computer system.

It allows software, including OS, to run in a simulated environment rather than a directly on physical hardware.


Hosting OS

IS The operating system running directly on the physical machine


Guest Operating System

An OS running inside a virtual machine


Hypervisor

Is a software responsible for creating a managing VM


Functions:

  • resource allocation

  • VM management

  • Hardware abstraction


Uses of Virtual Machines

  • running multiple OS

  • Software testing

  • server consolidation

  • security isolation


🔹 Advantages of Virtual Machines

  • Reduced hardware costs

  • Improved resource utilisation

  • Flexibility

  • Safe testing environments

  • Easier deployment


🔹 Disadvantages of Virtual Machines

  • Reduced performance

  • Resource overhead

  • Increased complexity

  • Hardware sharing limitations


🔹 Intermediate Code

Intermediate code is code produced after compilation that is not yet specific machine code.


🔹 Java Virtual Machine (JVM)

A process virtual machine that executes Java bytecode.

Advantages:

  • Platform independence

  • Portability

Disadvantages:

  • Execution overhead

  • Slower than native machine code



🔹 System VM vs Process VM

System VM

Emulates an entire computer system and can run a guest operating system.

Example:

  • VirtualBox

  • VMware

Process VM

Executes a single program using intermediate code.

Example:

  • JVM