computer system hardware - welcom to comp's personal...

33
EEL 602 1 Computer System Hardware Reading: Silberschatz chapter 2 Additional Reading: Stallings chapter 1, 2

Upload: others

Post on 04-Apr-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Computer System Hardware - Welcom to COMP's Personal ...csajaykr/myhome/teaching/eel602/Hardware.pdf · EEL 602 26 Dual-Mode Operation ¾Mode bit added to computer hardware to indicate

EEL 602 1

Computer System Hardware

Reading:Silberschatzchapter 2

Additional Reading:Stallingschapter 1, 2

Page 2: Computer System Hardware - Welcom to COMP's Personal ...csajaykr/myhome/teaching/eel602/Hardware.pdf · EEL 602 26 Dual-Mode Operation ¾Mode bit added to computer hardware to indicate

EEL 602 2

OutlineComputer HardwareCPU ComponentsRegistersInstruction ExecutionInterrupt and TrapMemory

HierarchyCache

Dual Mode OperationProtection

HardwareMemoryCPU, I/O

Page 3: Computer System Hardware - Welcom to COMP's Personal ...csajaykr/myhome/teaching/eel602/Hardware.pdf · EEL 602 26 Dual-Mode Operation ¾Mode bit added to computer hardware to indicate

EEL 602 3

Key ElementsCPU or ProcessorMain Memory

typically volatilealso referred as real memory or primary memory

I/O modulessecondary memory devicescommunications equipmentterminals

System buscommunication among processors, memory, and I/O modules

Why study hardware?OS exploits hardware resources to provide set of services

Computer Hardware

Page 4: Computer System Hardware - Welcom to COMP's Personal ...csajaykr/myhome/teaching/eel602/Hardware.pdf · EEL 602 26 Dual-Mode Operation ¾Mode bit added to computer hardware to indicate

EEL 602 4

CPU Components

Computer Components: Top-Level View

Page 5: Computer System Hardware - Welcom to COMP's Personal ...csajaykr/myhome/teaching/eel602/Hardware.pdf · EEL 602 26 Dual-Mode Operation ¾Mode bit added to computer hardware to indicate

EEL 602 5

User-Visible registersHelps programmer to minimize main memory referencesTypically two types of registers1. Data registers 2. Address registers

IndexSegment pointerStack pointer

Processor Registers

Page 6: Computer System Hardware - Welcom to COMP's Personal ...csajaykr/myhome/teaching/eel602/Hardware.pdf · EEL 602 26 Dual-Mode Operation ¾Mode bit added to computer hardware to indicate

EEL 602 6

Data registersGeneral purpose (programmers or machine)May be dedicated (floating-point and integer operations)

Address registersIndex

Involves adding an index to base value to get effective address

Segment pointerWhen memory is divided into segments, memory is referenced by a segment and an offset

Stack pointerPoints to top of stack

User-Visible Registers

Page 7: Computer System Hardware - Welcom to COMP's Personal ...csajaykr/myhome/teaching/eel602/Hardware.pdf · EEL 602 26 Dual-Mode Operation ¾Mode bit added to computer hardware to indicate

EEL 602 7

Program CounterContains the address of instruction to be fetched

Instruction RegisterContains the instruction most recently fetched

Program Status Word (PSW)Condition codesInterrupt enable/disableSupervisor/user mode

Control and Status RegistersMostly not visible to user, organization is machine specific

Page 8: Computer System Hardware - Welcom to COMP's Personal ...csajaykr/myhome/teaching/eel602/Hardware.pdf · EEL 602 26 Dual-Mode Operation ¾Mode bit added to computer hardware to indicate

EEL 602 8

Condition Codes or FlagsBits set by the processor hardware as a result of operationsExamples

Positive resultNegative resultZeroOverflow

Control and Status Registers

Page 9: Computer System Hardware - Welcom to COMP's Personal ...csajaykr/myhome/teaching/eel602/Hardware.pdf · EEL 602 26 Dual-Mode Operation ¾Mode bit added to computer hardware to indicate

EEL 602 9

Instruction ExecutionInstruction Cycle – processing required for single instruction

Two step processing in simplest formProcessor reads instructions from memory one at time

FetchesProcessor executes each instruction

Basic Instruction Cycle

Page 10: Computer System Hardware - Welcom to COMP's Personal ...csajaykr/myhome/teaching/eel602/Hardware.pdf · EEL 602 26 Dual-Mode Operation ¾Mode bit added to computer hardware to indicate

EEL 602 10

Instruction Fetch and ExecuteThe processor fetches the instruction from memoryProgram counter (PC) holds address of the instruction to be fetched nextProcessor increments the PC after each fetch

Page 11: Computer System Hardware - Welcom to COMP's Personal ...csajaykr/myhome/teaching/eel602/Hardware.pdf · EEL 602 26 Dual-Mode Operation ¾Mode bit added to computer hardware to indicate

