L21 – OS and IO 1 Comp 411– Spring 2008 4/24/08 Operating System The OS is JUST A PROGRAM but it runs in SUPERVISOR state access to PHYSICAL addresses.

Slides:



Advertisements
Similar presentations
System Integration and Performance
Advertisements

COMP375 Computer Architecture and Organization Senior Review.
More on Processes Chapter 3. Process image _the physical representation of a process in the OS _an address space consisting of code, data and stack segments.
Input and Output CS 215 Lecture #20.
1/1/ / faculty of Electrical Engineering eindhoven university of technology Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir.
1/1/ / faculty of Electrical Engineering eindhoven university of technology Introduction Part 3: Input/output and co-processors dr.ir. A.C. Verschueren.
OS2-1 Chapter 2 Computer System Structures. OS2-2 Outlines Computer System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection.
11/15/2005Comp 120 Fall November Seven Classes to Go! Questions! VM and Making Programs Go.
11/18/2004Comp 120 Fall November 3 classes to go No class on Tuesday 23 November Last 2 classes will be survey and exam review Interconnect and.
11/29/2005Comp 120 Fall November 4 to go! Questions? Interrupts and I/O devices.
Chapter 7 Interupts DMA Channels Context Switching.
Advanced OS Chapter 3p2 Sections 3.4 / 3.5. Interrupts These enable software to respond to signals from hardware. The set of instructions to be executed.
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
1/21/2010CSCI 315 Operating Systems Design1 Computer System Structures Notice: The slides for this lecture have been largely based on those accompanying.
Process Description and Control A process is sometimes called a task, it is a program in execution.
Chapter 2: Computer-System Structures
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.
System Calls 1.
3/11/2002CSE Input/Output Input/Output Control Datapath Memory Processor Input Output Memory Input Output Network Control Datapath Processor.
Disk Access. DISK STRUCTURE Sector: Smallest unit of data transfer from/to disk; 512B 2/4/8 adjacent sectors transferred together: Blocks Read/write heads.
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.
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.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Principles of I/0 hardware.
Chapter 2: Computer-System Structures
1 CSE Department MAITSandeep Tayal Computer-System Structures Computer System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection.
2: Computer-System Structures
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.
1 Chapter 2: Computer-System Structures  Computer System Operation  I/O Structure  Storage Structure  Storage Hierarchy  Hardware Protection  General.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
2.1 Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation Storage Structure Storage Hierarchy Hardware Protection General.
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.
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  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 4 Computer Systems Review.
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.
1 Lecture 1: Computer System Structures We go over the aspects of computer architecture relevant to OS design  overview  input and output (I/O) organization.
L20 – OS and IO 1 Comp 411– Fall /09/09 Operating System The OS is JUST A PROGRAM but it runs in SUPERVISOR state access to PHYSICAL addresses access.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
Processor Memory Processor-memory bus I/O Device Bus Adapter I/O Device I/O Device Bus Adapter I/O Device I/O Device Expansion bus I/O Bus.
Copyright © 2007 by Curt Hill Interrupts How the system responds.
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.
Interrupts and Exception Handling. Execution We are quite aware of the Fetch, Execute process of the control unit of the CPU –Fetch and instruction as.
10/15: Lecture Topics Input/Output –Types of I/O Devices –How devices communicate with the rest of the system communicating with the processor communicating.
Of Privilege, Traps, Interrupts & Exceptions Prof. Sirer CS 316 Cornell University.
Chapter 2: Computer-System Structures(Hardware)
Chapter 2: Computer-System Structures
Processes and threads.
Chapter 2: Computer-System Structures
Day 08 Processes.
Day 09 Processes.
Operating System The OS is JUST A PROGRAM
Structure of Processes
Operating System The OS is JUST A PROGRAM
Computer-System Architecture
Module 2: Computer-System Structures
Operating Systems.
Process Description and Control
Interrupts and Exception Handling
Module 2: Computer-System Structures
Unix Process Control B.Ramamurthy 4/11/2019 B.Ramamurthy.
Chapter 2: Computer-System Structures
Chapter 2: Computer-System Structures
Module 2: Computer-System Structures
Module 2: Computer-System Structures
Lecture Topics: 11/20 HW 7 What happens on a memory reference Traps
Presentation transcript:

