10
1 Silberschatz, Galvin and Gagne ©2002 2.1 Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection General System Architecture Silberschatz, Galvin and Gagne ©2002 2.2 Operating System Concepts Computer-System Architecture Silberschatz, Galvin and Gagne ©2002 2.3 Operating System Concepts Computer-System Operation I/O devices and the CPU can execute concurrently one device controller for each device type Each device controller has local buffer CPU moves data from/to main memory to/from local buffers I/O is from the device to local buffer of controller Device controller informs CPU that it has finished its operation by causing an interrupt.

Operating System Concepts 2.1 Silberschatz, Galvin and …ege/cop4610/Slides/ch2.pdf · Operating System Concepts 2.1 Silberschatz, ... one device controller for each device type

Embed Size (px)

Citation preview

Page 1: Operating System Concepts 2.1 Silberschatz, Galvin and …ege/cop4610/Slides/ch2.pdf · Operating System Concepts 2.1 Silberschatz, ... one device controller for each device type

1

Silberschatz, Galvin and Gagne ©20022.1Operating System Concepts

Chapter 2: Computer-System Structures

Computer System OperationI/O Structure Storage StructureStorage HierarchyHardware ProtectionGeneral System Architecture

Silberschatz, Galvin and Gagne ©20022.2Operating System Concepts

Computer-System Architecture

Silberschatz, Galvin and Gagne ©20022.3Operating System Concepts

Computer-System Operation

I/O devices and the CPU can execute concurrentlyone device controller for each device typeEach device controller has local bufferCPU moves data from/to main memory to/from local buffersI/O is from the device to local buffer of controllerDevice controller informs CPU that it has finished its operation by causing an interrupt.

Page 2: Operating System Concepts 2.1 Silberschatz, Galvin and …ege/cop4610/Slides/ch2.pdf · Operating System Concepts 2.1 Silberschatz, ... one device controller for each device type

2

Silberschatz, Galvin and Gagne ©20022.4Operating System Concepts

Common Functions of Interrupts

Interrupt calls interrupt service routineInterrupt has numberinterrupt vector contains addresses of service routines

Interrupt architecturesave the address of the interrupted instructiondisabled new interrupt to prevent a lost interrupt

trap = software-generated interruptcaused either by an error or a user request

operating system is interrupt driven

Silberschatz, Galvin and Gagne ©20022.5Operating System Concepts

Interrupt Handling

Preserve state of CPUstoring registers and the program counter

Determine which type of interrupt has occurred:vectored interrupt systempolling

Execute interrupt specific codeRestore CPU state

Silberschatz, Galvin and Gagne ©20022.6Operating System Concepts

Interrupt Time Line For a Single Process Doing Output

Page 3: Operating System Concepts 2.1 Silberschatz, Galvin and …ege/cop4610/Slides/ch2.pdf · Operating System Concepts 2.1 Silberschatz, ... one device controller for each device type

3

Silberschatz, Galvin and Gagne ©20022.7Operating System Concepts

I/O Structures

Synchronous Asynchronous

Silberschatz, Galvin and Gagne ©20022.8Operating System Concepts

Synchronous I/O

After I/O starts user program waits for I/O completionWait via

Special instructionWait loop

Limitationone I/O request at a timeno simultaneous I/O processing

Silberschatz, Galvin and Gagne ©20022.9Operating System Concepts

Asynchronous I/O

After I/O starts user program does not waitExtra System call needed to allow explicit wait

Device-status tableHas entry for each I/O devicetype, address, and state

Page 4: Operating System Concepts 2.1 Silberschatz, Galvin and …ege/cop4610/Slides/ch2.pdf · Operating System Concepts 2.1 Silberschatz, ... one device controller for each device type

4

Silberschatz, Galvin and Gagne ©20022.10Operating System Concepts

Device-Status Table

Silberschatz, Galvin and Gagne ©20022.11Operating System Concepts

Direct Memory Access Structure

Used for high-speed I/O devices able to transmit information at close to memory speedsDevice controller transfers blocks of data from buffer storage directly to main memory without CPU interventionOnly on interrupt is generated per block, rather than the one interrupt per byte

Silberschatz, Galvin and Gagne ©20022.12Operating System Concepts

Storage Structure

Main memoryonly large storage media that the CPU can access directly

Secondary storageextension of main memory that is large and non-volatile

Magnetic disksrigid metal or glass platters with magnetic recording material Disk is logically divided into tracks and sectorsThe disk controller determines the logical interaction between the device and the computer

