Introduction to Operating Systems • ABI (Application Binary Interface):
Ensures programs can run across systems.
What is an Operating System (OS)?
• API (Application Program Interface): Lets
• An OS is the main software that lets a programs use OS functions easily.
computer work.
OS as a Resource Manager
• It manages:
o The hardware (CPU, memory, • Like other software, the OS uses the
storage, input/output devices processor to run.
like keyboard, printer, etc.). • It decides how CPU time and resources
o The software (programs and files are shared among tasks.
installed).
• It acts as a middleman between the user, Why Operating Systems Change
the programs, and the hardware. • New hardware (faster CPUs, bigger
• Core parts include: storage).
o Kernel (heart of the OS, directly • New services (better networking,
talks to hardware). multitasking).
o System libraries (ready-made • Fixes to old problems (bugs, security).
code to help programs).
o Admin tools (settings, Evolution of Operating Systems
monitoring, etc.).
1. Serial Processing (1940s–1950s)
Objectives of an OS
• No OS yet. Programmers worked directly
1. Make the computer convenient to use. with hardware.
2. Use resources like CPU and memory • Used console with lights, switches, card
efficiently. readers.
3. Allow development and testing of new • Problems:
software easily. o Scheduling: People reserved
time but wasted CPU cycles.
Functions of an OS
o Setup time: Long manual setup
The OS provides services in different areas: before a program could run.
• Program development: Gives tools like 2. Simple Batch Systems (1950s)
text editors and debuggers.
• Program execution: Loads programs into • Jobs grouped and run in batches.
memory, schedules them, and runs them. • Used a monitor program to load jobs
• Access to I/O devices: Simplifies device automatically.
usage (you don’t need to know every • Reduced wasted time.
hardware detail).
3. Multiprogrammed Batch Systems
• File access control: Protects and organizes
files. • Multiple jobs kept in memory.
• System resource access: Controls who can • CPU chooses which one to run next using
use what resource. scheduling algorithms.
• Error detection/response: Detects • Improved efficiency.
hardware or software failures and
4. Time-Sharing Systems
recovers.
• Performance monitoring: Tracks usage • Many users share the same computer at
like CPU time for improvements. once.
• ISA (Instruction Set Architecture): Defines • CPU divides time into small slices
machine instructions. (quanta) for fairness.
• Example: CTSS at MIT. 4. User apps (EXE, DLL).
Examples of Operating Systems Classic UNIX
Microsoft Windows • Developed at Bell Labs, later rewritten in
C.
• Started as an extension of MS-DOS. • Three levels:
• Separates: 1. User level (programs, libraries).
o Kernel-mode (low-level: 2. Hardware level.
Windows Executive, Kernel, 3. System kernel (core operations).
drivers, HAL). • Uses a shell for commands.
o User-mode (apps, subsystems).
• Weakness: only supports single processor
• Modular → parts can be updated without well, limited code reuse.
rewriting everything.
Modern UNIX
Kernel Components:
• More modular design.
• I/O Manager → controls input/output • Example: System V Release 4 (SVR4).
devices. • Features:
• Cache Manager → keeps frequently used o Real-time processing.
files in memory. o Better scheduling.
• Object Manager → handles processes, o Virtual memory.
threads, etc. o Virtual file system.
• Plug-and-Play Manager → loads drivers o Works on 32-bit CPUs up to
automatically. supercomputers.
• Power Manager → controls device
power/sleep. Linux
• Security Reference Monitor → enforces • Started by Linus Torvalds in 1991.
file and process security. • Open-source, free, and UNIX-like.
• Virtual Memory Manager → handles RAM • Very modular → runs on phones to
and disk swapping. supercomputers.
• Process/Thread Manager → manages • Uses loadable modules:
running tasks. o Dynamic linking: add/remove
• Config Manager → manages system modules without rebooting.
registry. o Stackable modules: arranged in
• ALPC → communication between hierarchy, reused by others.
processes.
• Kernel → schedules processes, handles Kernel Components:
interrupts.
• Signals
• HAL → hides hardware details so OS
• System calls
works on many computers.
• Process & scheduler
• Device Drivers → software that lets
• Virtual memory
hardware work.
• File systems
• Windowing/Graphics → GUI system.
• Network protocols
User-Mode Processes: • Device drivers (character, block, network)
• Traps, faults, interrupts, physical memory
1. Special system processes (log-in,
services).
2. Service processes (background tasks).
3. Environment subsystems (POSIX, Win32).
Android Processes
• Based on Linux, made for mobile. What is a Process?
• Smaller kernel (removes unneeded
A process is more than just a program. It is the
drivers).
actual running instance of a program along with all
• Provides core services: memory, security,
the things it needs to work. Depending on context,
drivers, networking.
a process can mean:
• Started by Android, Inc., later acquired by
• A program that is actively executing.
Google (2005).
• A single instance of a program running on
• Supported by AOSP (Android Open
the computer.
Source Project) community.
• A unit of activity that executes
instructions, maintains a current state,
and uses system resources.
• An environment where a program runs
with code and data.
Every process has two main elements:
1. Program code (can be shared if multiple
processes run the same program).
2. Data (specific to that process).
Modern operating systems can manage
thousands of processes at once.
Elements of a Process
Each process can be described by the following
elements:
• Identifier – Unique ID number.
• Process State – The current activity of the
process:
o New – Being created.
o Ready – Waiting for CPU.
o Running – Currently executing.
o Waiting – Waiting for an event
(like I/O).
o Terminated – Finished.
• Priority – Its importance compared to
other processes.
• Program Counter – Address of the next
instruction.
• Memory Pointers – Addresses of code,
data, and shared blocks.
• Context Data – Register values while
executing.
• I/O Status Information – Devices used,
I/O requests.
• Accounting Information – CPU time used,
clock time, limits.
These are all stored in the Process Control Suspended Processes
Block (PCB).
Some processes are placed in a suspended state:
• The PCB allows the OS to pause a process • They are not immediately available for
and later resume it exactly where it left execution.
off. • A suspended process may or may not be
waiting for an event.
• This is key for multitasking and
• Being blocked is separate from being
multiprocessing.
suspended.
Process State Models A process can be suspended by:
1. Itself.
Two-State Model 2. Its parent process.
3. The operating system.
• Only has:
1. Running Process Description
2. Not Running
• OS selects a process to run; the others The OS manages all processes and resources. It:
wait in a queue. • Schedules processes for execution.
• Queue is usually FIFO (first-in, first-out). • Allocates resources (CPU, memory, I/O).
• Limitation: doesn’t distinguish between • Keeps track of process states and
“ready but waiting for CPU” and “blocked resources using tables.
waiting for I/O.” OS Tables
Five-State Model 1. Memory Tables – Track memory
Improves on the two-state model with more allocation, protection attributes, and
detailed states: virtual memory info.
• New – Just created, not yet admitted. 2. I/O Tables – Track input/output devices
• Ready – Waiting for CPU time. and usage.
• Running – Currently using CPU. 3. File Tables – Store file information and
attributes.
• Blocked/Waiting – Paused until an event
4. Process Tables – Contain details for
finishes (like I/O).
managing processes.
• Exit – Process completed or terminated.
Process Location
Possible transitions include:
• A process always includes its program and
• Null → New
data (local/global variables, constants).
• New → Ready
• Stored in memory (RAM or secondary
• Ready → Running
storage).
• Running → Ready
• The process image (program + data +
• Running → Blocked
PCB) can be stored as a continuous block
• Running → Exit
in disk.
• Blocked → Ready
• To run it, the OS loads it into RAM or
• Ready → Exit
virtual memory.
• Blocked → Exit
This model is more efficient because it
separates processes that are simply waiting for
CPU vs. those waiting for something else.
Process Attributes Process Termination
Grouped into 3 categories: Ways a process ends:
1. Identification – Process IDs, table indexes, • Batch job – finishes with a halt instruction
cross-references. (generates an interrupt).
2. Processor State Information – Contents • Interactive program – ends when user
of CPU registers. Must be saved if process performs a terminating action.
is interrupted. • Parent-child relationship – Parent can
3. Process Control Information – Scheduling terminate its children; if parent ends,
details, resource ownership, privileges. children often end too.
All of this is contained in the PCB, which is
central to process management.
Process Control
Modes of Execution
• User Mode – Less-privileged. Used for
normal programs.
• Kernel Mode – More-privileged. OS runs
here with full access to CPU, memory,
devices.
Protects OS and key data (like PCBs) from being
altered by user programs.
Process Creation
When OS creates a new process, it:
1. Assigns a unique process ID.
2. Allocates memory space.
3. Initializes the PCB.
4. Sets linkages in tables.
5. Creates/expands other needed structures.
Process Switching
OS may switch processes when:
• A process is blocked.
• A process is suspended.
• A higher-priority process needs the CPU.
Mechanisms:
• Interrupts – External events (e.g., timer,
I/O).
• Traps – Internal errors or exceptions.
• Supervisor calls – Explicit requests from
processes for OS services.