EEL 602 11

Instruction RegisterFetched instruction is loaded in IRInstruction categories

Processor-memoryTransfer data between processor and memory

Processor-I/OData transferred to or from a peripheral device

Data processingArithmetic or logic operation on data

ControlAlter sequence of execution

Page 12: Computer System Hardware - Welcom to COMP's Personal ...csajaykr/myhome/teaching/eel602/Hardware.pdf · EEL 602 26 Dual-Mode Operation ¾Mode bit added to computer hardware to indicate

EEL 602 12

InterruptsCommon Class of Interrupts

ProgramResult of instruction execution, e.g. arithmetic overflow, division by zero or illegal memory reference

TimerProcessors timer, functions on regular basis

I/OGenerated by I/O controller, signal or error

Hardware FailurePower failure or memory parity error

Page 13: Computer System Hardware - Welcom to COMP's Personal ...csajaykr/myhome/teaching/eel602/Hardware.pdf · EEL 602 26 Dual-Mode Operation ¾Mode bit added to computer hardware to indicate

EEL 602 13

Interrupt and TrapMechanisms to interrupt the normal processing of processor

TrapTrap is the notification of an internal event, highest priorityTraps are immediate and occur synchronously with the current activity of processor (result of program execution)

InterruptInterrupt is the notification of an external eventOccur asynchronously with the current activity of processor

Page 14: Computer System Hardware - Welcom to COMP's Personal ...csajaykr/myhome/teaching/eel602/Hardware.pdf · EEL 602 26 Dual-Mode Operation ¾Mode bit added to computer hardware to indicate

EEL 602 14

Program Flow of Control

(a) No Interrupts (c) Interrupts; long I/O wait(b) Interrupts; short I/O wait

Page 15: Computer System Hardware - Welcom to COMP's Personal ...csajaykr/myhome/teaching/eel602/Hardware.pdf · EEL 602 26 Dual-Mode Operation ¾Mode bit added to computer hardware to indicate

EEL 602 15

Interrupts

Simple Interrupt Processing

Page 16: Computer System Hardware - Welcom to COMP's Personal ...csajaykr/myhome/teaching/eel602/Hardware.pdf · EEL 602 26 Dual-Mode Operation ¾Mode bit added to computer hardware to indicate

EEL 602 16

Multiple Interrupts

Sequential interrupt processing

Disable new interrupts while an interrupt is being processed

Page 17: Computer System Hardware - Welcom to COMP's Personal ...csajaykr/myhome/teaching/eel602/Hardware.pdf · EEL 602 26 Dual-Mode Operation ¾Mode bit added to computer hardware to indicate

EEL 602 17

Multiple InterruptsDisadvantages of sequential interrupt processing

Does not account for relative priority or time critical needsI/O device may fill and overflow

Define priorities and serve in order

Nested interrupt processing

Page 18: Computer System Hardware - Welcom to COMP's Personal ...csajaykr/myhome/teaching/eel602/Hardware.pdf · EEL 602 26 Dual-Mode Operation ¾Mode bit added to computer hardware to indicate

EEL 602 18

Multiple Interrupts

Example: Time sequence of multiple interrupts with priorities

Page 19: Computer System Hardware - Welcom to COMP's Personal ...csajaykr/myhome/teaching/eel602/Hardware.pdf · EEL 602 26 Dual-Mode Operation ¾Mode bit added to computer hardware to indicate

EEL 602 19

Memory HierarchyDesign Constraints

How much?Open ended, large capacity

How fast?Mach the processor, do not wish to wait

How expensive?Reasonable relationship to other components

Tradeoff among three componentsFaster access time, greater cost per bitGreater capacity, smaller cost per bitGreater capacity, slower access speed

Page 20: Computer System Hardware - Welcom to COMP's Personal ...csajaykr/myhome/teaching/eel602/Hardware.pdf · EEL 602 26 Dual-Mode Operation ¾Mode bit added to computer hardware to indicate

EEL 602 20

Memory Hierarchy

As one goes downDecreasing cost per bitIncreasing capacityIncreasing access time

Key to success – Decrease the frequency of access

Page 21: Computer System Hardware - Welcom to COMP's Personal ...csajaykr/myhome/teaching/eel602/Hardware.pdf · EEL 602 26 Dual-Mode Operation ¾Mode bit added to computer hardware to indicate

EEL 602 21

CachingCopying information into faster storage system; main memory can be viewed as a fast cache for secondary storageUse of high-speed memory to hold recently-accessed dataRequires a cache management policy

Page 22: Computer System Hardware - Welcom to COMP's Personal ...csajaykr/myhome/teaching/eel602/Hardware.pdf · EEL 602 26 Dual-Mode Operation ¾Mode bit added to computer hardware to indicate

