CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O...

28
CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure Storage hierarchy Storage hierarchy Hardware protection Hardware protection General system architecture General system architecture

Transcript of CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O...

Page 1: CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.

CHAPTER 2: COMPUTER-SYSTEM STRUCTURES

Computer system operationComputer system operation I/O structure I/O structure Storage structureStorage structure Storage hierarchyStorage hierarchy Hardware protectionHardware protection General system architectureGeneral system architecture

Page 2: CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.

COMPUTER SYSTEM OPERATION

Page 3: CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.

Computer System Operation The CPU and I/O devices can execute concurrently.The CPU and I/O devices can execute concurrently. CPU CPU

fetches a instruction and executes it.fetches a instruction and executes it. moves data from/to main memory to/from local moves data from/to main memory to/from local

buffers.buffers. Each device controller Each device controller

is in charge of a particular device type.is in charge of a particular device type. has a local buffer. I/O is from the device to local has a local buffer. I/O is from the device to local

buffer of controller.buffer of controller. informs CPU that it has finished its operation by informs CPU that it has finished its operation by

causing an causing an interruptinterrupt..

Page 4: CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.

Computer System Operation An operating system is An operating system is interruptinterrupt driven. driven.

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

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

Incoming interrupts are Incoming interrupts are disableddisabled while another while another interrupt is being processed to prevent a interrupt is being processed to prevent a lost lost interruptinterrupt..

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

Page 5: CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.

Computer System Operation

Interrupt handlingInterrupt handling The operating system preserves the state of the CPU The operating system preserves the state of the CPU

by storing registers and the program counter.by storing registers and the program counter. Determines which type of interrupt has occurred:Determines which type of interrupt has occurred:

pollingpollingvectoredvectored interrupt system. interrupt system.

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

Returns to the saved state or other parts of OS.Returns to the saved state or other parts of OS.

Page 6: CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.

Computer System Operation

Interrupt Time Line For a Single Process Doing OutputInterrupt Time Line For a Single Process Doing Output

Page 7: CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.

I/O STRUCTURE

Synchronous I/O: Synchronous I/O: After I/O starts, control returns to the user program only After I/O starts, control returns to the user program only

upon I/O completion.upon I/O completion. How to wait for I/O completion: How to wait for I/O completion:

Wait instruction idles the CPU until the next interrupt. Wait instruction idles the CPU until the next interrupt. Wait loop (contention for memory access).Wait loop (contention for memory access).

If the CPU always waits for I/O completion, at most one If the CPU always waits for I/O completion, at most one I/O request is outstanding at a time,. Thus, whenever an I/O request is outstanding at a time,. Thus, whenever an I/O interrupt occurs, the OS knows exactly which device I/O interrupt occurs, the OS knows exactly which device is interrupting.is interrupting.

This approach excludes concurrent I/O operations to This approach excludes concurrent I/O operations to several devices, and also excludes the possibility of several devices, and also excludes the possibility of overlapping useful computation with I/O.overlapping useful computation with I/O.

Page 8: CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.

I/O Structure

Asynchronous I/O:Asynchronous I/O: After I/O starts, control returns to the user program After I/O starts, control returns to the user program

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

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

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

determine device status and to modify table entry to determine device status and to modify table entry to include interrupt.include interrupt.

Page 9: CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.

I/O Structure: DMA

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

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

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

Page 10: CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.

STORAGE STRUCTURE

Main memory – only large storage media that the CPU Main memory – only large storage media that the CPU can access directly.can access directly.

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

Magnetic disks – rigid metal or glass platters covered Magnetic disks – rigid metal or glass platters covered with magnetic recording material (See the next slide)with magnetic recording material (See the next slide) Disk surface is logically divided into Disk surface is logically divided into trackstracks, which , which

are subdivided into are subdivided into sectorssectors.. The The disk controllerdisk controller determines the logical determines the logical

interaction between the device and the computer.interaction between the device and the computer. Magnetic tapes: sequential access, large capacity. Magnetic tapes: sequential access, large capacity.

Page 11: CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.

Storage Structure

Page 12: CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.

STORAGE HIERARCHY

Page 13: CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.

Storage Hierarchy Storage systems organized in hierarchy.Storage systems organized in hierarchy.

Speed,Speed, Cost,Cost, Volatility.Volatility.

The design of a complete memory system must balance The design of a complete memory system must balance all these factors: all these factors: It uses only It uses only as much expensive memory as necessaryas much expensive memory as necessary, , while providing while providing as much inexpensive, nonvolatile as much inexpensive, nonvolatile

memory as possible.memory as possible.

Page 14: CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.

Storage Hierarchy: CachingCaching is an important principle of computer system:Caching is an important principle of computer system: Information is normally kept in some storage system. Information is normally kept in some storage system. As it is used, it is copied into a faster storage system – As it is used, it is copied into a faster storage system –