Page 5: Operating System Concepts 2.1 Silberschatz, Galvin and …ege/cop4610/Slides/ch2.pdf · Operating System Concepts 2.1 Silberschatz, ... one device controller for each device type

5

Silberschatz, Galvin and Gagne ©20022.13Operating System Concepts

Moving-Head Disk Mechanism

Silberschatz, Galvin and Gagne ©20022.14Operating System Concepts

Storage Hierarchy

Storage systems organized in hierarchySpeedCostVolatility

Cachingcopying information into faster storage systemmain memory can be viewed as cache for secondary storage

Silberschatz, Galvin and Gagne ©20022.15Operating System Concepts

Storage-Device Hierarchy

Page 6: Operating System Concepts 2.1 Silberschatz, Galvin and …ege/cop4610/Slides/ch2.pdf · Operating System Concepts 2.1 Silberschatz, ... one device controller for each device type

6

Silberschatz, Galvin and Gagne ©20022.16Operating System Concepts

Caching

Use of high-speed memory to hold recently-accessed dataRequires a cache management policyRequires replicated data to be consistent

Silberschatz, Galvin and Gagne ©20022.17Operating System Concepts

Hardware Protection

Dual-Mode OperationI/O ProtectionMemory ProtectionCPU Protection

Silberschatz, Galvin and Gagne ©20022.18Operating System Concepts

Dual-Mode Operation

System resources are sharedRogue program may not cause other programs to execute incorrectly

Hardware supports two modes of operation:1. User mode: execution done on behalf of a user2. Monitor mode (also kernel mode or system mode):

execution done on behalf of operating system

Page 7: Operating System Concepts 2.1 Silberschatz, Galvin and …ege/cop4610/Slides/ch2.pdf · Operating System Concepts 2.1 Silberschatz, ... one device controller for each device type

7

Silberschatz, Galvin and Gagne ©20022.19Operating System Concepts

Dual-Mode Operation (Cont.)

Hardware has mode bit:monitor (0) or user (1)On interrupt or fault: hardware switches to monitor mode

Privileged instructions can be issued only in monitor mode

monitor user

Interrupt/fault

set user mode

Silberschatz, Galvin and Gagne ©20022.20Operating System Concepts

I/O Protection

All I/O instructions are privileged instructionsOS ensures that a user program never gains control of the computer in monitor mode

example: user program stores a new address into interrupt vector

Silberschatz, Galvin and Gagne ©20022.21Operating System Concepts

Use of A System Call to Perform I/O

Page 8: Operating System Concepts 2.1 Silberschatz, Galvin and …ege/cop4610/Slides/ch2.pdf · Operating System Concepts 2.1 Silberschatz, ... one device controller for each device type

8

Silberschatz, Galvin and Gagne ©20022.22Operating System Concepts

Memory Protection

Must provide memory protection at least for the interrupt vector and the interrupt service routinesTypical: registers that hold range of legal addresses

Base register – holds the smallest legal physical memory address.Limit register – contains the size of the range

Memory outside the defined range is protected

Silberschatz, Galvin and Gagne ©20022.23Operating System Concepts

Use of A Base and Limit Register

Silberschatz, Galvin and Gagne ©20022.24Operating System Concepts

Hardware Address Protection

Page 9: Operating System Concepts 2.1 Silberschatz, Galvin and …ege/cop4610/Slides/ch2.pdf · Operating System Concepts 2.1 Silberschatz, ... one device controller for each device type

9

Silberschatz, Galvin and Gagne ©20022.25Operating System Concepts

Hardware Protection

When executing in monitor mode, the operating system has unrestricted access to both monitor and user’s memoryThe load instructions for the base and limitregisters are privileged instructions

Silberschatz, Galvin and Gagne ©20022.26Operating System Concepts

CPU Protection

Timerinterrupts computer after specified period to ensure operating system maintains control

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

Timer commonly used to implement time sharingTime also used to compute the current timeLoad-timer is a privileged instruction

Silberschatz, Galvin and Gagne ©20022.27Operating System Concepts

Network Structure

Local Area Networks (LAN)Wide Area Networks (WAN)

Page 10: Operating System Concepts 2.1 Silberschatz, Galvin and …ege/cop4610/Slides/ch2.pdf · Operating System Concepts 2.1 Silberschatz, ... one device controller for each device type

10

Silberschatz, Galvin and Gagne ©20022.28Operating System Concepts

Local Area Network Structure

Silberschatz, Galvin and Gagne ©20022.29Operating System Concepts

Wide Area Network Structure