Top Banner
Computer-System Computer-System Structures Structures Er.Harsimran Singh Er.Harsimran Singh www.ProgrammingPlaza.com www.ProgrammingPlaza.com
28
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Computer-System Structures Er.Harsimran Singh .

Computer-System Computer-System StructuresStructures

Er.Harsimran SinghEr.Harsimran Singh

www.ProgrammingPlaza.com www.ProgrammingPlaza.com

Page 2: Computer-System Structures Er.Harsimran Singh .

Computer-System StructuresComputer-System Structures

Computer System OperationComputer System Operation I/O Structure I/O Structure Storage StructureStorage Structure Storage HierarchyStorage Hierarchy Hardware ProtectionHardware Protection Network StructureNetwork Structure

Page 3: Computer-System Structures Er.Harsimran Singh .

A Modern Computer SystemA Modern Computer System

Page 4: Computer-System Structures Er.Harsimran Singh .

Computer-SystemComputer-System Operation Operation

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

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

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

operation by causing an operation by causing an interruptinterrupt

Page 5: Computer-System Structures Er.Harsimran Singh .

Common Functions of InterruptsCommon Functions of Interrupts

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

Interrupt architecture must save the address of the interrupted Interrupt architecture must save the address of the interrupted instructioninstruction

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

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

An operating system is An operating system is interruptinterrupt driven driven

Page 6: Computer-System Structures Er.Harsimran Singh .

I/O StructureI/O Structure

Synchronous I/OSynchronous I/O - After I/O starts, control returns to user - After I/O starts, control returns to user program only upon I/O completionprogram only upon I/O completion

--Wait instruction idles the CPU until the next interruptWait instruction idles the CPU until the next interrupt

-Wait loop (contention for memory access)-Wait loop (contention for memory access)-At most one I/O request is outstanding at a time, no -At most one I/O request is outstanding at a time, no

simultaneous I/O processingsimultaneous I/O processing Asynchronous I/OAsynchronous I/O - After I/O starts, control returns to user - After I/O starts, control returns to user

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

user to wait for I/O completionuser 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 stateindicating 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 interruptinclude interrupt

Page 7: Computer-System Structures Er.Harsimran Singh .

Two I/O MethodsTwo I/O Methods

Synchronous Asynchronous

Page 8: Computer-System Structures Er.Harsimran Singh .

Direct Memory Access StructureDirect Memory Access Structure

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

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

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

Page 9: Computer-System Structures Er.Harsimran Singh .

Storage StructureStorage Structure

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

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

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

subdivided into subdivided into sectorssectors The The disk controllerdisk controller determines the logical interaction determines the logical interaction

between the device and the computerbetween the device and the computer

Page 10: Computer-System Structures Er.Harsimran Singh .

Moving-Head Disk MechanismMoving-Head Disk Mechanism

Page 11: Computer-System Structures Er.Harsimran Singh .

Storage HierarchyStorage Hierarchy

Storage systems organized in hierarchyStorage systems organized in hierarchy SpeedSpeed CostCost VolatilityVolatility

CachingCaching – copying information into faster storage system; – copying information into faster storage system; main memory can be viewed as a last main memory can be viewed as a last cachecache for secondary for secondary storagestorage

Page 12: Computer-System Structures Er.Harsimran Singh .

Storage-Device HierarchyStorage-Device Hierarchy

Page 13: Computer-System Structures Er.Harsimran Singh .

CachingCaching

Use of high-speed memory to hold recently-accessed dataUse of high-speed memory to hold recently-accessed data Requires a Requires a cache managementcache management policy policy Caching introduces another level in storage hierarchy. Caching introduces another level in storage hierarchy.

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

Page 14: Computer-System Structures Er.Harsimran Singh .

Migration of Integer “A” From Disk to RegisterMigration of Integer “A” From Disk to Register

Page 15: Computer-System Structures Er.Harsimran Singh .

Hardware ProtectionHardware Protection

Dual-Mode OperationDual-Mode Operation I/O ProtectionI/O Protection Memory ProtectionMemory Protection CPU ProtectionCPU Protection

Page 16: Computer-System Structures Er.Harsimran Singh .

Dual-Mode OperationDual-Mode Operation

Sharing system resources requires operating system to ensure Sharing system resources requires operating system to ensure that an incorrect program or poorly behaving human cannot that an incorrect program or poorly behaving human cannot cause other programs to execute incorrectlycause other programs to execute incorrectly

OS must provide hardware support to differentiate between at OS must provide hardware support to differentiate between at least two modes of operationsleast 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 modesystem mode) – ) – execution done on behalf of operating systemexecution done on behalf of operating system

Page 17: Computer-System Structures Er.Harsimran Singh .

Dual-Mode Operation (Cont.)Dual-Mode Operation (Cont.)

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 When an interrupt or fault occurs hardware switches to monitor modemonitor mode

Privileged instructions can be issued only in monitor mode

monitor user

Interrupt/fault

set user mode

Page 18: Computer-System Structures Er.Harsimran Singh .

I/O ProtectionI/O Protection

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

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

Page 19: Computer-System Structures Er.Harsimran Singh .

Use of A System Call to Perform I/OUse of A System Call to Perform I/O

Page 20: Computer-System Structures Er.Harsimran Singh .

Memory ProtectionMemory Protection

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

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

addressaddress Limit registerLimit register – contains the size of the range – contains the size of the range

Memory outside the defined range is protectedMemory outside the defined range is protected

Page 21: Computer-System Structures Er.Harsimran Singh .

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

Page 22: Computer-System Structures Er.Harsimran Singh .

Hardware Address ProtectionHardware Address Protection

Page 23: Computer-System Structures Er.Harsimran Singh .

Hardware ProtectionHardware 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 memoryunrestricted 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 instructionsprivileged instructions

Page 24: Computer-System Structures Er.Harsimran Singh .

CPU ProtectionCPU Protection

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

Timer commonly used to implement time sharingTimer commonly used to implement time sharing Time also used to compute the current timeTime also used to compute the current time Load-timer is a privileged instructionLoad-timer is a privileged instruction

Page 25: Computer-System Structures Er.Harsimran Singh .

General-System ArchitectureGeneral-System Architecture

Given the I/O instructions are privileged, how does the user Given the I/O instructions are privileged, how does the user program perform I/O?program perform I/O?

System call – the method used by a process to request action System call – the method used by a process to request action by the operating systemby the operating system Usually takes the form of a trap to a specific location in the Usually takes the form of a trap to a specific location in the

interrupt vectorinterrupt vector Control passes through the interrupt vector to a service Control passes through the interrupt vector to a service

routine in the OS, and the mode bit is set to monitor moderoutine in the OS, and the mode bit is set to monitor mode The monitor verifies that the parameters are correct and The monitor verifies that the parameters are correct and

legal, executes the request, and returns control to the legal, executes the request, and returns control to the instruction following the system callinstruction following the system call

Page 26: Computer-System Structures Er.Harsimran Singh .

Network StructureNetwork Structure

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

Page 27: Computer-System Structures Er.Harsimran Singh .

Local Area Network StructureLocal Area Network Structure

Page 28: Computer-System Structures Er.Harsimran Singh .

Wide Area Network StructureWide Area Network Structure