Operating Systems Design & Construction
Operating Systems Design & Construction CMPSC 473
Popular in Course
Popular in ComputerScienence
verified elite notetaker
This 0 page Class Notes was uploaded by Isabel Eichmann on Sunday November 1, 2015. The Class Notes belongs to CMPSC 473 at Pennsylvania State University taught by Staff in Fall. Since its upload, it has received 31 views. For similar materials see /class/233061/cmpsc-473-pennsylvania-state-university in ComputerScienence at Pennsylvania State University.
Reviews for Operating Systems Design & Construction
Report this Material
What is Karma?
Karma is the currency of StudySoup.
Date Created: 11/01/15
M Operating Systems CMPSC 473 InputOutput April 22 2008 Lecture 22 Instructor Trent Jaeger Last Class File System Interface Today IO OS role in 10 39 Share the same device across different processesusers 39 User does not see the details of how hardware works Device independent interface to provide uniformity across devices I O Peripherals OxOOm OxOfff on39Chip Ox1000 IO Disk BUS CTr39Iler39 0x2000 I Ox2fff Talk to Devices Communication Send instructions to the devices Get the results I 0 Ports Dedicated I O registers for communicating status and requests Memory mapped I O Map the registers into main memory Communicate requests through memory Memory mapped data registers can be larger Think graphics device Memory mapped I Q Can read and write device registers just like normal memory However user programs are NOT typically allowed to do these reads writes The OS has to manage control these devices The addresses to these devices may not need to go through address translation since OS is the one accessing them and protection does not need to be enforced and there is no swapping paging for these addresses Consider a disk device 0x000 Memory Bus OxOfff Ox1000 IO 32 pa 0 RAM GD L 39 GD Confroller GD Ox1fff Reading a sector from disk STor39e CommandReg READCONNAND STor39e Tr39ackReg Tr39ack STor39e SecTor Reg SecTor39 Device sTar39Ts oper39aTion You don39T wanT To do This InsTead blockswiTch To L Load R STaTusReg oTher39 process and IeT an cmp R O inTer39r39upT wake you up Jeq DaTa now on memory of card For i 1 T0 S CTOPSiZ 4 over39head To ask The mai MemTar39geTi MemOnCar39di CPU To do This is again a lot of 3 n Interrupt Cycle CPU lO controller 1 device driver initiates lO initiates lO l CPU executing checks for interrupts between instructions I input ready output mplete or error generates interrupt signal CPU receiving interrupt transfers control to interrupt handler interrupt handler rooesses data returns from interrupt CPU resumes processing at interrupted task DIVLA engine to of oad work of copying OxOOO Memory Bus OxOfff Ox1000 DMA Confroller Ox1fff STore CommandReg READCONNAND STore TrackReg Track Assuming an STore SecTorReg SecTor infegraled DM i 39 1 STore MemoryAddressReg Address and disk drllen Device sTarTs operaTion PdiskrequesT39 OperaTion compleTe and daTa is now in required memory ocaTions Called when DMA raises inTerrupT afTer ISRO CompleTion of Transfer VdiskrequesT Issues to consider What is purpose of RAM on card To address the speed mismatch between the bit stream coming from disk and the transfer to main memory When we program the DMA engine With address of transfer Store TVlemoryAddressReg Address is Address virtual or physical It has to be a physical address since the addresses generated by the DMA do NOT go through the MMU address translation But since it is the OS programming the DMA this is available and it is NOT a problem You do NOT want to give this option to user programs Also the address needs to be pinned cannot be evicted in memory lO Devices Block devices usually stores information in fixed size blocks you read or write an individual block independently of others by giving it an address Eg disks tapes Character devices delivers or accepts streams of characters Not addressable Eg terminals printers mouse network interface Principles of I 0 Software Provide device independence same programs should work with different devices uniform naming ie name shouldn39t depend on the device error handling handle it as low as possible and only if unavoidable pass it on higher synchronous blocking vs asynchronous interrupt driven Even though I 0 devices are usually async sync is easier to program Characteristics of Devices aspect variation example datatransfer mode character terminal block disk sequential modem access method random CDROM transfer schedule Syncmonous tape asynchronous keyboard Shari dedicated tape 9 sharable keyboard device speed latency seek time transfer rate delay between operations read only CDROM lO direction write only graphics controller read write dis IO Software A layered approach Lowest layer device dependent Device drivers Middle layer Device independent OS software High level User level software libraries The rst 2 are part of the kernel Device Drivers Accept abstract requests from device independent OS software and service those requests There is a device driver for each device However the interface to all device drivers is the same OpenO closeO read write interruptO iocth Disk driver Semaphore r39equesT Open Im er39r39upTO check whcn caused The inTer39r39upT Close case diskr39ead VrequesT Readm hhgr am The device Pr39equesT Wr39iTe Device independent OS Layer Device naming and protection Each device is given a major minor present in the i node for that device Major identifies the driver Minor is passed on to the driver to handle sub devices Does buffering caching Uses a device independent block size Handles error reporting in a device independent fashion Putting things together U NIX 7 9 9 User calls open deVtty W call OS traverses le system to nd the i node of ttyO This should contain the major minor Check permissions to make sure it is allowed An entry is created in OFDT and a handle is returned to the user When user calls writefd subsequently indeX into OFDT get major minor 5 which is a system I O and Kernel Objects systemwide openfile table r 39 A filesystem record table inode pointer gt pointer to read and write functions pointer to select function per process 4 pointer to ioctl function file descriptor Openfile table 39 pomter to close function 0 network information table networking socket record userprocess memory pointer to network info pointerto read and write functions pointer to select function pointerto ioctl function pointer to close function o o kernel memory Getting to the driver ro W n e 8Pen1 ose Open Read fp lilnfeg PL lt5 Reojdeo Wr39iTe Major Openfp Closefp Readfp Wri39l39efp Driver codes supplied by hw vendors Linked needs ker39nel r39ebooT for InsTallaTion or39 dynamically loaded inTo Ker39nel I emor39y DaTa STr39ucT Copy the bytes pointed to by the pointer given by user into a kernel pinned which is not going to be paged out buffer Use the above data structure to nd the relevant driver s write routine and call it with the pinned buffer address and other relevant parameters For a write one can possibly return back to user even if the write has not propagated On a read for an input device the driver would program the device and block the activity till the interrupt This was a character device In a block device before calling the driver check the buffer cache that the OS is maintaining to see if the request can be satis ed before going to the driver itself The lookup is done based on major logical block id Thus it is a unified device independent cache across all devices This is all for the user referring to an lO device deV Note It is not very different When the user references a normal file In that case we have already seen how the file system generates a request in the form of a logical block id which is then sent to the driver Where the speci ed file system resides disk CD Life Cycle of an I O Request veques vo system caH can aheady sausw vequesn YES semi veauesua demos unver mack pvocess n appropna e pvocess vequest ssue com a a cunngure cumroHer m m s m commuev ock unm mevrupted devwcercomvouev commands nsev pmcess Keme o subsystem Keme o subsystem devme deev mtervupt hammer mommrde ce meme conuouev vo comp eted mpm dam avaHab e or ompm summesz vemm quotom system CaH uansrev data m appmpnate m moses r slum commenon nr enor code deterrmne wmon v0 cump eled ndma e stats change m we subsystem renews lmevrupn 5mm data m devmerdeer nuwzv na mm m drwev unevmm v0 comp etad gensvate mevrupt Summary Input Output The OS Manages Device Usage Communication IO Subsystem 39 Next time Protection