Академический Документы
Профессиональный Документы
Культура Документы
Operating
Systems:
Internals Chapter 1
and Design
Principles Computer System
Overview
Eighth Edition
By William Stallings
Operating System
١
٠٩/٠١/١٤٣٨
Basic Elements
I/O
Processor Modules
Main System
Memory Bus
Processor
Referred to as
the Central
Processing Unit
(CPU)
٢
٠٩/٠١/١٤٣٨
Main Memory
Volatile
Contents of the memory is lost
when the computer is shut down
Referred to as real memory or
primary memory
I/O Modules
٣
٠٩/٠١/١٤٣٨
System Bus
Provides for
communication among
processors, main memory,
and I/O modules
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
٤
٠٩/٠١/١٤٣٨
Microprocessor
Invention that brought about desktop
and handheld computing
Processor on a single chip
Fastest general purpose processor
Multiprocessors
Each chip (socket) contains multiple
processors (cores)
Graphical Processing
Units (GPU’s)
Provide efficient computation on arrays
of data using Single-Instruction Multiple
Data (SIMD) techniques
Used for general numerical processing
Physics simulations for games
Computations on large spreadsheets
٥
٠٩/٠١/١٤٣٨
System on a Chip
(SoC)
To satisfy the requirements of handheld
devices, the microprocessor is giving way
to the SoC
Components such as DSPs, GPUs,
codecs and main memory, in
addition to the CPUs and caches,
are on the same chip
٦
٠٩/٠١/١٤٣٨
Instruction Execution
processor reads
processor executes
(fetches) instructions
each instruction
from memory
Two steps
٧
٠٩/٠١/١٤٣٨
٨
٠٩/٠١/١٤٣٨
٩
٠٩/٠١/١٤٣٨
Interrupts
Interrupt the normal sequencing of the
processor
Provided to improve processor utilization
most I/O devices are slower than the processor
processor must pause to wait for device
wasteful use of the processor
١٠
٠٩/٠١/١٤٣٨
User I/O
Program Program
1 4
I/O
Command
WRITE
Figure 1.5a 5
END
2
Flow of Control
WRITE
Without
Interrupts 3
WRITE
(a) No interrupts
User I/O
Program Program
1 4
I/O
Command
WRITE
2a
WRITE 5
3b
WRITE
١١
٠٩/٠١/١٤٣٨
User I/O
Program Program
1 4
I/O
Command
WRITE
Figure 1.5c 2
Interrupt
Handler
WRITE 5
Long I/O Wait 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
١٣
٠٩/٠١/١٤٣٨
Time
1 1
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
١٤
٠٩/٠١/١٤٣٨
T–M T–M
Y N+1
Control Control
Stack Stack
T T
N+1 Y+L+1
Program Program
Counter Counter
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 from • disable interrupts while
a communications line an interrupt is being
and printing results at processed
the same time • use a priority scheme
١٥
٠٩/٠١/١٤٣٨
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 Hierarchy
Memory Relationships
Greater capacity
Faster = smaller cost per
access time bit
= greater Greater
cost per bit capacity =
slower access
speed
١٧
٠٩/٠١/١٤٣٨
Ou isk
cD
t eti
Sto boar gn OM
decreasing cost per bit rag d
e
Ma D-R W
C D-R W
C
D-
R
DV D-RA y
M
a
DV lu-R
increasing capacity B
Of pe
increasing access time f
Sto -line
rag
e Ma
gn
e tic
Ta
decreasing frequency 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
٢٠
٠٩/٠١/١٤٣٨
Line Memory
Number Tag Block address
0 0
1 1
2 2 Block 0
3 (K words)
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
٢١
٠٩/٠١/١٤٣٨
cache size
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 and
on performance
main memory
٢٢
٠٩/٠١/١٤٣٨
Mapping Function
∗ Determines which cache
location the block will occupy
when one block is read in,
another may have to be
replaced
Two constraints affect
design:
the more flexible the
mapping function, the
more complex is the
circuitry required to
search the cache
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
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
٢٤
٠٩/٠١/١٤٣٨
Programmed I/O
The I/O module performs the requested action
then sets the appropriate bits in the I/O status
register
The processor periodically checks the status of the
I/O module until it determines the instruction is
complete
With programmed I/O the performance level of
the entire system is severely degraded
Interrupt--Driven I/O
Interrupt
Processor
issues an I/O The processor
command to a executes the
module and data transfer
then goes on and then
to do some resumes its
other useful former
work processing
٢٥
٠٩/٠١/١٤٣٨
Interrupt-Driven I/O
Interrupt-
Drawbacks
Transfer rate is limited by the speed with
which the processor can test and service a
device
The processor is tied up in managing an I/O
transfer
a number of instructions must be
executed for each I/O transfer
٢٦
٠٩/٠١/١٤٣٨
Symmetric Multiprocessors
(SMP)
A stand-alone computer system with the
following characteristics:
two or more similar processors of comparable capability
processors share the same main memory and are
interconnected by a bus or other internal connection scheme
processors share access to I/O devices
all processors can perform the same functions
the system is controlled by an integrated operating system
that provides interaction between processors and their
programs at the job, task, file, and data element levels
٢٧
٠٩/٠١/١٤٣٨
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
32 kB 32 kB 32 kB 32 kB 32 kB 32 kB 32 kB 32 kB 32 kB 32 kB 32 kB 32 kB
L1-I L1-D L1-I L1-D L1-I L1-D L1-I L1-D L1-I L1-D L1-I L1-D
12 MB
L3 Cache
٢٩
٠٩/٠١/١٤٣٨
Summary
Basic Elements Cache memory
Motivation
Evolution of the
microprocessor Cache principles
Cache design
Instruction execution
Direct memory access
Interrupts
Interrupts and the Multiprocessor and
instruction cycle multicore organization
Interrupt processing Symmetric
multiprocessors
Multiple interrupts
Multicore computers
The memory hierarchy
٣٠