CSC 553 Operating Systems
CSC 553 Operating Systems
Memory
System interconnect
translation Hardware
(bus)
I/O devices
Main
and
memory
networking
Programs
and Data
I/O Controller
Processor Processor
Storage
OS
Programs
Data
New services
Fixes
Evolution of
Operating Systems
Time
Sharing
Multiprogrammed Systems
Batch Systems
Simple Batch
Systems
Serial
Processing
Serial Processing – Earliest
Computers
• No operating system
– Programmers interacted directly with the
computer hardware
• Computers ran from a console with display
lights, toggle switches, some form of input
device, and a printer
• Users have access to the computer in
“series”
• Setup time
– A considerable amount of time was spent on
setting up the program to run
Simple Batch Systems
• Early computers were very expensive
– Important to maximize processor utilization
• Monitor
– User no longer has direct access to processor
– Job is submitted to computer operator who
batches them together and places them on an
input device
– Program branches back to the monitor when
finished
memory
• Monitor reads in job User
Program
Area
and gives control
• Job returns control to
monitor Figure 2.3 Memory Layout for a Resident Monitor
Processor Point of View
• Processor executes instruction from the memory
containing the monitor
• Executes the instructions in the user program until
it encounters an ending or error condition
• “Control is passed to a job” means processor is
fetching and executing instructions in a user
program
• “Control is returned to the monitor” means that
the processor is fetching and executing
instructions from the monitor program
• While the user program is executing, it must not alter the memory area
containing the monitor
Timer
Privileged instructions
Interrupts
Modes of Operation
I/O devices
are slow
compared to
processor
Even with
automatic
job
sequencing
Processor is often
idle
System Utilization
Read one record from file 15 µs
Execute 100 instructions 1 µs
Write one record to file 15 µs
TOTAL 31 µs
1
Percent CPU Utilization = = 0.032 = 3.2%
31
Uniprogramming
Time
(a) Uniprogramming
Multiprogramming
Program A Run Wait Run Wait
Effects of Multiprogramming on
Resource Utilization
Uniprogramming Multiprogramming
Processor use 20% 40%
Memory use 33% 67%
Disk use 33% 67%
Printer use 33% 67%
Elapsed time 30 min 15 min
Throughput 6 jobs/hr 12 jobs/hr
Mean response time 18 min 10 min
Utilization Histograms for
Uniprogramming and Multiprogramming
100% 100%
CPU CPU
0% 0%
100% 100%
Memory Memory
0% 0%
100% 100%
Disk Disk
0% 0%
100% 100%
Terminal Terminal
0% 0%
100% 100%
Printer Printer
0% 0%
time 0 5 10 15
minutes
time
(a) Uniprogramming (b) Multiprogramming
Time-Sharing Systems
• Can be used to handle multiple interactive
jobs
• Processor time is shared among multiple
users
• Multiple users simultaneously access the
system through terminals, with the OS
interleaving the execution of each user
program in a short burst or quantum of
computation
Batch Multiprogramming vs Timesharing
0 0 0
Monitor Monitor Monitor
5000 5000 5000
JOB 4
JOB 1
15000 JOB 2
(JOB 1)
20000 20000
(JOB 2) (JOB 2)
25000 25000 25000
Free Free Free
32000 32000 32000
(d) (e) (f)
Major Achievements
• Operating Systems are among the most
complex pieces of software ever developed
• Major advances in development include:
– Processes
– Memory management
– Information protection and security
– Scheduling and resource management
– System structure
Process
• Fundamental to the structure of operating
systems
A program in execution
Causes of Errors
• Improper synchronization
– It is often the case that a routine must be
suspended awaiting an event elsewhere in the
system
– Improper design of the signaling mechanism
can result in loss or duplication
Causes of Errors
Causes of Errors
• Deadlocks
– It is possible for two or more
programs to be hung up waiting for
each other
Components of a Process
Process Main
Memory
Processor
Registers
Process index i
Management i
PC
Process Base b
list Limit h
Other
registers
process at any instant is
Context
contained in its context Process Data
h Data
the context to include any B
Program
(code)
new information needed to
support the feature
Figure 2.8 Typical Process Implementation
Memory Management
• The OS has five principal storage
management responsibilities:
Automatic Support of
Process Protection and Long-term
allocation and modular
isolation access control storage
management programming
Virtual Memory
A.1
A.0 A.2
0 0
A.5
1 1
2 2
B.0 B.1 B.2 B.3
3 3
4 4
5 5
6 6
A.7
7 User
A.9
8 program
B
9
A.8
10
User
program
A
B.5 B.6
Disk
Address
Secondary
Memory
involves controlling
access to computer Data integrity
systems and the
information stored in
them
Scheduling and Resource Management
• Key responsibility
of an OS is
managing Efficiency
Fairness
resources
• Resource
allocation policies Differential
responsiveness
must consider:
Operating System
Service Call Service
from Process Call
Handler (code)
Pass Control
to Process
Microkernel Architecture
• Assigns only a few essential functions to the
kernel:
Address Interprocess
Basic
space communication
scheduling
management (IPC)
• The approach:
Well suited to a
Simplifies Provides
distributed
implementation flexibility
environment
Multithreading
• Technique in
which a
Thread Process
process,
A collection of one or
executing an Dispatchable unit of
work
more threads and
associated system
resources
application,
is divided Includes a processor
By breaking a single
application into
context and its own
into threads data area for a stack
multiple threads, a
programmer has
greater control over
that can run the modularity of the
application and the
timing of application-
concurrently Executes sequentially related events
and is interruptible
SMP Advantages
Process 1
Process 2
Process 3
Process 1
Process 2
Process 3
Blocked Running
OS Design
• Object-Oriented Design
– Lends discipline to the process of adding
modular extensions to a small kernel
– Enables programmers to customize an
operating system without disrupting system
integrity
– Also eases the development of distributed tools
and full-blown distributed operating systems
Fault Tolerance
• Refers to the ability of a system or component to
continue normal operation despite the presence of
hardware or software faults
• Typically involves some degree of redundancy
• Intended to increase the reliability of a system
– Typically comes with a cost in financial terms or
performance
• The extent adoption of fault tolerance measures
must be determined by how critical the resource is
Fundamental Concepts
• The basic measures are:
– Reliability
• R(t)
• Defined as the probability of its correct
operation up to time t given that the
system was operating correctly at time
t=0
Fundamental Concepts
• The basic measures are:
– Mean time to failure (MTTF)
• Mean time to repair (MTTR) is the
average time it takes to repair or
replace a faulty element
Fundamental Concepts
• The basic measures are:
– Availability
• Defined as the fraction of time the
system is available to service users’
requests
Availability Classes
Class Availability Annual Downtime
Continuous 1.0 0
Fault Tolerant 0.99999 5 minutes
Fault Resilient 0.9999 53 minutes
High Availability 0.999 8.3 hours
Normal Availability 0.99 - 0.995 44-87 hours
Faults
• Are defined by the IEEE Standards
Dictionary as an erroneous hardware or
software state resulting from:
– Component failure
– Operator error
– Physical interference from the environment
– Design error
– Program error
– Data structure error
Faults
• The standard also states that a fault
manifests itself as:
– A defect in a hardware device or component
– An incorrect step, process, or data definition in
a computer program
Fault Categories
• Permanent
– A fault that, after it occurs, is always
present
– The fault persists until the faulty
component is replaced or repaired
Fault Categories
• Temporary
– A fault that is not present all the time for all
operating conditions
– Can be classified as
• Transient – a fault that occurs only once
• Intermittent – a fault that occurs at multiple,
unpredictable times
Methods of Redundancy
Symmetric Multiprocessor OS
Considerations
• A multiprocessor OS must provide all the
functionality of a multiprogramming system plus
additional features to accommodate multiple
processors
• Key design issues:
– Simultaneous concurrent processes or threads
– Scheduling
– Synchronization
– Memory Management
– Reliability and Fault Tolerance
Symmetric Multiprocessor OS
Considerations
• Simultaneous concurrent processes or
threads:
– Kernel routines need to be reentrant to allow
several processors to execute the same kernel
code simultaneously
Symmetric Multiprocessor OS
Considerations
• Scheduling:
– Any processor may perform scheduling, which
complicates the task of enforcing a scheduling
policy
Symmetric Multiprocessor OS
Considerations
• Synchronization:
– With multiple active processes having potential
access to shared address spaces or shared I/O
resources, care must be taken to provide
effective synchronization
Symmetric Multiprocessor OS
Considerations
• Memory management:
– The reuse of physical pages is the biggest
problem of concern
Symmetric Multiprocessor OS
Considerations
• Reliability and Fault Tolerance:
– The OS should provide graceful degradation in
the face of processor failure
Multicore OS Considerations
• The design challenge
for a many-core
multicore system is to
efficiently harness the Hardware parallelism within each
core processor, known as
multicore processing instruction level parallelism
power and intelligently
manage the substantial Potential for multiprogramming
and multithreaded execution
on-chip resources within each processor
efficiently
Potential for a single application
• Potential for to execute in concurrent
processes or threads across
parallelism exists at multiple cores
three levels:
Grand Central Dispatch (GCD)
• Is a multicore support capability
– Once a developer has identified something that
can be split off into a separate task, GCD makes
it as easy and noninvasive as possible to
actually do so
• In essence, GCD is a thread pool
mechanism, in which the OS maps tasks
onto threads representing an available
degree of concurrency
Trap
Libraries
User Level
Inter-process
communication
File Subsystem
Process
Control Scheduler
Subsystem
Memory
Buffer Cache
management
character block
Device Drivers Kernel Level
Hardware Control
Hardware Level
exec
switch
NFS
file mappings
FFS
virtual
device memory vnode/vfs
mappings framework interface
s5fs
anonymous RFS
mappings
Common
Facilities
network tty
driver driver
System V Release 4 (SVR4)
BSD
• Berkeley Software Distribution
• 4.xBSD is widely used in academic
installations and has served as the basis of a
number of commercial UNIX products
• 4.4BSD was the final version of BSD to be
released by Berkeley
BSD
• There are several widely used, open-source
versions of BSD:
– FreeBSD
• Popular for Internet-based servers and
firewalls
• Used in a number of embedded
systems
BSD
• There are several widely used, open-source
versions of BSD:
– NetBSD
• Available for many platforms
• Often used in embedded systems
– OpenBSD
• An open-source OS that places special
emphasis on security
Solaris 11
• Oracle’s SVR4-based UNIX release
• Provides all of the features of SVR4 plus a
number of more advanced features such as:
– A fully preemptable, multithreaded kernel
– Full support for SMP
– An object-oriented interface to file systems