15
1 Silberschatz, Galvin and Gagne 2002 2.1 Operating System Concepts Chapter 2: Computer-System Structures n Computer System Operation n I/O Structure n Storage Structure n Storage Hierarchy n Hardware Protection n Network Structure Silberschatz, Galvin and Gagne 2002 2.2 Operating System Concepts Computer-System Architecture

Computer-System Architecture - Kent State Universityfarrell/osf03/lectures/ch2-2up.pdf · 1 Operating System Concepts 2.1 Silberschatz, Galvin and Gagne 2002 Chapter 2: Computer -System

Embed Size (px)

Citation preview

Page 1: Computer-System Architecture - Kent State Universityfarrell/osf03/lectures/ch2-2up.pdf · 1 Operating System Concepts 2.1 Silberschatz, Galvin and Gagne 2002 Chapter 2: Computer -System

1

Silberschatz, Galvin and Gagne 20022.1Operating System Concepts

Chapter 2: Computer-System Structures

n Computer System Operationn I/O Structure n Storage Structuren Storage Hierarchyn Hardware Protectionn Network Structure

Silberschatz, Galvin and Gagne 20022.2Operating System Concepts

Computer-System Architecture

Page 2: Computer-System Architecture - Kent State Universityfarrell/osf03/lectures/ch2-2up.pdf · 1 Operating System Concepts 2.1 Silberschatz, Galvin and Gagne 2002 Chapter 2: Computer -System

2

Silberschatz, Galvin and Gagne 20022.3Operating System Concepts

Computer System Bootup

n Bootstrap Program – in ROM or EEPROMF Initializes RegistersF Locates and loads into memory operating system kernel

n OS starts first process (init in Unix/Linux)n Waits for event to occur – signalled by interrupt

F Hardware triggeredF Software triggered (system or monitor call )

Silberschatz, Galvin and Gagne 20022.4Operating System Concepts

Computer-System Operation

n I/O devices and the CPU can execute concurrently.n Each device controller is in charge of a particular device

type.n Each device controller has a local buffer.n CPU moves data from/to main memory to/from local

buffersn I/O is from the device to local buffer of controller.n Device controller informs CPU that it has finished its

operation by causing an interrupt.

Page 3: Computer-System Architecture - Kent State Universityfarrell/osf03/lectures/ch2-2up.pdf · 1 Operating System Concepts 2.1 Silberschatz, Galvin and Gagne 2002 Chapter 2: Computer -System

3

Silberschatz, Galvin and Gagne 20022.5Operating System Concepts

Common Functions of Interrupts

n Interrupt transfers control to the interrupt service routine generally, through the interrupt vector, which contains the addresses of all the service routines.

n Interrupt architecture must save the address of the interrupted instruction.

n Incoming interrupts are disabled while another interrupt is being processed to prevent a lost interrupt .

n A trap is a software-generated interrupt caused either by an error or a user request.

n A modern operating system is interrupt driven.

Silberschatz, Galvin and Gagne 20022.6Operating System Concepts

Interrupt Handling

n The operating system preserves the state of the CPU by storing registers and the program counter.

n Determines which type of interrupt has occurred:F pollingF vectored interrupt system

n Separate segments of code determine what action should be taken for each type of interrupt

Page 4: Computer-System Architecture - Kent State Universityfarrell/osf03/lectures/ch2-2up.pdf · 1 Operating System Concepts 2.1 Silberschatz, Galvin and Gagne 2002 Chapter 2: Computer -System

4

Silberschatz, Galvin and Gagne 20022.7Operating System Concepts

Interrupt Time Line For a Single Process Doing Output

Silberschatz, Galvin and Gagne 20022.8Operating System Concepts

I/O Structure

n Synchronous I/O : After I/O starts, control returns to user program only upon I/O completion.F Wait instruction idles the CPU until the next interruptF Wait loop (contention for memory access).F At most one I/O request is outstanding at a time, no