EEL 602 22

Caching

Cache Read Operation

Cache sizeReplacement policy

Page 23: Computer System Hardware - Welcom to COMP's Personal ...csajaykr/myhome/teaching/eel602/Hardware.pdf · EEL 602 26 Dual-Mode Operation ¾Mode bit added to computer hardware to indicate

EEL 602 23

Typical Memory Hierarchy

Page 24: Computer System Hardware - Welcom to COMP's Personal ...csajaykr/myhome/teaching/eel602/Hardware.pdf · EEL 602 26 Dual-Mode Operation ¾Mode bit added to computer hardware to indicate

EEL 602 24

Hardware ProtectionSharing of Resources → Utilization and Problems

OS must ensure that an incorrect program cannot cause other programs to execute incorrectly

Hardware ProtectionDual-Mode OperationI/O ProtectionMemory ProtectionCPU Protection

Page 25: Computer System Hardware - Welcom to COMP's Personal ...csajaykr/myhome/teaching/eel602/Hardware.pdf · EEL 602 26 Dual-Mode Operation ¾Mode bit added to computer hardware to indicate

EEL 602 25

Dual-Mode OperationProvide hardware support to differentiate between at least two modes of operations

User Mode → execution done on behalf of a user

Monitor Mode (also kernel mode or system mode) →execution done on behalf of operating system

Page 26: Computer System Hardware - Welcom to COMP's Personal ...csajaykr/myhome/teaching/eel602/Hardware.pdf · EEL 602 26 Dual-Mode Operation ¾Mode bit added to computer hardware to indicate

EEL 602 26

Dual-Mode OperationMode bit added to computer hardware to indicate current mode: Monitor (0) or User (1)When an interrupt or fault occurs hardware switches to monitor mode

Privileged instructions can be issued only in monitor modeMSDOS (8088 architecture) – No Mode bitWin 2000, IBM OS/2 (advanced versions of Intel CPU, Pentium)

provide dual-mode operation

Monitor User

Interrupt/fault

set user mode

Page 27: Computer System Hardware - Welcom to COMP's Personal ...csajaykr/myhome/teaching/eel602/Hardware.pdf · EEL 602 26 Dual-Mode Operation ¾Mode bit added to computer hardware to indicate

EEL 602 27

I/O ProtectionAll I/O instructions → privileged instructions

Must ensure that a user program could never gain control of the computer in monitor mode

All I/O instructions → through OS, checks if valid

Page 28: Computer System Hardware - Welcom to COMP's Personal ...csajaykr/myhome/teaching/eel602/Hardware.pdf · EEL 602 26 Dual-Mode Operation ¾Mode bit added to computer hardware to indicate

EEL 602 28

Use of system call to perform I/O

I/O Protection

Page 29: Computer System Hardware - Welcom to COMP's Personal ...csajaykr/myhome/teaching/eel602/Hardware.pdf · EEL 602 26 Dual-Mode Operation ¾Mode bit added to computer hardware to indicate

EEL 602 29

Memory ProtectionMemory protection → Prevent interrupt vector and interrupt service routines from user program

Range of legal addresses - two registersBase register → holds the smallest legal physical memory addressLimit register → contains the size of the range

Memory outside the defined range is protected

Page 30: Computer System Hardware - Welcom to COMP's Personal ...csajaykr/myhome/teaching/eel602/Hardware.pdf · EEL 602 26 Dual-Mode Operation ¾Mode bit added to computer hardware to indicate

EEL 602 30

Use of base and limit register

Memory Protection

Page 31: Computer System Hardware - Welcom to COMP's Personal ...csajaykr/myhome/teaching/eel602/Hardware.pdf · EEL 602 26 Dual-Mode Operation ¾Mode bit added to computer hardware to indicate

EEL 602 31

Hardware Address Protection

Page 32: Computer System Hardware - Welcom to COMP's Personal ...csajaykr/myhome/teaching/eel602/Hardware.pdf · EEL 602 26 Dual-Mode Operation ¾Mode bit added to computer hardware to indicate

EEL 602 32

Hardware ProtectionThe load instructions for the base and limitregisters are privileged instructions

When executing in monitor mode, OS has unrestricted access to both monitor and user’s memory

Page 33: Computer System Hardware - Welcom to COMP's Personal ...csajaykr/myhome/teaching/eel602/Hardware.pdf · EEL 602 26 Dual-Mode Operation ¾Mode bit added to computer hardware to indicate

EEL 602 33

CPU ProtectionPrevent user program from struck in infinite loopor never returning control to OSTimer – interrupts computer after specified period to ensure OS system maintains control

Timer is decremented every clock tickWhen timer reaches the value 0, an interrupt occurs

Timer commonly used to implement time sharingLoad-timer is a privileged instruction