Академический Документы
Профессиональный Документы
Культура Документы
A. Frank - P. Weisberg
Contents
Computer System Organization Main Memory Management Memory Protection I/O Protection CPU Protection Types of Interrupts:
1. Traps 2. External interrupts 3. System calls A. Frank - P. Weisberg
A. Frank - P. Weisberg
Storage Structure
Main memory only large storage media that the CPU can access directly. Secondary storage extension of main memory that provides large nonvolatile storage capacity. Magnetic disks rigid metal or glass platters covered with magnetic recording material.
Disk surface is logically divided into tracks, which are subdivided into sectors. The disk controller determines the logical interaction between the device and the computer.
4
A. Frank - P. Weisberg
A. Frank - P. Weisberg
A. Frank - P. Weisberg
A. Frank - P. Weisberg
Caching
Important principle, performed at many levels in a computer (in hardware, operating system, software). Information in use is copied from slower to faster storage temporarily. Faster storage (cache) checked first to determine if information is there:
If it is, information used directly from the cache (fast). If not, data copied to cache and used there.
A. Frank - P. Weisberg
10
A. Frank - P. Weisberg
11
Memory Split
64K User Program 16K Resident Monitor 0K Fence Register
12
A. Frank - P. Weisberg
Fence Register
The Fence Register is loaded with the base of the user program (which is also the limit of the Resident Monitor). The user program can read any address but addressing access logic assures that it can write only to addresses that are larger than the Fence Register value. The instruction to load the Fence Register has to be privileged (i.e., can be executed only by the Resident Monitor) but how to ensure that?
13
A. Frank - P. Weisberg
Must ensure that a user program could never gain control of the computer in kernel mode. Privileged Instructions can be executed only in kernel mode. Solution: Mode bit (in Status Register).
14
A. Frank - P. Weisberg
user
15
A. Frank - P. Weisberg
set kernel mode instruction? Should be privileged? No, there should be no such instruction!
16
A. Frank - P. Weisberg
Memory Division
In order to have memory division protection, add two registers that determine the range of legal addresses a program may access:
base register holds the smallest legal physical memory address of the program. limit register contains the size of the range.
Base/Limit Registers are also called Lower/Upper Fence Registers. Memory outside the defined range is protected.
17
A. Frank - P. Weisberg
18
A. Frank - P. Weisberg
Protection Hardware
When executing in kernel mode, the operating system has unrestricted access to both system and users memory. The load instructions for the base and limit registers are privileged instructions (the read instructions for these registers need not be privileged). Privileged instructions can be issued only in kernel mode.
19
A. Frank - P. Weisberg
20
A. Frank - P. Weisberg
Traps
A trap/exception is a software-generated interrupt caused by an error of the program, for example:
arithmetic overflow/underflow division by zero execute illegal instruction reference outside users memory space.
A trap can be initiated also by an explicit trap instruction in the program. The trap uses the interrupt hardware to switch to kernel mode.
21
A. Frank - P. Weisberg
use fence registers and addressing access logic. use privileged fence load instruction. use mode bit. change to kernel mode only by interrupt hardware!
A. Frank - P. Weisberg
2. But how to protect fence registers? 3. But how to ensure privileged execution? 4. But how to protect mode bit?
Computer Dynamics
23
A. Frank - P. Weisberg
CPU checks for interrupts after each instruction. If no interrupts, then fetch next instruction of current program. If an interrupt is pending, then suspend execution of the current program, and execute the interrupt handler.
24
A. Frank - P. Weisberg
25
A. Frank - P. Weisberg
Interrupt Handler
A program that determines nature of the interrupt and performs whatever actions are needed. Interrupt transfers control to the interrupt handler, generally through the interrupt vector, which contains the addresses of all interrupt service routines, which determine how to handle. Interrupt architecture must save the state of the program (content of PC + registers + ...). Incoming interrupts are disabled while another interrupt is being processed to prevent a lost interrupt. Later, control must be transferred back to the interrupted program so that it can be resumed from point of interruption.
26
A. Frank - P. Weisberg
External Interrupts
An external interrupt is a temporal suspension of a process caused by an event external to that process and performed in such a way that the process can be resumed. External Interrupts are caused by events external to that process: I/O Timer Hardware failure
27
A. Frank - P. Weisberg
30
A. Frank - P. Weisberg
31
A. Frank - P. Weisberg
32
A. Frank - P. Weisberg
Asynchronous I/O After I/O starts, control returns to user program without waiting for I/O completion.
System call request to OS 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.
A. Frank - P. Weisberg
33
34
Asynchronous
Device-Status Table
35
A. Frank - P. Weisberg
I/O Protection
User process may accidentally or purposefully attempt to disrupt normal operation via illegal I/O instructions. All I/O devices need to be protected from wrongdoing by the users (e.g., prevent current program from reading control cards of next job). All I/O instructions need to be privileged instructions. Given that the I/O instructions are privileged, how does the user program perform I/O? Solution: System Calls (from programs).
37
A. Frank - P. Weisberg
System Call
The method used by a process to request action by the operating system: 1. After system call parameter preparations, it uses the trap instruction to transfer control to the requested service routine in the OS. 2. The system verifies that the parameters are correct and legal, and executes the request. 3. Returns control to the instruction following the system call.
38
A. Frank - P. Weisberg
39
A. Frank - P. Weisberg
40
A. Frank - P. Weisberg
CPU Protection
Timer interrupts computer after specified period to ensure operating system maintains control. Programmable interval timer used for timings, periodic interrupts. Set timer is a privileged instruction. Timer is commonly used to implement Time Sharing Systems.
41
A. Frank - P. Weisberg
Timer Dynamics
Timer used to prevent infinite loop or process hogging resources:
Set interrupt to occur after specific period. Operating system decrements timer counter. When counter is zero generates an interrupt. Set up before scheduling process to regain control or terminate program that exceeds allotted time.
42
A. Frank - P. Weisberg
44
A. Frank - P. Weisberg