L21 – OS and IO 1 Comp 411– Spring /24/08 Operating System The OS is JUST A PROGRAM but it runs in SUPERVISOR state access to PHYSICAL addresses access to special registers (like page table register) all IO devices, etc. whereas ordinary programs run in USER state only access to VIRTUAL addresses through page tables normally no access to IO devices Programs ask the OS for services (syscall) give me more memory read/write data from/to disk put pixel on screen give me the next character from the keyboard The OS may choose to “map” devices such as the screen into USER space

L21 – OS and IO 2 Comp 411– Spring /24/08 Shell You normally interact with a SHELL It provides the command prompt, or GUI (graphical user interface) It is JUST A PROGRAM It runs in USER state just like your programs It interprets your mouse clicks or typed commands and asks the OS to implement your requests Suppose you “double-click” on a program icon What happens?

L21 – OS and IO 3 Comp 411– Spring /24/08 Program Startup in SHELL First the SHELL finds the file (using FILE SYSTEM in OS) indicated by the icon It checks some permissions and such Finally it calls the EXEC system call with the file name and possibly some arguments Now the OS takes over

L21 – OS and IO 4 Comp 411– Spring /24/08 OS Exec The OS keeps a PROCESS TABLE of all running programs disk location of executable memory location of page tables priority current status (running, waiting ready, waiting on an event, etc.) PID (process ID) a number assigned to the process A PROCESS is an independent program running in its own memory space The OS allocates a new entry in the PROCESS TABLE And sets up the PAGE TABLE for the new process

L21 – OS and IO 5 Comp 411– Spring /24/08 Initial Page Table foo swap 0x text segment 0x text segment 0x data segment 0x x x xffffe000 0xfffff000 1stack memory disk page table

L21 – OS and IO 6 Comp 411– Spring /24/08 Program Startup Now everything is ready The PROCESS TABLE entry has been set up The PAGE TABLE for the process has been initialized The TEXT SEGMENT is out on disk The DATA SEGMENT is in memory The STACK SEGMENT has been allocated 1 PAGE The OS is ready to take the leap of faith ONLY ONE program runs at a time When your program is running the OS is not To run your program and maintain control the OS must trust that is will eventually get control again when the program asks for a service when the program does something illegal when a timer goes off

L21 – OS and IO 7 Comp 411– Spring /24/08 Page Fault in the Text When we branch to the beginning of “main” we get a page fault So the OS copies the first page of the TEXT of main to a free page in memory

L21 – OS and IO 8 Comp 411– Spring /24/08 Page Fault in the Text foo swap 0x text segment 0x text segment 0x data segment 0x x x xffffe000 0xfffff000 1stack memory disk page table

L21 – OS and IO 9 Comp 411– Spring /24/08 Allocate a block of memory Now suppose the first thing our program needs to do is get 6k of memory for an array The program uses “new” to make an array Down inside “new” it calls “malloc” Down inside “malloc” it uses a system call to ask the OS for memory The OS will have to find 2 pages to hold 6k

L21 – OS and IO 10 Comp 411– Spring /24/08 Allocate a block of memory foo swap 0x text segment 0x text segment 0x data segment 0x heap 0x heap 0x xffffe000 0xfffff000 1stack disk page table

L21 – OS and IO 11 Comp 411– Spring /24/08 Fault in the other page of TEXT foo swap 0x text segment 0x text segment 0x data segment 0x heap 0x heap 0x xffffe000 0xfffff000 1stack memory disk page table

L21 – OS and IO 12 Comp 411– Spring /24/08 Grow the stack Now our program needs more stack space Perhaps it has to call a recursive function to traverse a complex data structure Or perhaps the user declares an “automatic” array like double work[1000]; which needs 8000 bytes of memory

L21 – OS and IO 13 Comp 411– Spring /24/08 Grow the stack foo swap 0x text segment 0x text segment 0x data segment 0x heap 0x heap 0x xffffd xffffe xfffff000 1stack memory disk page table

L21 – OS and IO 14 Comp 411– Spring /24/08 Get partially paged out Sometime later, some other program running on the system needs more memory It asks the OS The OS realizes that not enough physical memory remains available So the OS chooses to PAGE OUT one page from our program It would choose one that hasn’t been used for a while like possibly one of the heap segments

L21 – OS and IO 15 Comp 411– Spring /24/08 Partially Paged Out foo swap 0x text segment 0x text segment 0x data segment 0x heap 0x heap 0x xffffd xffffe xfffff000 1stack memory disk page table