simultaneous I/O processing.n Asynchronous I/O : After I/O starts, control returns to

user program without waiting for I/O completion.F System call – request to the operating system to allow user

to wait for I/O completion.F Device-status table contains entry for each I/O device

indicating its type, address, and state.F Operating system indexes into I/O device table to determine

device status and to modify table entry to include interrupt.

Page 5: Computer-System Architecture - Kent State Universityfarrell/osf03/lectures/ch2-2up.pdf · 1 Operating System Concepts 2.1 Silberschatz, Galvin and Gagne 2002 Chapter 2: Computer -System

5

Silberschatz, Galvin and Gagne 20022.9Operating System Concepts

Two I/O Methods

Synchronous Asynchronous

Silberschatz, Galvin and Gagne 20022.10Operating System Concepts

Device-Status Table

Page 6: Computer-System Architecture - Kent State Universityfarrell/osf03/lectures/ch2-2up.pdf · 1 Operating System Concepts 2.1 Silberschatz, Galvin and Gagne 2002 Chapter 2: Computer -System

6

Silberschatz, Galvin and Gagne 20022.11Operating System Concepts

Direct Memory Access Structure

n Used for high-speed I/O devices able to transmit information at close to memory speeds.

n Device controller transfers blocks of data from buffer storage directly to main memory without CPU intervention.

n Only one interrupt is generated per block, rather than the one interrupt per byte.

Silberschatz, Galvin and Gagne 20022.12Operating System Concepts

Storage Structure

n Main memory (RAM) – only large storage media that the CPU can access directly. (volatile)

n Secondary storage – extension of main memory that provides large nonvolatile storage capacity.

n Magnetic disks – rigid metal or glass platters covered with magnetic recording material F Disk surface is logically divided into tracks, which are

subdivided into sectors.F The disk controller determines the logical interaction

between the device and the computer.

Page 7: Computer-System Architecture - Kent State Universityfarrell/osf03/lectures/ch2-2up.pdf · 1 Operating System Concepts 2.1 Silberschatz, Galvin and Gagne 2002 Chapter 2: Computer -System

7

Silberschatz, Galvin and Gagne 20022.13Operating System Concepts

Moving-Head Disk Mechanism

Silberschatz, Galvin and Gagne 20022.14Operating System Concepts

Storage Hierarchy

n Storage systems organized in hierarchy.F SpeedF CostF Volatility

n Caching – copying information into faster storage system; main memory can be viewed as a last cache for secondary storage.

Page 8: Computer-System Architecture - Kent State Universityfarrell/osf03/lectures/ch2-2up.pdf · 1 Operating System Concepts 2.1 Silberschatz, Galvin and Gagne 2002 Chapter 2: Computer -System

8

Silberschatz, Galvin and Gagne 20022.15Operating System Concepts

Storage-Device Hierarchy

Silberschatz, Galvin and Gagne 20022.16Operating System Concepts

Caching

n Use of high-speed memory to hold recently-accessed data.

n Requires a cache management policy.n Caching introduces another level in storage hierarchy.

This requires data that is simultaneously stored in more than one level to be consistent .

Page 9: Computer-System Architecture - Kent State Universityfarrell/osf03/lectures/ch2-2up.pdf · 1 Operating System Concepts 2.1 Silberschatz, Galvin and Gagne 2002 Chapter 2: Computer -System

9

Silberschatz, Galvin and Gagne 20022.17Operating System Concepts

Migration of A From Disk to Register

Silberschatz, Galvin and Gagne 20022.18Operating System Concepts

Hardware Protection

n Dual-Mode Operationn I/O Protectionn Memory Protectionn CPU Protection

Page 10: Computer-System Architecture - Kent State Universityfarrell/osf03/lectures/ch2-2up.pdf · 1 Operating System Concepts 2.1 Silberschatz, Galvin and Gagne 2002 Chapter 2: Computer -System

