Chapter 1: Introduction
Objectives
To describe the basic organization of computer systems
To provide a grand tour of the major components of operating systems
To give an overview of the many types of computing environments
To explore several operating systems
2
What is an Operating System?
A program that acts as an intermediary between a user of a computer and
the computer hardware
Operating system goals:
Execute user programs and make solving user problems easier
Make the computer system convenient to use
Use the computer hardware in an efficient manner
3
Computer System Structure
Computer system can be divided into four components:
Hardware – provides basic computing resources
CPU, memory, I/O devices
Operating system
Controls and coordinates use of hardware among various
applications and users
Application programs – define the ways in which the system resources
are used to solve the computing problems of the users
Word processors, compilers, web browsers, database systems, video
games
Users
People, machines, other computers
4
Four Components of a Computer System
5
What Operating Systems Do
Users want convenience, ease of use and good performance
Don’t care about resource utilization
But shared computer such as mainframe or minicomputer must keep all
users happy
Users of dedicated systems such as workstations have dedicated
resources but frequently use shared resources from servers
Handheld computers are resource poor, optimized for usability and battery
life
Some computers have little or no user interface, such as embedded
computers in devices and automobiles
6
Operating System Definition
OS is a resource allocator
Manages all resources
Decides between conflicting requests for efficient and fair resource use
OS is a control program
Controls execution of programs to prevent errors and improper use of the
computer
7
Operating System Definition (Cont.)
No universally accepted definition
“Everything a vendor ships when you order an operating system” is a good
approximation
But varies wildly
“The one program running at all times on the computer” is the kernel.
Everything else is either
a system program (ships with the operating system) , or
an application program.
8
Computer Startup
Bootstrap program is loaded at power-up or reboot
Typically stored in ROM or EPROM, generally known as firmware
Initializes all aspects of system
Loads operating system kernel and starts execution
Computer-system operation
One or more CPUs, device controllers connect through common bus
providing access to shared memory
Concurrent execution of CPUs and devices competing for memory
cycles
Computer System Organization
9
Computer-System Operation
I/O devices and the CPU can execute concurrently
Each device controller is in charge of a particular device type
Each device controller has a local buffer
CPU moves data from/to main memory to/from local buffers
I/O is from the device to local buffer of controller
Device controller informs CPU that it has finished its operation by causing an
interrupt
10
Common Functions of Interrupts
Interrupt transfers control to the interrupt service routine generally, through
the interrupt vector, which contains the addresses of all the service
routines
Interrupt architecture must save the address of the interrupted instruction
A trap or exception is a software-generated interrupt caused either by an
error or a user request
An operating system is interrupt driven
Interrupt Handling
The operating system preserves the state of the CPU by storing registers
and the program counter
Determines which type of interrupt has occurred:
polling
vectored interrupt system
Separate segments of code determine what action should be taken for each
type of interrupt
11
Interrupt Timeline
12
Storage Structure
Main memory – only large storage media that the CPU can access directly
Random access: Typically volatile
Secondary storage – extension of main memory that provides large
nonvolatile storage capacity
Hard disks – rigid metal or glass platters covered with magnetic
recording material
Disk surface is logically divided into tracks, which are subdivided into sectors
The disk controller determines the logical interaction between the device and
the computer
Solid-state disks – faster than hard disks, nonvolatile
store data permanently inside an integrated circuit, typically using
flash memory.
13
Storage Hierarchy
Storage systems organized in hierarchy
Speed
Cost
Volatility
Caching – copying information into faster storage system; main memory can
be viewed as a cache for secondary storage
Device Driver for each device controller to manage I/O
Provides uniform interface between controller and kernel
14
Storage-Device Hierarchy
15
Caching
Important principle, performed at many levels in a computer (in hardware,
operating system, software)
Information in use copied from slower to faster storage temporarily
Faster storage (cache) checked first to determine if information is there
If it is, information used directly from the cache (fast)
If not, data copied to cache and used there
Cache smaller than storage being cached
Cache management important design problem
Cache size and replacement policy
16
Direct Memory Access Structure
Used for high-speed I/O devices able to transmit information at close to
memory speeds
Device controller transfers blocks of data from buffer storage directly to
main memory without CPU intervention
Only one interrupt is generated per block, rather than the one interrupt per
byte
17
How a Modern Computer Works
I/O Structure:
A device controller maintains some
local buffer storage and a set of
special-purpose registers.
The device controller is responsible for
moving the data between the
peripheral devices that it controls and
its local buffer storage.
Typically, an operating systems have a
device driver for each device controller.
This device driver understands the
device controller and provides the rest
of the operating
system with a uniform interface to the
device.
18
Real-time Scenario for (threads)?
Thread: the smallest unit of execution within a process
Gaming Applications
Scenario: Real-time rendering and game logic.
How Threads can Help:
One thread can handle graphics rendering.
A second thread manages game logic (e.g., AI/other player).
A third thread processes user inputs.
Threads ensure smooth gameplay without delays or lags
19
Computer-System Architecture
Most systems use a single general-purpose processor
Most systems have special-purpose processors as well
Multiprocessors systems growing in use and importance
Also known as parallel systems, tightly-coupled systems
Advantages include:
Increased throughput
Economy of scale
Increased reliability – graceful degradation or fault tolerance
Two types:
Asymmetric Multiprocessing – is a system architecture where each
processor is assigned a specific task and operates independently.
one processor acting as the master to coordinate the work of the others kind of
master-slave architecture.
Symmetric Multiprocessing – all processors share equal responsibility and work
collaboratively
20
Symmetric Multiprocessing Architecture
21
A Dual-Core Design
Multi-core/Dual-Core
Systems containing all chips
Chassis containing multiple separate systems
22
Multi-core vs Multi-processor?
Multi-core
A single CPU (chip) with multiple cores, where each core can execute tasks independently.
A quad-core processor has 4 cores, each capable of running its own task simultaneously.
Examples:
Intel Core i7: A CPU with 8 cores, commonly found in laptops and desktops.
AMD Ryzen 9 5900X: A 12-core CPU for gaming and productivity tasks.
Use Case:
Multicore processors are used in devices requiring parallelism for multitasking, gaming,
video editing, AI inference, and general-purpose computing.
Multi-Processor:
A system with multiple physical CPUs, each capable of executing instructions
independently. Each processor may also be multicore.
Examples:
High-Performance Servers:
A server with 2 Intel Xeon CPUs, each with 16 cores, providing a total of 32 cores
Dell PowerEdge R740 server.
Use Case:
Multiprocessor systems are used in environments requiring scalability, like data centers,
supercomputers, and high-end workstations for scientific research and real-time processing.
23
Multi-core vs Multi-processor?
Characteristics Multi-core Multi-Processor
Multiple physical CPUs in the same
Physical Chips Single CPU with multiple cores.
system.
Faster communication between cores Slower communication between
Communication
(on the same chip). processors (uses a shared bus).
More expensive due to multiple
Cost Cheaper due to a single CPU.
CPUs.
24
Clustered Systems
Like multiprocessor systems, but multiple systems working together
Usually sharing storage via a storage-area network (SAN)
Provides a high-availability service which survives failures
Asymmetric clustering has one machine in hot-standby mode
Symmetric clustering has multiple nodes running applications,
monitoring each other
Some clusters are for high-performance computing (HPC)
Applications must be written to use parallelization
Some have distributed lock manager (DLM) to avoid conflicting
operations
25
Clustered Systems
26
Operating System Structure
An operating system provides the environment within which programs are
executed.
Multiprogramming (Batch system) needed for efficiency
Single user cannot keep CPU and I/O devices busy at all times
Multiprogramming organizes jobs (code and data) so CPU always has one to
execute
A subset of total jobs in system is kept in memory
One job selected and run via job scheduling
When it has to wait (for I/O for example), OS switches to another job
27
Operating System Structure
Timesharing (multitasking) is logical extension of multiprogramming.
CPU switches jobs so frequently that users can interact with each job while it is
running, creating interactive computing
Response time should be < 1 second
Each user has at least one program executing in memory !process
If several jobs ready to run at the same time ! CPU scheduling
If processes don’t fit in memory, swapping moves them in and out to run
Virtual memory allows execution of processes not completely in memory
28
Memory Layout for Multiprogrammed System
29
Operating-System Operations
Interrupt driven (hardware and software)
Hardware interrupt by one of the devices
Software interrupt (exception or trap):
Software error (e.g., division by zero)
Request for operating system service
Other process problems include infinite loop, processes modifying
each other or the operating system
30
Operating-System Operations (cont.)
Dual-mode operation allows OS to protect itself and other system
components
User mode and kernel mode
Mode bit provided by hardware
Provides ability to distinguish when system is running user code or
kernel code
Some instructions designated as privileged, only executable in
kernel mode
System call changes mode to kernel, return from call resets it to user
Increasingly CPUs support multi-mode operations
i.e. virtual machine manager (VMM) mode for guest VMs
31
Transition from User to Kernel Mode
32
Operating-System Operations (cont.)
Feature/Aspect User Mode Kernal Mode
Privilege Level Low privilege (restricted access). High privilege (full system access).
No direct hardware access; must use system calls to Direct access to hardware (CPU, memory,
Access to Hardware
interact with hardware. devices).
Access to all memory, including user and
Memory Access Access is restricted to the process's memory space.
system memory.
Executes system calls and manages
System Calls Must invoke system calls to request kernel services.
hardware directly.
Execution Scope Executes application code. Executes critical OS code and services.
Managing les, memory, I/O, process
Examples of Operations Running applications (e.g., browsers, text editors).
scheduling, and device drivers.
33
fi
Privileged Instructions?
Privileged Instructions are special instructions that can only be executed in kernel mode
(also called supervisor mode or system mode) of an operating system.
These instructions have a direct impact on the hardware or the operating system itself.
Potentially harm the system's stability or security if executed by an unprivileged user program
Examples:
I/O Operations:
Directly accessing hardware devices, such as reading or writing to I/O ports or controlling
disk drives.
Example: Initiating a disk read/write operation.
Setting or Changing System Configuration:
Modifying the CPU mode, enabling or disabling interrupts, or altering memory settings.
Example: Changing the base address of a page table.
Interrupt Management:
Enabling, disabling, or servicing interrupts.
Example: cli (clear interrupt flag) and sti (set interrupt flag) instructions in x86
processors.
34
Real-time Scenarios?
User Mode
Running a web browser.
Playing a video game.
Editing a document in Microsoft Word.
These applications request system services (e.g., file saving,
network access) via system calls
Kernel Mode
Handling disk I/O when a file is saved.
Managing memory allocation when an application starts.
Scheduling processes to ensure multitasking.
35
A View of Operating System Services
36
Process Management
A process is a program in execution.
Program is a passive entity, process is an active entity.
Process needs resources to accomplish its task
CPU, memory, I/O, files
Initialization data
Process termination requires reclaim of any reusable resources
Single-threaded process has one program counter specifying location of next
instruction to execute
Process executes instructions sequentially, one at a time, until completion
Multi-threaded process has one program counter per thread
Typically system has many processes, some user, some operating system running
concurrently on one or more CPUs
Concurrency by multiplexing the CPUs among the processes / threads
37
Process Management Activities
The operating system is responsible for the following activities in connection
with process management:
Creating and deleting both user and system processes
Suspending and resuming processes
Providing mechanisms for process synchronisation
Providing mechanisms for process communication
Providing mechanisms for deadlock handling
38
Memory Management
To execute a program all (or part) of the instructions must be in memory
All (or part) of the data that is needed by the program must be in memory.
Memory management determines what is in memory and when
Optimizing CPU utilization and computer response to users
Memory management activities
Keeping track of which parts of memory are currently being used and by
whom
Deciding which processes (or parts thereof) and data to move into and
out of memory
Allocating and deallocating memory space as needed
39
Storage Management
OS provides uniform, logical view of information storage
Abstracts physical properties to logical storage unit - file
Each medium is controlled by device (i.e., disk drive, tape drive)
Varying properties include access speed, capacity, data-transfer rate,
access method (sequential or random)
File-System management
Files usually organized into directories
Access control on most systems to determine who can access what
OS activities include
Creating and deleting files and directories
Primitives to manipulate files and directories
Mapping files onto secondary storage
Backup files onto stable (non-volatile) storage media
40
Mass-Storage Management
Usually disks used to store data that does not fit in main memory or data that
must be kept for a “long” period of time
Proper management is of central importance
Entire speed of computer operation hinges on disk subsystem and its
algorithms
OS activities
Free-space management
Storage allocation
Disk scheduling
Some storage need not be fast
Tertiary storage includes optical storage, magnetic tape
Still must be managed – by OS or applications
Varies between WORM (write-once, read-many-times) and RW (read-
write)
41
Migration of data “A” from Disk to Register
Multitasking environments must be careful to use most recent value, no
matter where it is stored in the storage hierarchy
Multiprocessor environment must provide cache coherency in hardware
such that all CPUs have the most recent value in their cache
Distributed environment situation even more complex
Several copies of a datum can exist
42
I/O Subsystem
One purpose of OS is to hide peculiarities of hardware devices from the user
I/O subsystem responsible for
Memory management of I/O including buffering (storing data temporarily
while it is being transferred), caching (storing parts of data in faster
storage for performance), spooling (the overlapping of output of one job
with input of other jobs)
General device-driver interface
Drivers for specific hardware devices
43
Protection and Security
Protection – any mechanism for controlling access of processes or
users to resources defined by the OS
Security – defense of the system against internal and external attacks
Huge range, including denial-of-service, worms, viruses, identity
theft, theft of service
Systems generally first distinguish among users, to determine who can
do what
User identities (user IDs, security IDs) include name and associated
number, one per user
User ID then associated with all files, processes of that user to
determine access control
Group identifier (group ID) allows set of users to be defined and
controls managed, then also associated with each process, file
Privilege escalation allows user to change to effective ID with more
rights
44
Operating System Services
Operating systems provide an environment for execution of programs and services to
programs and users
One set of operating-system services provides functions that are helpful to the user:
User interface - Almost all operating systems have a user interface (UI).
Varies between Command-Line (CLI), Graphics User Interface (GUI),
Batch
Program execution - The system must be able to load a program into memory
and to run that program, end execution, either normally or abnormally (indicating
error)
I/O operations - A running program may require I/O, which may involve a file or
an I/O device
45
Bourne Shell Command Interpreter
46
User Operating System Interface - GUI
User-friendly desktop metaphor interface
Usually mouse, keyboard, and monitor
Icons represent files, programs, actions, etc
Various mouse buttons over objects in the interface cause various actions
(provide information, options, execute function, open directory (known as a
folder)
Invented at Xerox PARC
Many systems now include both CLI and GUI interfaces
Microsoft Windows is GUI with CLI “command” shell
Apple Mac OS X is “Aqua” GUI interface with UNIX kernel underneath and
shells available
Unix and Linux have CLI with optional GUI interfaces (CDE, KDE, GNOME)
47
Touchscreen Interfaces
Touchscreen devices require new
interfaces
Mouse not possible or not desired
Actions and selection based on
gestures
Virtual keyboard for text entry
Voice commands.
48
The Mac OS X GUI
49
System Calls
A system call is a mechanism that allows user-level programs to request
services from the operating system kernel.
It acts as an interface between user applications and the OS.
Typically written in a high-level language (C or C++)
Mostly accessed by programs via a high-level Application Programming
Interface (API) rather than direct system call use
Three most common APIs are Win32 API for Windows, POSIX API for
POSIX-based systems (including virtually all versions of UNIX, Linux, and
Mac OS X), and Java API for the Java virtual machine (JVM)
50
Why Are System Calls Needed?
User programs run in user mode, where they have limited access
to hardware and system resources.
To perform privileged operations (like accessing files, allocating
memory, or interacting with hardware), programs must use system
calls, which execute in kernel mode.
For example:
A program cannot directly access disk storage; it must use a
system call like read() or write().
A program cannot directly create processes; it must use
fork().
51
Example of System Calls
System call sequence to copy the contents of one file to another file
52
Example of Standard API
53
System Call Implementation
Typically, a number associated with each system call
System-call interface maintains a table indexed according to these
numbers
The system call interface invokes the intended system call in OS kernel and
returns status of the system call and any return values
The caller need not to know anything about how the system call is
implemented
Just needs to obey API and understand what OS will do as a result call
Most details of OS interface hidden from programmer by API
Managed by run-time support library (set of functions built into
libraries included with compiler)
54
API – System Call – OS Relationship
55
API – System Call – OS Relationship
APIs act as wrappers around system calls to simplify their use.
When an application calls an API function (e.g., fopen("file.txt", "r"))
the API internally calls the relevant system call (sys_open() in Linux).
The OS kernel processes the system call and returns the result to the API,
which then gives it back to the application.
56
System Call Parameter Passing
Often, more information is required than simply identity of desired system call
Exact type and amount of information vary according to OS and call
Three general methods used to pass parameters to the OS
Simplest: pass the parameters in registers
In some cases, may be more parameters than registers
Parameters stored in a block, or table, in memory, and address of block
passed as a parameter in a register
This approach taken by Linux and Solaris
Parameters placed, or pushed, onto the stack by the program and
popped off the stack by the operating system
Block and stack methods do not limit the number or length of parameters
being passed
57
Types of System Calls
Process control
create process, terminate process
end, abort
load, execute
get process attributes, set process attributes
wait for time
wait event, signal event
allocate and free memory
Dump memory if error
Debugger for determining bugs, single step execution
Locks for managing access to shared data between processes
58
Types of System Calls
File management
create file, delete file
open, close file
read, write, reposition
get and set file attributes
Device management
request device, release device
read, write, reposition
get device attributes, set device attributes
logically attach or detach devices
59
Types of System Calls (Cont.)
Information maintenance
get time or date, set time or date
get system data, set system data
get and set process, file, or device attributes
Communications
create, delete communication connection
send, receive messages if message passing model to host name or
process name
From client to server
Shared-memory model create and gain access to memory regions
transfer status information
attach and detach remote devices
Protection
Control access to resources
Get and set permissions
Allow and deny user access
60
Examples of Windows and Unix System Calls
61
Operating System Structure
General-purpose OS is very large program
Various ways to structure ones
Simple structure – MS-DOS
More complex -- UNIX
Layered – an abstraction
Microkernel -Mach
62
Simple Structure -- Monolithic
A monolithic OS is an operating system where the entire kernel runs in a
single address space with all essential services tightly integrated.
This structure provides high performance but can be complex and difficult to
maintain.
Characteristics
Single Large Kernel – All OS services (e.g., file system, memory
management, I/O, device drivers) reside in the kernel.
Direct Communication – Functions communicate via direct procedure
calls, making execution faster.
Fast Execution – Since all components operate in kernel mode, there are
minimal context switches.
Difficult to Modify – Any change to the system (e.g., adding a new
feature) requires recompiling the entire kernel.
Examples: Linux (Most distributions), Unix (Traditional versions), MS-DOS
(Old single-user systems), Windows 9x (95, 98, ME)
63
Simple Structure -- MS-DOS
MS-DOS – written to provide the most
functionality in the least space.
Application programs are able to access
the basic I/O routines to write directly to
the display and disk drives.
leaves MS-DOS vulnerable to errant (or
malicious) programs
Not divided into modules
Although MS-DOS has some
structure, its interfaces and levels of
functionality are not well separated
64
Non Simple Structure -- UNIX
UNIX – limited by hardware functionality, the original UNIX operating system
had limited structuring.
The UNIX OS consists of two separable parts
Systems programs
The kernel
Consists of everything below the system-call interface and above the
physical hardware
Provides the file system, CPU scheduling, memory management, and
other operating-system functions; a large number of functions for one
level
65
Traditional UNIX System Structure
Beyond simple but not fully layered
66
Layered Approach
The operating system is divided into a
number of layers (levels), each built
on top of lower layers. The bottom
layer (layer 0), is the hardware; the
highest (layer N) is the user interface.
With modularity, layers are selected
such that each uses functions
(operations) and services of only
lower-level layers.
problem with layered implementations
is that they tend to be less efficient
than other types.
67
What’s the Layered Approach for I/O looks like?
User Interface Layer: User requests I/O operations through GUI/CLI
(GUI/CLI: File Explorer, Terminal, Browser)
Application Layer: Applications use APIs for I/O operations.
Programs use APIs: fopen(), read(), printf().
System Call Interface (SCI) Layer : Converts API requests into system calls
(System Calls: sys_read(), sys_write())
I/O Subsystem Layer : Manages file systems, buffering, and scheduling
(Virtual File System, Buffering)
Device Driver Layer: Translates I/O requests into low-level hardware commands
(Disk Driver, Network Driver, Printer Driver)
Hardware Layer: The physical device executes the operation
(HDD, SSD, Network Adapter, USB Devices)
68
Microkernel System Structure
Moves as much from the kernel into user space
Mach example of microkernel
Mac OS X kernel (Darwin) partly based on Mach
Removed all nonessential components from the kernel and implementing
them as system and user-level programs.
The result is a smaller kernel.
Communication takes place between user modules using message passing
Benefits:
Easier to extend a microkernel
Easier to port the operating system to new architectures
More reliable (less code is running in kernel mode)
More secure
Detriments:
Performance overhead of user space to kernel space communication
69
Microkernel System Structure
70
Modules
Many modern operating systems implement loadable kernel modules
Uses object-oriented approach
Each core component is separate
Each talks to the others over known interfaces
Each is loadable as needed within the kernel
Overall, similar to layers but with more flexible
Linux, Solaris, etc
71
Solaris Modular Approach
72
Hybrid Systems
Most modern operating systems are actually not one pure model
Hybrid combines multiple approaches to address performance, security,
usability needs
Linux and Solaris kernels in kernel address space, so monolithic, plus
modular for dynamic loading of functionality
Windows mostly monolithic, plus microkernel for different subsystem
personalities
Apple Mac OS X hybrid, layered, Aqua UI plus Cocoa programming
environment
Below is kernel consisting of Mach microkernel and BSD Unix parts, plus
I/O kit and dynamically loadable modules (called kernel extensions)
73
Mac OS X Structure
74
iOS
Apple mobile OS for iPhone, iPad
Structured on Mac OS X, added functionality
Does not run OS X applications natively
Also runs on different CPU architecture
(ARM vs. Intel)
Cocoa Touch Objective-C API for developing
apps
Media services layer for graphics, audio, video
Core services provides cloud computing,
databases
Core operating system, based on Mac OS X
kernel
75
Android
Developed by Open Handset Alliance (mostly Google)
Open Source
Similar stack to IOS
Based on Linux kernel but modified
Provides process, memory, device-driver management
Adds power management
Runtime environment includes core set of libraries and Dalvik virtual machine
Apps developed in Java plus Android API
Java class files compiled to Java bytecode then translated to
executable than runs in Dalvik VM
Libraries include frameworks for web browser (webkit), database (SQLite),
multimedia, smaller libc
76
Android Architecture
77
Summary
Definition of OS and its Functions
Components of Computer Systems, Architecture and Organization
System Calls
Structures of different type of OS