chapter 2: computer-system structuresfarrell/osf03/lectures/ch2-1up.pdf4 operating system concepts...
TRANSCRIPT
![Page 1: Chapter 2: Computer-System Structuresfarrell/osf03/lectures/ch2-1up.pdf4 Operating System Concepts 2.4 Silberschatz, Galvin and Gagne 2002 Computer-System Operation n I/O devices and](https://reader034.vdocuments.net/reader034/viewer/2022052612/5f0ce1907e708231d43797f5/html5/thumbnails/1.jpg)
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
![Page 2: Chapter 2: Computer-System Structuresfarrell/osf03/lectures/ch2-1up.pdf4 Operating System Concepts 2.4 Silberschatz, Galvin and Gagne 2002 Computer-System Operation n I/O devices and](https://reader034.vdocuments.net/reader034/viewer/2022052612/5f0ce1907e708231d43797f5/html5/thumbnails/2.jpg)
2
Silberschatz, Galvin and Gagne 20022.2Operating System Concepts
Computer-System Architecture
![Page 3: Chapter 2: Computer-System Structuresfarrell/osf03/lectures/ch2-1up.pdf4 Operating System Concepts 2.4 Silberschatz, Galvin and Gagne 2002 Computer-System Operation n I/O devices and](https://reader034.vdocuments.net/reader034/viewer/2022052612/5f0ce1907e708231d43797f5/html5/thumbnails/3.jpg)
3
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)
![Page 4: Chapter 2: Computer-System Structuresfarrell/osf03/lectures/ch2-1up.pdf4 Operating System Concepts 2.4 Silberschatz, Galvin and Gagne 2002 Computer-System Operation n I/O devices and](https://reader034.vdocuments.net/reader034/viewer/2022052612/5f0ce1907e708231d43797f5/html5/thumbnails/4.jpg)
4
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 buffers
n 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 5: Chapter 2: Computer-System Structuresfarrell/osf03/lectures/ch2-1up.pdf4 Operating System Concepts 2.4 Silberschatz, Galvin and Gagne 2002 Computer-System Operation n I/O devices and](https://reader034.vdocuments.net/reader034/viewer/2022052612/5f0ce1907e708231d43797f5/html5/thumbnails/5.jpg)
5
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.
![Page 6: Chapter 2: Computer-System Structuresfarrell/osf03/lectures/ch2-1up.pdf4 Operating System Concepts 2.4 Silberschatz, Galvin and Gagne 2002 Computer-System Operation n I/O devices and](https://reader034.vdocuments.net/reader034/viewer/2022052612/5f0ce1907e708231d43797f5/html5/thumbnails/6.jpg)
6
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 7: Chapter 2: Computer-System Structuresfarrell/osf03/lectures/ch2-1up.pdf4 Operating System Concepts 2.4 Silberschatz, Galvin and Gagne 2002 Computer-System Operation n I/O devices and](https://reader034.vdocuments.net/reader034/viewer/2022052612/5f0ce1907e708231d43797f5/html5/thumbnails/7.jpg)
7
Silberschatz, Galvin and Gagne 20022.7Operating System Concepts
Interrupt Time Line For a Single Process Doing Output
![Page 8: Chapter 2: Computer-System Structuresfarrell/osf03/lectures/ch2-1up.pdf4 Operating System Concepts 2.4 Silberschatz, Galvin and Gagne 2002 Computer-System Operation n I/O devices and](https://reader034.vdocuments.net/reader034/viewer/2022052612/5f0ce1907e708231d43797f5/html5/thumbnails/8.jpg)
8
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 9: Chapter 2: Computer-System Structuresfarrell/osf03/lectures/ch2-1up.pdf4 Operating System Concepts 2.4 Silberschatz, Galvin and Gagne 2002 Computer-System Operation n I/O devices and](https://reader034.vdocuments.net/reader034/viewer/2022052612/5f0ce1907e708231d43797f5/html5/thumbnails/9.jpg)
9
Silberschatz, Galvin and Gagne 20022.9Operating System Concepts
Two I/O Methods
Synchronous Asynchronous
![Page 10: Chapter 2: Computer-System Structuresfarrell/osf03/lectures/ch2-1up.pdf4 Operating System Concepts 2.4 Silberschatz, Galvin and Gagne 2002 Computer-System Operation n I/O devices and](https://reader034.vdocuments.net/reader034/viewer/2022052612/5f0ce1907e708231d43797f5/html5/thumbnails/10.jpg)
10
Silberschatz, Galvin and Gagne 20022.10Operating System Concepts
Device-Status Table
![Page 11: Chapter 2: Computer-System Structuresfarrell/osf03/lectures/ch2-1up.pdf4 Operating System Concepts 2.4 Silberschatz, Galvin and Gagne 2002 Computer-System Operation n I/O devices and](https://reader034.vdocuments.net/reader034/viewer/2022052612/5f0ce1907e708231d43797f5/html5/thumbnails/11.jpg)
11
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.
![Page 12: Chapter 2: Computer-System Structuresfarrell/osf03/lectures/ch2-1up.pdf4 Operating System Concepts 2.4 Silberschatz, Galvin and Gagne 2002 Computer-System Operation n I/O devices and](https://reader034.vdocuments.net/reader034/viewer/2022052612/5f0ce1907e708231d43797f5/html5/thumbnails/12.jpg)
12
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 13: Chapter 2: Computer-System Structuresfarrell/osf03/lectures/ch2-1up.pdf4 Operating System Concepts 2.4 Silberschatz, Galvin and Gagne 2002 Computer-System Operation n I/O devices and](https://reader034.vdocuments.net/reader034/viewer/2022052612/5f0ce1907e708231d43797f5/html5/thumbnails/13.jpg)
13
Silberschatz, Galvin and Gagne 20022.13Operating System Concepts
Moving-Head Disk Mechanism
![Page 14: Chapter 2: Computer-System Structuresfarrell/osf03/lectures/ch2-1up.pdf4 Operating System Concepts 2.4 Silberschatz, Galvin and Gagne 2002 Computer-System Operation n I/O devices and](https://reader034.vdocuments.net/reader034/viewer/2022052612/5f0ce1907e708231d43797f5/html5/thumbnails/14.jpg)
14
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 15: Chapter 2: Computer-System Structuresfarrell/osf03/lectures/ch2-1up.pdf4 Operating System Concepts 2.4 Silberschatz, Galvin and Gagne 2002 Computer-System Operation n I/O devices and](https://reader034.vdocuments.net/reader034/viewer/2022052612/5f0ce1907e708231d43797f5/html5/thumbnails/15.jpg)
15
Silberschatz, Galvin and Gagne 20022.15Operating System Concepts
Storage-Device Hierarchy
![Page 16: Chapter 2: Computer-System Structuresfarrell/osf03/lectures/ch2-1up.pdf4 Operating System Concepts 2.4 Silberschatz, Galvin and Gagne 2002 Computer-System Operation n I/O devices and](https://reader034.vdocuments.net/reader034/viewer/2022052612/5f0ce1907e708231d43797f5/html5/thumbnails/16.jpg)
16
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 17: Chapter 2: Computer-System Structuresfarrell/osf03/lectures/ch2-1up.pdf4 Operating System Concepts 2.4 Silberschatz, Galvin and Gagne 2002 Computer-System Operation n I/O devices and](https://reader034.vdocuments.net/reader034/viewer/2022052612/5f0ce1907e708231d43797f5/html5/thumbnails/17.jpg)
17
Silberschatz, Galvin and Gagne 20022.17Operating System Concepts
Migration of A From Disk to Register
![Page 18: Chapter 2: Computer-System Structuresfarrell/osf03/lectures/ch2-1up.pdf4 Operating System Concepts 2.4 Silberschatz, Galvin and Gagne 2002 Computer-System Operation n I/O devices and](https://reader034.vdocuments.net/reader034/viewer/2022052612/5f0ce1907e708231d43797f5/html5/thumbnails/18.jpg)
18
Silberschatz, Galvin and Gagne 20022.18Operating System Concepts
Hardware Protection
n Dual-Mode Operationn I/O Protection
n Memory Protectionn CPU Protection
![Page 19: Chapter 2: Computer-System Structuresfarrell/osf03/lectures/ch2-1up.pdf4 Operating System Concepts 2.4 Silberschatz, Galvin and Gagne 2002 Computer-System Operation n I/O devices and](https://reader034.vdocuments.net/reader034/viewer/2022052612/5f0ce1907e708231d43797f5/html5/thumbnails/19.jpg)
19
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.
![Page 20: Chapter 2: Computer-System Structuresfarrell/osf03/lectures/ch2-1up.pdf4 Operating System Concepts 2.4 Silberschatz, Galvin and Gagne 2002 Computer-System Operation n I/O devices and](https://reader034.vdocuments.net/reader034/viewer/2022052612/5f0ce1907e708231d43797f5/html5/thumbnails/20.jpg)
20
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 21: Chapter 2: Computer-System Structuresfarrell/osf03/lectures/ch2-1up.pdf4 Operating System Concepts 2.4 Silberschatz, Galvin and Gagne 2002 Computer-System Operation n I/O devices and](https://reader034.vdocuments.net/reader034/viewer/2022052612/5f0ce1907e708231d43797f5/html5/thumbnails/21.jpg)
21
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).
![Page 22: Chapter 2: Computer-System Structuresfarrell/osf03/lectures/ch2-1up.pdf4 Operating System Concepts 2.4 Silberschatz, Galvin and Gagne 2002 Computer-System Operation n I/O devices and](https://reader034.vdocuments.net/reader034/viewer/2022052612/5f0ce1907e708231d43797f5/html5/thumbnails/22.jpg)
22
Silberschatz, Galvin and Gagne 20022.22Operating System Concepts
Use of A System Call to Perform I/O
![Page 23: Chapter 2: Computer-System Structuresfarrell/osf03/lectures/ch2-1up.pdf4 Operating System Concepts 2.4 Silberschatz, Galvin and Gagne 2002 Computer-System Operation n I/O devices and](https://reader034.vdocuments.net/reader034/viewer/2022052612/5f0ce1907e708231d43797f5/html5/thumbnails/23.jpg)
23
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.
![Page 24: Chapter 2: Computer-System Structuresfarrell/osf03/lectures/ch2-1up.pdf4 Operating System Concepts 2.4 Silberschatz, Galvin and Gagne 2002 Computer-System Operation n I/O devices and](https://reader034.vdocuments.net/reader034/viewer/2022052612/5f0ce1907e708231d43797f5/html5/thumbnails/24.jpg)
24
Silberschatz, Galvin and Gagne 20022.24Operating System Concepts
Use of A Base and Limit Register
![Page 25: Chapter 2: Computer-System Structuresfarrell/osf03/lectures/ch2-1up.pdf4 Operating System Concepts 2.4 Silberschatz, Galvin and Gagne 2002 Computer-System Operation n I/O devices and](https://reader034.vdocuments.net/reader034/viewer/2022052612/5f0ce1907e708231d43797f5/html5/thumbnails/25.jpg)
25
Silberschatz, Galvin and Gagne 20022.25Operating System Concepts
Hardware Address Protection
![Page 26: Chapter 2: Computer-System Structuresfarrell/osf03/lectures/ch2-1up.pdf4 Operating System Concepts 2.4 Silberschatz, Galvin and Gagne 2002 Computer-System Operation n I/O devices and](https://reader034.vdocuments.net/reader034/viewer/2022052612/5f0ce1907e708231d43797f5/html5/thumbnails/26.jpg)
26
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 27: Chapter 2: Computer-System Structuresfarrell/osf03/lectures/ch2-1up.pdf4 Operating System Concepts 2.4 Silberschatz, Galvin and Gagne 2002 Computer-System Operation n I/O devices and](https://reader034.vdocuments.net/reader034/viewer/2022052612/5f0ce1907e708231d43797f5/html5/thumbnails/27.jpg)
27
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.
![Page 28: Chapter 2: Computer-System Structuresfarrell/osf03/lectures/ch2-1up.pdf4 Operating System Concepts 2.4 Silberschatz, Galvin and Gagne 2002 Computer-System Operation n I/O devices and](https://reader034.vdocuments.net/reader034/viewer/2022052612/5f0ce1907e708231d43797f5/html5/thumbnails/28.jpg)
28
Silberschatz, Galvin and Gagne 20022.28Operating System Concepts
Network Structure
n Local Area Networks (LAN)n Wide Area Networks (WAN)
![Page 29: Chapter 2: Computer-System Structuresfarrell/osf03/lectures/ch2-1up.pdf4 Operating System Concepts 2.4 Silberschatz, Galvin and Gagne 2002 Computer-System Operation n I/O devices and](https://reader034.vdocuments.net/reader034/viewer/2022052612/5f0ce1907e708231d43797f5/html5/thumbnails/29.jpg)
29
Silberschatz, Galvin and Gagne 20022.29Operating System Concepts
Local Area Network Structure
![Page 30: Chapter 2: Computer-System Structuresfarrell/osf03/lectures/ch2-1up.pdf4 Operating System Concepts 2.4 Silberschatz, Galvin and Gagne 2002 Computer-System Operation n I/O devices and](https://reader034.vdocuments.net/reader034/viewer/2022052612/5f0ce1907e708231d43797f5/html5/thumbnails/30.jpg)
30
Silberschatz, Galvin and Gagne 20022.30Operating System Concepts
Wide Area Network Structure