10

Silberschatz, Galvin and Gagne 20022.19Operating System Concepts

Dual-Mode Operation

n Sharing system resources requires operating system to ensure that an incorrect program cannot cause other programs to execute incorrectly.

n Provide hardware support to differentiate between at least two modes of operations.1. User mode – execution done on behalf of a user.2. Monitor mode (also kernel mode or system mode) –

execution done on behalf of operating system.

Silberschatz, Galvin and Gagne 20022.20Operating System Concepts

Dual-Mode Operation (Cont.)

n Mode bit added to computer hardware to indicate the current mode: monitor (0) or user (1).

n When an interrupt or fault occurs hardware switches to monitor mode.

Privileged instructions can be issued only in monitor mode.

monitor user

Interrupt/fault

set user mode

Page 11: Computer-System Architecture - Kent State Universityfarrell/osf03/lectures/ch2-2up.pdf · 1 Operating System Concepts 2.1 Silberschatz, Galvin and Gagne 2002 Chapter 2: Computer -System

11

Silberschatz, Galvin and Gagne 20022.21Operating System Concepts

I/O Protection

n All I/O instructions are privileged instructions.n Must ensure that a user program could never gain control

of the computer in monitor mode (I.e., a user program that, as part of its execution, stores a new address in the interrupt vector).

Silberschatz, Galvin and Gagne 20022.22Operating System Concepts

Use of A System Call to Perform I/O

Page 12: Computer-System Architecture - Kent State Universityfarrell/osf03/lectures/ch2-2up.pdf · 1 Operating System Concepts 2.1 Silberschatz, Galvin and Gagne 2002 Chapter 2: Computer -System

12

Silberschatz, Galvin and Gagne 20022.23Operating System Concepts

Memory Protection

n Must provide memory protection at least for the interrupt vector and the interrupt service routines.

n In order to have memory protection, add two registers that determine the range of legal addresses a program may access:F Base register – holds the smallest legal physical memory

address.F Limit register – contains the size of the range

n Memory outside the defined range is protected.

Silberschatz, Galvin and Gagne 20022.24Operating System Concepts

Use of A Base and Limit Register

Page 13: Computer-System Architecture - Kent State Universityfarrell/osf03/lectures/ch2-2up.pdf · 1 Operating System Concepts 2.1 Silberschatz, Galvin and Gagne 2002 Chapter 2: Computer -System

13

Silberschatz, Galvin and Gagne 20022.25Operating System Concepts

Hardware Address Protection

Silberschatz, Galvin and Gagne 20022.26Operating System Concepts

Hardware Protection

n When executing in monitor mode, the operating system has unrestricted access to both monitor and user’s memory.

n The load instructions for the base and limit registers are privileged instructions.

Page 14: Computer-System Architecture - Kent State Universityfarrell/osf03/lectures/ch2-2up.pdf · 1 Operating System Concepts 2.1 Silberschatz, Galvin and Gagne 2002 Chapter 2: Computer -System

14

Silberschatz, Galvin and Gagne 20022.27Operating System Concepts

CPU Protection

n Timer – interrupts computer after specified period to ensure operating system maintains control.F Timer is decremented every clock tick.F When timer reaches the value 0, an interrupt occurs.

n Timer commonly used to implement time sharing.n Time also used to compute the current time.n Load-timer is a privileged instruction.

Silberschatz, Galvin and Gagne 20022.28Operating System Concepts

Network Structure

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

Page 15: Computer-System Architecture - Kent State Universityfarrell/osf03/lectures/ch2-2up.pdf · 1 Operating System Concepts 2.1 Silberschatz, Galvin and Gagne 2002 Chapter 2: Computer -System

15

Silberschatz, Galvin and Gagne 20022.29Operating System Concepts

Local Area Network Structure

Silberschatz, Galvin and Gagne 20022.30Operating System Concepts

Wide Area Network Structure