CS4315A. Berrached:CMS:UHD1 Operating Systems and Computer Organization Chapter 4.

Slides:



Advertisements
Similar presentations
Computer-System Structures Er.Harsimran Singh
Advertisements

1 (Review of Prerequisite Material). Processes are an abstraction of the operation of computers. So, to understand operating systems, one must have a.
Slide 4-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 4 Computer Organization.
Slide 3-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 3 3 Operating System Organization.
Computer System Overview
FIU Chapter 7: Input/Output Jerome Crooks Panyawat Chiamprasert
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
OS2-1 Chapter 2 Computer System Structures. OS2-2 Outlines Computer System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
© 2004, D. J. Foreman 1 Computer Organization. © 2004, D. J. Foreman 2 Basic Architecture Review  Von Neumann ■ Distinct single-ALU & single-Control.
OS Spring’03 Introduction Operating Systems Spring 2003.
Abhinav Kamra Computer Science, Columbia University 2.1 Operating System Concepts Silberschatz, Galvin and Gagne  2002 Chapter 2: Computer-System Structures.
Computer System Organization S H Srinivasan
Computer System Structures memory memory controller disk controller disk controller printer controller printer controller tape-drive controller tape-drive.
General System Architecture and I/O.  I/O devices and the CPU can execute concurrently.  Each device controller is in charge of a particular device.
Computer Organization
System Calls 1.
Chapter 1. Introduction What is an Operating System? Mainframe Systems
1 Computer System Overview Chapter 1. 2 n An Operating System makes the computing power available to users by controlling the hardware n Let us review.
Input and Output Computer Organization and Assembly Language: Module 9.
2.1 Silberschatz, Galvin and Gagne ©2003 Operating System Concepts with Java Chapter 2: Computer-System Structures Computer System Operation I/O Structure.
CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.
Silberschatz, Galvin, and Gagne  Applied Operating System Concepts Module 2: Computer-System Structures Computer System Operation I/O Structure.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
Chapter 2: Computer-System Structures
Thanks to Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2 Computer-System Structures n Computer System Operation n I/O Structure.
1 CSE Department MAITSandeep Tayal Computer-System Structures Computer System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection.
2: Computer-System Structures
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Overview of Hardware.
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.
Chapter 2: Computer-System Structures 2.1 Computer System Operation 2.5 Hardware Protection 2.6 Network Structure.
1 Chapter 2: Computer-System Structures  Computer System Operation  I/O Structure  Storage Structure  Storage Hierarchy  Hardware Protection  General.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection Network Structure.
2.1 Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation Storage Structure Storage Hierarchy Hardware Protection General.
© 2004, D. J. Foreman 1 Computer Organization. © 2004, D. J. Foreman 2 Basic Architecture Review  Von Neumann ■ Distinct single-ALU & single-Control.
© 2004, D. J. Foreman 1 Computer Organization. © 2004, D. J. Foreman 2 Basic Architecture Review  Von Neumann ■ Distinct single-ALU & single-Control.
Interrupt driven I/O. MIPS RISC Exception Mechanism The processor operates in The processor operates in user mode user mode kernel mode kernel mode Access.
Slide 4-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 4 4 Computer Organization.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Operating Systems 1 K. Salah Module 1.2: Fundamental Concepts Interrupts System Calls.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 2 Computer-System Structures Slide 1 Chapter 2 Computer-System Structures.
Silberschatz, Galvin and Gagne  Applied Operating System Concepts Chapter 2: Computer-System Structures Computer System Architecture and Operation.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
C HAPTER 4 OS: C OMPUTER O RGANIZATION TOPICS: The Von Neumann Architecture The CPU.
CS4315A. Berrached:CMS:UHD1 Operating Systems and Computer Organization Chapter 4.
Computer Organization (Review of Prerequisite Material)
Slide 4-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 4 4 Computer Organization.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
Chapter 2: Computer-System Structures(Hardware) or Architecture or Organization Computer System Operation I/O Structure Storage Structure Storage Hierarchy.
Slide 4-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 4.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
Chapter 2: Computer-System Structures(Hardware)
Computer System Overview
Chapter 2: Computer-System Structures
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
Operating Systems: A Modern Perspective, Chapter 4
Computer Organization
Computer-System Architecture
Module 2: Computer-System Structures
Outline Computer Organization Devices Interrupts Computer architecture
Computer Organization
Module 2: Computer-System Structures
Chapter 2: Computer-System Structures
Chapter 2: Computer-System Structures
Module 2: Computer-System Structures
Module 2: Computer-System Structures
Presentation transcript:

CS4315A. Berrached:CMS:UHD1 Operating Systems and Computer Organization Chapter 4

CS4315A. Berrached:CMS:UHD2 Operating System and Computer Organization Organization of Conventional Computers The ALU The Control Unit The Memory Unit I/O Devices Interrupts Hardware protection

CS4315A. Berrached:CMS:UHD3 Conventional Computer Organization

