2 Os
2 Os
CS2006
Lecture: 3
Computer-System Architecture
What is a Computer
System?
Computer
System
Consists of CPU and device controllers
Connected through a common Bus.
Providing access to shared memory
Each device controller is in charge of a specific
device
Disk drives
Audio devices
Video display
Computer System
Organization
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 Operation
I/O devices and the CPU can execute concurrently
Device controller informs CPU that it has finished its operation by causing an
interrupt
Major Computer
Components
7
1- CPU
Registers
Program Counter (PC)
Instruction Register (IR)
Program Status Word (PSW)
General-purpose registers
Instruction Set Architecture
RISC vs. CISC
Intel, SPARC, MIPS, PowerPC, ARM, Alpha, …
Pipelining
Fetch, Decode, Execute, Write Back, etc.
Instruction-Level Parallelism(ILP)
Superscalar vs. VLIW
Simultaneous Multithreading
Processo
r
Internal Register
Memory Address Register (MAR)
Specifies the address for next read or write
Memory Buffer Register (MBR)
Contains data written into memory or receives data
read from memory
I/O address register
I/O buffer register
9
User-Visible
Register
May be read by user processes
Available to all programs – application programs
and system programs
Types of registers
Data
Address
Index
Segment pointer
Stack pointer
12
Control and Status
Register
Program Counter (PC)
Contains the address of an instruction to be
fetched
Instruction Register (IR)
Contains the instruction most recently fetched
Program Status Word (PSW)
Condition codes
Interrupt enable/disable
Supervisor/user mode
2- Memory Structure
Storage systems organized in hierarchy
Speed
Cost
Volatility
Caching
copying information into faster storage system
main memory can be viewed as a last cache for secondary
storage
Storage-Device Hierarchy
Memory Hierarchy
Caching
Use of high-speed memory to hold recently-accessed data
Caching introduces another level in storage hierarchy. This requires data that
is simultaneously stored in more than one level to be consistent
Cache coherency
Migration of A From Disk to Register
3- I/O Structure
After I/O starts, control returns to user program only upon I/O completion
Wait instruction idles the CPU until the next interrupt
Wait loop (contention for memory access)
At most one I/O request is outstanding at a time, no simultaneous I/O processing
After I/O starts, control returns to user program without waiting for I/O
completion
System call – request to the operating system to allow user to wait for I/O
completion
Device-status table contains entry for each I/O device indicating its type, address,
and state
Operating system indexes into I/O device table to determine device status and to
modify table entry to include interrupt
Device
Controllers
I/O devices generally consists of two parts:
An Electronic component: Device Controller
A Mechanical component: The device itself
Each device controller is in charge of a specific
device
It maintains
Some local storage buffer
A set of special purpose register
Accepts command from the Operating System
For example to read data from the device.
Device
Controllers
A Device controller might accept a command:
Read
Sector 11,206
The device controller would:
Determine the current position of the head
Move the head to the required location
Accept data bit by bit
Store in a local buffer
Perform checksum on the data
Controllers contain small embedded programs to
carry out all this work.
Device
Drivers
Who would initiate the controller
Who would determine read/write
Who would tell the sector number
A part of operating system called Device Driver
Software or Hardware?
Software that talks to a controller
Gives it command
Accept Responses
Same for all controllers?
Different software for different type of controllers
Each controller manufacturer has to supply a driver for
each operating system it supports
Device Status
Table
One entry per I/O device
Keeps record of
Device’s type
Address
State
Not functioning
Idle
Busy
If the device is busy, the new request is saved in a
queue
Device Status
Table
9
A
The operating system
Question
Gets an input
Performs a
computation
Produces an output
And Quits
Yes or no?
• Hardware Interrupts
• Software Interrupts
• Traps
Hardware
Interrupts
Hardware Interrupts - generated by hardware devices to
signal that they need some attention from the OS.
They may have just received some data (e.g., keystrokes on the keyboard
or an data on the Ethernet card);
23
Interrupt
s Suspends the normal
sequence of
execution
Used to improve
processor utilization
Interrupt
Handling
Different routines handle different type of interrupts.
Called Interrupt Service Routine (ISR)
When the CPU is interrupted it stops what it is doing
The address of the interrupted instruction is saved
A generic routine is run
This routine examines the nature of interrupt
Calls the corresponding ISR
The ISR’s are usually stored in the lower part of the memory
After the interrupt is serviced, the saved address is loaded to
the Program Counter
The Interrupted computation can resume as though the
interrupt had not occurred.
Interrupt
Cycle
Interrupt
Timeline
27
Simple Interrupt
Processing
28
Multiple
Interrupts
Disable interrupts while an interrupt is being
processed
29
Multiple
Interrupts
Define Priorities for
interrupts
30
I/O
How does the kernel notice an I/O has finished?
Polling
Control
Hardware interrupt
I/O Control
(Cont’d)
Device interrupts
Not
Ready
Check
Error Condition
Status
Ready
Read word from I/O module I/O -> CPU
No
Done
Check
Error Condition
Status
Ready
Read word from I/O module I/O -> CPU
No
Done
Read status
Interrupt
of DMA
module DMA -> CPU
Ye
Next Instruction
s
45
Interrupts and Exceptions
Interrupts
Generated by hardware devices
Triggered by a signal in INTR or NMI pins (Pentium)
Asynchronous
Exceptions
Generated by software executing instructions
INT instruction in IA32
Page fault, protection fault
Synchronous
Trap (expected) or fault (unexpected)
Referenc
ehttp://www.cs.toronto.edu/~demke/469F.06/Lectures/Lecture6.pdf
Chapter 1, Operating Systems by William Stallings
http://www.tldp.org/LDP/tlk/dd/interrupts.html
http://en.wikibooks.org/wiki/Operating_System_Design/Processes/Interrupt
http://www.slideshare.net/guest2e9811e/interrupts
https://amser.org/g11619
http://www.eecs.harvard.edu/~mdw/course/cs161/notes/osstructure.pdf
http:/ /www.sci.brooklyn.cuny.edu/~jniu/teaching/csc33200/files/09
10- ComputerSystemOverview02.pdf
http://siber.cankaya.edu.tr/OperatingSystems/ceng328/node87.html
http://www.personal.kent.edu/~rmuhamma/OpSystems/Myos/processC
ontrol.htm
http://www.tutorialspoint.com/operating_system/os_processes.htm
http://wiki.answers.com/Q/Explain_process_control_block
https://msdn.microsoft.com/en-us/library/windows/desktop/
aa365683(v=vs.85).aspx