the cache – on a temporary basis. the cache – on a temporary basis. When we need a particular piece of information, we When we need a particular piece of information, we

first check whether it is in the cache. first check whether it is in the cache. If it is, we use the information directly from the If it is, we use the information directly from the

cache;cache; If it is not, we use the information from the main If it is not, we use the information from the main

storage system, putting a copy in the cache under the storage system, putting a copy in the cache under the assumption that we will need it again soon. assumption that we will need it again soon.

Page 15: CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.

Storage Hierarchy: Caching Use of high-speed memory to hold recently-accessed Use of high-speed memory to hold recently-accessed

data.data. Requires a Requires a cache managementcache management policy. policy. An example: Main memory can be viewed as a fast An example: Main memory can be viewed as a fast

ache for secondary storage. ache for secondary storage. The movement of information between levels of a The movement of information between levels of a

storage hierarchy may be either explicit or implicit, storage hierarchy may be either explicit or implicit, depending on the hardware design and the controlling depending on the hardware design and the controlling operating–system softwareoperating–system software Data transfer from ache to CPU and registers,Data transfer from ache to CPU and registers, Data transfer from disk to memory. Data transfer from disk to memory.

Page 16: CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.

Storage Hierarchy: Consistency

Page 17: CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.

HARDWARE PROTECTION

Dual-mode operationDual-mode operation I/O protectionI/O protection Memory protectionMemory protection CPU protectionCPU protection

Page 18: CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.

Hardware Protection: Dual-mode operation

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

Provide hardware support to differentiate between at Provide hardware support to differentiate between at least two modes of operations.least two modes of operations.

1.1.User modeUser mode – execution done on behalf of a user. – execution done on behalf of a user.

2.2.Monitor modeMonitor mode (also (also kernel modekernel mode or or system mode system mode oror privileged modeprivileged mode) – execution done on behalf of ) – execution done on behalf of operating system.operating system.

Page 19: CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.

Hardware Protection: Dual-mode operation

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

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

Privileged instructions can be issued only in monitor mode.

monitor user

Interrupt/fault

set user mode

Page 20: CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.

Hardware Protection: I/O protection To prevent users from performing illegal I/O, we define To prevent users from performing illegal I/O, we define

all I/O instructions to be privileged instructions.all I/O instructions to be privileged instructions. To do I/O, To do I/O,

A user program executes a system call to request that A user program executes a system call to request that the OS perform I/O on its behalf. the OS perform I/O on its behalf.

The OS, executing in monitor mode, checks that the The OS, executing in monitor mode, checks that the request is valid and (if the request is valid) does the I/O request is valid and (if the request is valid) does the I/O request. request.

The OS then returns to the user. The OS then returns to the user. Must ensure that a user program could never gain control Must ensure that a user program could never gain control

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

Page 21: CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.

Hardware Protection: Memory protection

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

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

physical memory address.physical memory address. Limit registerLimit register – contains the size of the – contains the size of the

range. range. Memory outside the defined range is protected.Memory outside the defined range is protected.

Page 22: CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.

Hardware Protection: Memory protection

Use of A Base and Limit RegisterUse of A Base and Limit Register

Page 23: CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.

Hardware Protection: Memory protection

Hardware Address ProtectionHardware Address Protection When executing in monitor mode, the operating system has When executing in monitor mode, the operating system has

unrestricted access to both monitor and user’s memory.unrestricted access to both monitor and user’s memory. The load instructions for the The load instructions for the basebase and and limitlimit registers are registers are

privileged instructions.privileged instructions.

Page 24: CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.

Hardware Protection: CPU protection TimerTimer – interrupts computer after specified period to – interrupts computer after specified period to

ensure operating system maintains control.ensure operating system maintains control. To use the timer to prevent a user program from To use the timer to prevent a user program from

running too longrunning too long To initialize a counter with the amount of time that a To initialize a counter with the amount of time that a

program is allowed to run.program is allowed to run. The timer is decremented every clock tick.The timer is decremented every clock tick. When the timer reaches the value 0, an interrupt When the timer reaches the value 0, an interrupt

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

Page 25: CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.

NETWORK STRUCTURE

Two types of networksTwo types of networks Local-area networks (LAN)Local-area networks (LAN)

Over small geographical areas (such as a single Over small geographical areas (such as a single building)building)

Fast,Fast,Reliable.Reliable.

Wide-area networks (WAN)Wide-area networks (WAN)Over a large geographical area (such as the US)Over a large geographical area (such as the US)Slow,Slow,Unreliable.Unreliable.

Page 26: CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.

Network Structure: LAN

Page 27: CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.

Network Structure: WAN

Page 28: CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.