CS4315A. Berrached:CMS:UHD4 The ALU Status Registers Operands Result MDRMAR To/from main memory R1 R2 Rn …. Functional Unit CMD

CS4315A. Berrached:CMS:UHD5 Memory Data Access Main Memory

CS4315A. Berrached:CMS:UHD6 Program Specification

CS4315A. Berrached:CMS:UHD7 Machine Language

CS4315A. Berrached:CMS:UHD8 Control Unit

CS4315A. Berrached:CMS:UHD9 Control Unit Operation Instruction Fetch Phase: instruction is retrieved from memory Instruction Decode Phase: instruction is decoded and control signals generated Instruction Execute Phase: ALU op, memory data access, or I/O op is executed.

CS4315A. Berrached:CMS:UHD10 Control Unit Operation PC = ; IR = Memory[PC] ; haltFlag = CLEAR ; Decode(IR); while (haltFlag not SET) { Execute(IR); PC = PC + InstructionSize; IR = Memory[PC] ; Decode(IR); }

CS4315A. Berrached:CMS:UHD11 How does it all start? When the computer is started, the control unit branches to a fixed memory location; e.g. initial PC value hardwired. The fixed location is a ROM address that contains a the BIOS loader. The BIOS loader loads a “bootstrap loader” from the disk “boot sector” into memory and branches to the bootstrap loader program. The bootstrap loader may be comprehensive enough to load the nucleus of the OS; Otherwise, it loads a loader program that does so. Once bootstrap phase is done, any program can be run by loading it in memory and loading its initial address in the PC (fetch-decode-exec algorithm)

CS4315A. Berrached:CMS:UHD12 Bootstrapping Bootstrap loader (“boot sector”) Primary Memory 1 0x Fetch Unit Decode Unit Execute Unit … … PC IR BIOS loader 0x

CS4315A. Berrached:CMS:UHD13 Bootstrapping Bootstrap loader (“boot sector”) Primary Memory Loader 1 2 Fetch Unit Decode Unit Execute Unit … … PC IR BIOS loader 0x x x

CS4315A. Berrached:CMS:UHD14 Bootstrapping Bootstrap loader (“boot sector”) Primary Memory Loader OS Fetch Unit Decode Unit Execute Unit … … PC IR BIOS loader 0x x x x000A000

CS4315A. Berrached:CMS:UHD15 Bootstrapping Bootstrap loader (“boot sector”) Primary Memory Loader OS Initialize hardware 5. Create user environment 6. … Fetch Unit Decode Unit Execute Unit 000A000 … … PC IR BIOS loader 0x x x x000A000

CS4315A. Berrached:CMS:UHD16 Primary Memory Unit Main (Primary) Memory holds both program and data while they are being executed by CPU. The main memory interface consists of the registers: MAR, MDR, CMD. Unit of information accessed depends on the width of memory and width of data bus. Max. addressing space depends on width of address bus. One request at a time. CPU and I/O devices may contend for memory access.

CS4315A. Berrached:CMS:UHD17 Primary Memory Unit MAR MDR Command n Read Op: Load MAR with address read 2. Load Command with “read” Data will then appear in the MDR

CS4315A. Berrached:CMS:UHD18 I/O devices Each I/O device consists of a device controller and the physical device itself. Devices: - storage devices: for permanent storage (e.g. disk, tape) - communication devices: to transfer data from the computer to another machine (e.g. keyboard, a terminal display, or a serial port to a modem or a network).

CS4315A. Berrached:CMS:UHD19 I/O Devices (cont.) Device controller: hardware that connects the device to the computer. –continuously monitors and controls the operation of the device. – provides an interface to the computer. Device Manager: program (part of the OS) that manages device controllers

CS4315A. Berrached:CMS:UHD20 The Device-Controller-Software Relationship Application Program Device Controller Device Software in the CPU Abstract I/O Machine Device manager: Program to manage device controllers

CS4315A. Berrached:CMS:UHD21 Device Controller Interface Command Status Data 0 Data 1 Data n-1 Logic busydoneError code... busy done 0 0 idle 0 1 finished 1 0 working 1 1 (undefined)

CS4315A. Berrached:CMS:UHD22 I/O Devices (cont.) How does the computer communicate with an I/O device? –device controller has a set of registers: Command reg., Status reg., Data regs., Address regs, etc. –Status reg.: tells the computer the status of device: idle, busy, non functional, etc. –A process can request an operation from device by placing a command in device’s Command reg. –Data regs. Are used to exchange data –Address regs: used to indicate address of source/destination

CS4315A. Berrached:CMS:UHD23 Performing a Write Operation while(deviceNo.busy || deviceNo.done) ; deviceNo.data[0] = deviceNo.command = WRITE; while(deviceNo.busy) ; deviceNo.done = TRUE; Devices much slower than CPU CPU waits while device operates Would like to multiplex CPU to a different process while I/O is in process