L21 – OS and IO 16 Comp 411– Spring /24/08 Later we need that page foo swap 0x text segment 0x text segment 0x data segment 0x heap 0x heap 0x xffffd xffffe xfffff000 1stack memory disk page table

L21 – OS and IO 17 Comp 411– Spring /24/08 Exit Finally our program exits It calls the “exit” system call to notify the OS that it is done The OS puts the memory back on the free list Cleans up the PAGE TABLE and PROCESS TABLE And goes on about its business... What does the OS do when no programs are ready?

L21 – OS and IO 18 Comp 411– Spring /24/08 Interrupts How does the CPU manage SLOW I/O devices? Programmed I/O Interrupt Driven I/O

L21 – OS and IO 19 Comp 411– Spring /24/08 Polling Advantages Simple No surprises Processor in full control Disadvantages Polling can waste lots of time

L21 – OS and IO 20 Comp 411– Spring /24/08 Interrupt Driven I/O Advantage CPU only bothered when actually needed Disadvantage Can occur at surprising or inconvenient times Have to save and restore state

L21 – OS and IO 21 Comp 411– Spring /24/08 MIPS Exceptions Reset Hardware Errors (Bus Error, Cache Error) External Interrupt (6 inputs) Address Error Reserved Instruction TLB Miss System Call Breakpoint Trap Integer Overflow Floating Point Error Timer And a few more

L21 – OS and IO 22 Comp 411– Spring /24/08 Exception Processing EPC gets address of faulty instruction or of next instruction depending on type of exception Switch to kernel mode Jump to a new location based on type of exception PC  FFFF FFFF BFC for Reset PC  FFFF FFFF BFC for Hardware error PC  FFFF FFFF BFC for external interrupts PC  FFFF FFFF BFC for … Save registers Examine the “cause” register to find out why you came here Branch to code to do the right thing

L21 – OS and IO 23 Comp 411– Spring /24/08 Magnetic Disk Long term, nonvolatile storage Large, inexpensive, and slow Rotating platter(s) coated with magnetic material Use a movable read/write head to access When magnetized region zips past coils in head, a tiny signal is produced Force current through coils to generate magnetic field to magnetize tiny regions on the disk Use feedback to keep the head in the right place

L21 – OS and IO 24 Comp 411– Spring /24/08 Outside

L21 – OS and IO 25 Comp 411– Spring /24/08 Inside

L21 – OS and IO 26 Comp 411– Spring /24/08 Platters and Heads

L21 – OS and IO 27 Comp 411– Spring /24/08 Magnetic Disk Organization Cylinder: All tracks under head with arm in a fixed position Read/Write time has 3 components Seek time to move the arm Rotational latency: wait for the desired sector to come by Transfer time: transfer bits

L21 – OS and IO 28 Comp 411– Spring /24/08 Typical Disk Times Average Seek: 8ms to 12ms Sum of all possible seek / number of possible seeks Locality reduces this to maybe only 25% of average number Rotational Latency: At 5400 RPM  11 ms At 7200 RPM  8 ms At RPM  6ms Transfer time depends on: Transfer size (typical 512 bytes) Rotation speed Recording density Diameter Typical values: 10 to 40MBytes per second

L21 – OS and IO 29 Comp 411– Spring /24/08 CD

L21 – OS and IO 30 Comp 411– Spring /24/08 CRT Display

L21 – OS and IO 31 Comp 411– Spring /24/08 LCD

L21 – OS and IO 32 Comp 411– Spring /24/08 Graphics Cards

L21 – OS and IO 33 Comp 411– Spring /24/08 Polygons to Surfaces Numerical coordinates specify vertex positions in 3D Matrix multiply transforms 3D coordinates to eye coordinates Divide projects 3D to 2D in perspective Pixel processors fill polygons with appropriate colors based on lighting model

L21 – OS and IO 34 Comp 411– Spring /24/08 Anti-aliasing

L21 – OS and IO 35 Comp 411– Spring /24/08 Sound Sound is variations in air pressure A microphone converts these into an analog electrical signal An analog-to-digital converter samples this at frequent intervals The resulting numbers are stored in a file (.wav) On playback a digital-to-analog converter changes these numbers into an analog electrical signal And the moving cone of a speaker converts this into varying air pressure

L21 – OS and IO 36 Comp 411– Spring /24/08 MP3? The sequence of numbers representing typical sounds is VERY redundant The next value is closely related to the previous Values aren’t random cause we don’t like noise Extract this redundancy to get compression Lossy compression: Throw less important info away cause listener won’t notice