Operating Systems

Back to UWaterloo

OS must handling running many processes, uses ISR's & context switches to handle multiple processes

Requires scheduling to determine which processes run with what order and frequency

Chapter 1


User-visible registers (1 to 64 depending on architecture)

Interupts for Peripherals (ISRs)

Interrupts are mechanically similar to multiprogramming

How do you handle interrupts during an ISR?

  1. You can disable interrupts to stop nested interrupts
  1. You could have multiple interrupts going on, with priority (this gets into scheduling algorithms)

ARM fast interrupts for sequential interrupt processing uses a single jump instead of jumping back to user program before next interrupt.

Context Switching

OS creates an abstraction, running processes; instances of executing programs. Its context consists of registers, vars, program counter)

Context switch steps:

  1. Save context of CPU
  2. Schedule next process for execution
  3. Load new context of CPU

Embedded Parallel Operating System (EPOS) for labs


scheduler decides which process to run at a certain time & how long it runs

Scheduling algorithm

3 types of scheduling algorithms (high level categories)

  1. batch (payroll)
  1. realtime (deadlines)
  1. interactive (desktop)

Preemptive scheduling is the act of interrupting a task with a context switch, with the intention to resume later


Round robin uses timer interrupts

Priority scheduling runs processes in priority (static or dynamic)

First come first server (will extend priority)


Traditionally implemented with a hiearchy of abstract Scheduler classes

EPOS instead uses composition? to detach scheduling policy and data structure mechanism and criteria

epos uml


More than one program to execute

Chapter 2

Operating System

A program that controls execution of other programs to help them by acting as a standard interface between application and hardware

ulimit controls limitations within the shell and its forked processes

The OS manages computer resources. Kernel is the portion of OS that is in main memory, containing frequently used functions.

/procs/ demo

Virtual Memory uses swap disk of some form (alternative memory medium) to create the illusion of more memory


Chapter 3

How OS deals with processes, first understanding of states of processes and how to manage them.

Uniprocessor interleaves execution of processes, while multiprocessor has parallel execution of processes

How does the OS manage processes

A process is a program in execution, a unit activity with a sequence of instructions, and state

Process elements include PID, state, priority, memory pointers (shared memory blocks), context data (PSW, counter, registers), I/O status info, accounting info (process time, time limit, threads)

Process Control Block is the data structure that contains the process elements

For sharing CPU, a single processor system works as follows: task switcher triggers after timeout (quantum size, say after for example 6 instructions) or after I/O request, switch to dispatcher that switches processes


Longer quantum size means less wasted cycles on dispatcher, but lower responsiveness (longer wait time till first instruction for processes scheduled later)

Two state process model says a process is either running or not running

Processes are terminated if

Core dump