CS4315A. Berrached:CMS:UHD24 CPU-I/O Overlap CPU Device … Ready Processes CPU Device … Ready Processes I/O Operation CPU Device … Ready Processes Uses CPU

CS4315A. Berrached:CMS:UHD25 I/O Devices (cont.) How does the computer operate on device controller registers? How does it identify each device? 1. Instruction set of the CPU may have special instructions to operate on I/O devices. E.g. Input DeviceN, DeviceRegisterN, Rn Output Rn, DeviceN, DeviceRegisterN etc. 2. Memory Mapped I/O

CS4315A. Berrached:CMS:UHD26 Memory Mapped I/O A set of memory addresses are reserved for I/O devices. E.g: 0000 to 3FF in Intel 8086 –each device is assigned a sub-set of memory addresses. –A memory address is assigned to each register of each device controller regular CPU instructions are used to interact with device controller.

CS4315A. Berrached:CMS:UHD27 I/O Devices (cont.) How does the CPU know when a device controller has completed the requested operation? 1. Polling: CPU continually check status register of device controller 2. Interrupt driven I/O: device controller sends a signal to CPU through the bus. –bus must support interrupts –CPU must include an interrupt flag –CPU instruction set must include instructions to test and set/clear interrupt flag.

CS4315A. Berrached:CMS:UHD28 Determining When I/O is Complete CPU Device Interrupt Pending CPU incorporates an “interrupt pending” flag When device.busy  FALSE, interrupt pending flag is set Hardware “tells” OS that the interrupt occurred Interrupt handler part of the OS makes process ready to run

CS4315A. Berrached:CMS:UHD29 Fetch-Execute Cycle with Interrupt PC = ; IR = Memory[PC] ; haltFlag = CLEAR ; Decode(IR); while (haltFlag not SET) { Execute(IR); PC = PC + InstructionSize; if (InterruptFlag) { save current PC; // (e.g. in system stack) PC = AddressOfInterruptHandler; reset InterruptFlag; } IR = Memory[PC] ; Decode(IR); }

CS4315A. Berrached:CMS:UHD30 Hardware Protection Dual-Mode Operation I/O Protection Memory Protection

CS4315A. Berrached:CMS:UHD31 Dual-Mode Operation Sharing system resources requires that the operating system ensures a level of protection to the users: –an incorrect program can not cause other programs to execute incorrectly – that a user program cannot have access resource for it does not have permission –some operations should not be performed by user programs

CS4315A. Berrached:CMS:UHD32 Dual-Mode Operation (Cont.) Provide hardware support to differentiate between at least two modes of operations: 1. User mode - execution done on behalf of the user 2. Supervisor mode (also called monitor mode or privileged mode or protected mode or system mode etc.) - execution done on behalf of the operating system

CS4315A. Berrached:CMS:UHD33 Dual-Mode Operation (Cont.) Mode bit is added to computer hardware (to CPU) to indicate the current mode. Supervisor mode (0)user mode (1) Instruction set: privileged instructions and non- privileged instructions - privileged instructions can be executed only in supervisor mode. Operating system can execute any instruction. Must insure that a user program can not execute privileged instructions directly.

CS4315A. Berrached:CMS:UHD34 Going from User Mode to Supervisor Mode When a user program need service from the OS (e.g. open a file, read, write, allocate memory etc.), it makes a system call: i.e. a call to one of the OS functions. OS functions must run in supervisor mode. User processes run in user mode. computer designers had to come up with some kind of approach that would allow a user process to miraculously change the CPU mode to supervisor and branch to one of these OS functions simultaneously. The trap instruction is just the ticket.

CS4315A. Berrached:CMS:UHD35 Trap Instruction A trap instruction is a machine-level instruction that: –Switches the CPU mode to supervisor –Looks up the address of the target function in a kernel- space trap table –Branches to the entry point of the kernel-space function using the address from the trap table The trick is that the instruction does all three of these steps rather than just one or two. And trap is the only instruction that sets the CPU mode bit to supervisor.

CS4315A. Berrached:CMS:UHD36 The system call is translated into a trap instruction –the trap instruction is a machine level instruction that is part of the instruction set of the processor The trap instruction will do the following: –change mode-bit to supervisor mode –jump to a trap handler which will determine which OS function is being requested etc.

CS4315A. Berrached:CMS:UHD37 Dual-Mode Operation (Cont.) Processor must provide the following: A Mode-bit flag Instruction set: privileged instructions and non- privileged instructions A trap instruction

CS4315A. Berrached:CMS:UHD38 I/O protection Instruction to change the mode must be privileged I/O operation are privileged instructions How can user program perform I/O? It makes a system call to OS. When a system call is made a trap instruction is executed: –sets the mode to supervisor mode –OS function verifies that parameters are correct and legal, executes the request, sets mode to user mode, and returns control to user program

CS4315A. Berrached:CMS:UHD39 Memory Protection

CS4315A. Berrached:CMS:UHD40 Example of Memory Protection

CS4315A. Berrached:CMS:UHD41 Protection Hardware