CSC 553 Operating Systems: Lecture 1-Computer System
CSC 553 Operating Systems: Lecture 1-Computer System
Operating System
• Exploits the hardware resources of one or
more processors
• Provides a set of services to system users
• Manages secondary memory and I/O
devices
Basic Elements
I/O
Processor Modules
Main System
Memory Bus
Processor
Referred to as the
Central
Processing Unit
(CPU)
Main Memory
• Stores data and programs
• Typically volatile
– Contents of the memory is lost when the
computer is shut down
• Referred to as real memory or primary
memory
I/O Modules
Secondary
memory devices
(e.g. disks)
Move data
between the
Communications
computer and its equipment
external
environment
Terminals
System Bus
I/O AR
Data
Execution
unit Data
I/O BR Data
Data
PC = Program counter
Buffers IR = Instruction register
MAR = Memory address register
MBR = Memory buffer register
I/O AR = Input/output address register
I/O BR = Input/output buffer register
Graphical Processing
Units (GPU’s)
– Provide efficient computation on arrays of data
using Single-Instruction Multiple Data (SIMD)
techniques pioneered in supercomputers
– No longer used just for rendering advanced
graphics
• Also used for general numerical processing
» Physics simulations for games
» Computations on large spreadsheets
Digital Signal Processors (DSPs)
– Deal with streaming signals such as audio or
video
– Used to be embedded in I/O devices like
modems
–Are now becoming first-class
computational devices, especially in
handhelds
– Encoding/decoding speech and video
(codecs)
– Provide support for encryption and security
Processor reads
Processor executes
(fetches) instructions
each instruction
from memory
Two steps
1 4
I/O
Command
WRITE
Flow of 5
END
Control 2
Without WRITE
Interrupts
3
WRITE
(a) No interrupts
User I/O
Program Program
1 4
I/O
Command
WRITE
2a
Interrupt
Short I/O Wait 2b Handler
WRITE 5
END
3a
3b
WRITE
1 4
I/O
Command
WRITE
Interrupt
Handler
WRITE 5
END
WRITE
i
Interrupt
occurs here i+1
Interrupts
Disabled
Check for
Fetch next Execute interrupt;
START instruction instruction initiate interrupt
Interrupts
handler
Enabled
HALT
Time
1 1
4 4
I/O operation
I/O operation;
processor waits 2a concurrent with
processor executing
5 5
2b
2
4
I/O operation
4 3a concurrent with
processor executing
I/O operation;
processor waits 5
5 3b
4 4
5
2
4
4
3 I/O operation
concurrent with
I/O operation; processor executing;
processor waits then processor
waits
5
5
Hardware Software
Device controller or
other system hardware
issues an interrupt
Save remainder of
process state
information
Processor finishes
execution of current
instruction
Process interrupt
Processor signals
acknowledgment
of interrupt
Restore process state
information
Processor pushes PSW
and PC onto control
stack
Restore old PSW
and PC
Processor loads new
PC value based on
interrupt
Y Start Y Start
Interrupt General Interrupt General
Service Registers Service Registers
Y + L Return Routine T Y + L Return Routine T–M
Stack Stack
Pointer Pointer
Processor Processor
T–M T
N User's N User's
N+1 N+1
Program Program
Main Main
Memory Memory
Multiple Interrupts
An interrupt occurs
while another interrupt Two approaches:
is being processed
• e.g. receiving data • Disable interrupts
from a while an interrupt is
communications line being processed
and printing results at • Use a priority scheme
the same time
Interrupt
User Program Handler X
Interrupt
Handler Y
Interrupt
User Program Handler X
Interrupt
Handler Y
Printer Communication
User Program
interrupt service routine interrupt service routine
t=0
15
10 t=
t=
t = 25
t= t = 25 Disk
40 interrupt service routine
t=
35
Memory Relationships
Greater capacity =
Faster access smaller cost per
time = bit
greater cost Greater capacity
per bit = slower access
speed
The Memory Hierarchy
Going down the g-
Re rs
ist
e
hierarchy: I nb
Me oard
mo
ry
Ca
ch
e
in
Ma ory
m
Me
of access to the
memory by the
processor
Figure 1.14 The Memory Hierarchy
T1 + T2
T2
Average access time
T1
0 1
Fraction of accesses involving only Level 1 (Hit ratio)
Secondary
Memory
Also
referred to
as auxiliary
memory
• External
• Nonvolatile
• Used to store
program and
data files
• Invisible to the OS
• Interacts with other memory management
hardware
• Processor must access memory at least once per
instruction cycle
• Processor execution is limited by memory cycle
time
• Exploit the principle of locality with a small, fast
memory
Block Transfer
Word Transfer
Fastest Fast
Less Slow
fast
C-1
Block Length
(K Words)
(a) Cache
Block M – 1
2n - 1
Word
Length
(b) Main memory
START
RA - read address
Receive address
RA from CPU
Load main
Deliver RA word
memory block
to CPU
into cache slot
DONE
Number of
cache Block size
levels
Main
categories
are:
Write Mapping
policy function
Replacement
algorithm
Cache Size
Block
Size
The unit of data
Small caches have
exchanged
significant impact
between cache
on performance
and main memory
Mapping Function
Replacement Algorithm
Least Recently Used (LRU) Algorithm
– Effective strategy is to replace a block that has
been in the cache the longest with no
references to it
– Hardware mechanisms are needed to identify
the least recently used block
• Chooses which block to replace when a new block is
to be loaded into the cache
Write Policy
Dictates when the memory write operation takes
place
I/O Techniques
• When the processor encounters an
instruction relating to I/O, it executes that
instruction by issuing a command to the
appropriate I/O module
Three techniques are possible for I/O operations:
Interrupt-Driven I/O
Processor
issues an I/O The processor
command to a executes the data
module and transfer and then
then goes on to resumes its
do some other former
useful work processing
Performance Scaling
• A system with multiple • Vendors can offer a range of
processors will yield greater products with different price
performance if work can be and performance
done in parallel characteristics
System Bus
Main I/O
Memory I/O Adapter
Subsystem
I/O
Adapter
I/O
Adapter
Multicore Computer
• Also known as a chip multiprocessor
• Combines two or more processors (cores)
on a single piece of silicon (die)
• Each core consists of all of the components
of an independent processor
• In addition, multicore chips also include L2
cache and in some cases L3 cache