15cs302j Operating Systems Unit1
15cs302j Operating Systems Unit1
I/O
Processor Modules
Main System
Memory Bus
15CS302J OPERATING SYSTEMS LECTURE NOTES
4
REJO
Processor
Referred to as the
Central Processing
Unit (CPU)
15CS302J OPERATING SYSTEMS LECTURE NOTES
5
REJO
Main Memory
•Volatile
• Contents of the memory is lost
when the computer is shut down
•Referred to as real memory or
primary memory
storage (e.g.
Moves data hard drive)
between the
computer and communications
external equipment
environments
such as:
terminals
15CS302J OPERATING SYSTEMS LECTURE NOTES
7
REJO
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
Figure 15CS302J
1.1 Computer
OPERATINGComponents: Top-Level
SYSTEMS LECTURE NOTES View
9
REJO
Microprocessor
processor reads
processor executes
(fetches) instructions
each instruction
from memory
Two steps
15CS302J OPERATING SYSTEMS LECTURE NOTES
14
REJO
Fetch Stage Execute Stage
1 4 1
I/O
Command
WRITE WRITE
5
2a
END
2
2b
WRITE WRITE
Figure 1.5a
3a
Flow of Control
3
Without Interrupts
3b
WRITE WRITE
1 4 1 4 1
I/O I/O
Command Command
WRITE WRITE WRITE
5
2a
END
Figure 1.5b
2
Interrupt
2
2b Handler
3 3
3b
4 1 4 1 4
Interrupt Interrupt
2b Handler Handler
WRITE 5 WRITE 5
Long I/O Wait END END
3a
3b
WRITE WRITE
i
Interrupt
occurs here i+1
Figure 1.615CS302J
Transfer of Control via Interrupts
OPERATING SYSTEMS LECTURE NOTES
25
REJO
Fetch Stage Execute Stage Interrupt Stage
Interrupts
Disabled
Check for
Fetch next Execute interrupt;
START instruction instruction initiate interrupt
Interrupts
handler
Enabled
HALT
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
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
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
Figure
15CS302J1.10 Simple
OPERATING Interrupt
SYSTEMS Processing
LECTURE NOTES
29
REJO
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
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
Handler Y
Interrupt
User Program Handler X
Interrupt
Handler Y
15
0 t=
t =1
t = 25
t= t = 25 Disk
40 interrupt service routine
t=
35
Greater capacity =
Faster access smaller cost per bit
time = greater
cost per bit Greater capacity =
slower access
speed
hierarchy: Inb
Me oard
mo
i st
Ca
ch
e
in
ry M a or y
m
Me
decreasing frequency of Of
S t o f - li n e ne
tic
Ta
p e
rag ag
access to the memory by e M
the processor
T2
T1
0 1
Fraction of accesses involving only Level 1 (Hit ratio)
Also referred to as
auxiliary memory
• external
• nonvolatile
• used to store program
and data files
Fastest Fast
Less Slow
fast
C-1
Block Length
(K Words)
(a) Cache
Block M – 1
2n - 1
Word
Length
(b) Main memory
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
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
System Bus
Main I/O
Memory I/O Adapter
Subsystem
I/O
Adapter
I/O
Adapter
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
• convenience
• efficiency
• ability to evolve
15CS302J OPERATING SYSTEMS LECTURE NOTES
60
REJO
Application programs
Application
programming interface
Application Libraries/utilities Software
binary interface
Operating system
Instruction Set
Architecture
Execution hardware
Memory
System interconnect
translation Hardware
(bus)
I/O devices
Main
and
memory
networking
• Program development
• Program execution
• Access I/O devices
• Controlled access to files
• System access
• Error detection and response
• Accounting
Programs
and Data
I/O Controller
Processor Processor
Storage
OS
Programs
Data
hardware upgrades
new services
Fixes
Time
Sharing
Multiprogrammed Systems
Batch Systems
Simple Batch
Systems
Serial
Processing
15CS302J OPERATING SYSTEMS LECTURE NOTES
68
REJO
Serial Processing
Interrupt
Processing
• while the user program is executing, it must not alter the memory area
containing the monitor
Timer
Privileged instructions
Interrupts
• Processor is
often idle
• even with
automatic job
sequencing
• I/O devices
are slow
compared to
processor
Time
(a) Uniprogramming
Time
(b) Multiprogramming with two programs
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
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%
0 5 10 15
time
minutes
time
(a) Uniprogramming (b) Multiprogramming
CTSS
Time Slicing
• One of the first time-sharing • System clock generates interrupts at a
rate of approximately one every 0.2
operating systems seconds
• At each interrupt OS regained control
• Developed at MIT by a group known and could assign processor to another
as Project MAC user
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 advances in
development include:
• processes
• memory management
• information protection and security
• scheduling and resource management
• system structure