cse 513 i ntroduction to operating systems class 8 i nput
play

CSE 513 I ntroduction to Operating Systems Class 8 - I nput/ - PowerPoint PPT Presentation

CSE 513 I ntroduction to Operating Systems Class 8 - I nput/ Output File Systems Jonathan Walpole Dept. of Comp. Sci. and Eng. Oregon Health and Science University I / O devices Device (mechanical hardware) Device controller


  1. CSE 513 I ntroduction to Operating Systems Class 8 - I nput/ Output File Systems Jonathan Walpole Dept. of Comp. Sci. and Eng. Oregon Health and Science University

  2. I / O devices � Device (mechanical hardware) � Device controller (electrical hardware) � Device driver (sof tware)

  3. Devices and their controllers Monitor Bus � Components of a simple personal computer

  4. How to communicate with a device? � Hardware supports I / O ports or memory mapped I / O f or accessing device controller registers and buf f ers

  5. Wide perf ormance range f or I / O

  6. Perf ormance challenges: I / O hardware � How to prevent slow devices f rom slowing down memory � How to identif y I / O addresses without interf ering with memory perf ormance

  7. Single vs. Dual Memory Bus Architecture (a) A single- bus architecture (b) A dual- bus memory architecture

  8. Hardware view of Pentium Structure of a large Pentium system

  9. Perf ormance challenges: I / O sof tware � How to prevent CPU throughput f rom being limited by I / O device speed (f or slow devices) � How to prevent I / O throughput f rom being limited by CPU speed (f or f ast devices) � How to achieve good utilization of CPU and I / O devices � How to meet the real- time requirements of devices

  10. Programmed I / O Steps in printing a string

  11. Programmed I / O � Polling/ busy- waiting approach copy_from_user(buffer,p,count); for(i=0;i<count;i++){ while (*p_stat_reg != READY); *p_data_reg = p[i]; } return();

  12. I nterrupt- driven I / O � Asynchronous approach � give device dat a, do somet hing else! � r esume when device int er r upt s if (count==0){ copy_from_user(buffer,p,count); unblock_user(); enable_interrupts(); } else { while (*p_stat_reg != READY); *p_data_reg = p[i]; *p_data_reg=p[0]; count--; scheduler(); i++; } ack_interrupt(); return_from_interrupt();

  13. I nterrupt driven I / O (b)

  14. Hardware Support f or I nterrupts How interrupts happens. Connections between devices and interrupt controller actually use interrupt lines on the bus rather than dedicated wires

  15. DMA � Of f load all work to a DMA controller � avoids using t he CPU t o do t he t r ansf er � r educes number of int er r upt s � DMA cont r oller is like a co-pr ocessor doing pr ogr ammed I / O copy_from_user(buffer,p,count); ack_interrupt(); set_up_DMA_controller(); unblock_user(); scheduler(); return_from_interrupt();

  16. DMA

  17. Sof tware engineering- related challenges � How to remove the complexities of I / O handling f rom application programs � st andar d I / O API s (libr ar ies and syst em calls) � gener ic cat egor ies acr oss dif f er ent device t ypes � How to support a wide range of device types on a wide range of operating systems � st andar d int er f aces f or device dr iver s � st andar d/ published int er f aces f or access t o ker nel f acilit ies

  18. I / O Sof tware Layers Layers of the I / O Sof tware System

  19. I nterrupt Handlers I nterrupt handlers are best hidden � have dr iver st ar t ing an I / O oper at ion block unt il � int er r upt not if ies of complet ion I nterrupt procedure does its task � t hen unblocks dr iver t hat st ar t ed it � Steps must be perf ormed in sof tware af ter � interrupt completed Save regs not alr eady saved by int er r upt har dwar e − Set up cont ext f or int er r upt ser vice pr ocedur e −

  20. I nterrupt Handlers Set up st ack f or int errupt service procedure � Ack int errupt cont roller, reenable int errupt s � Copy regist ers f rom where saved � Run service procedure � Set up MMU cont ext f or process t o run next � Load new process' regist ers � St art running t he new process �

  21. Device Drivers Communications between drivers and device controllers goes over � the bus

  22. I / O Sof tware: Device Drivers � Device drivers “connect” devices with the operating system � Typically a nast y assembly-level j ob • Must deal with hardware changes • Must deal with O.S. changes � Hide as many device-specif ic det ails as possible � Device drivers are typically given kernel privileges f or ef f iciency � Can br ing down O.S.! � How t o pr ovide ef f iciency and saf et y???

  23. Device- I ndependent I / O Sof tware Functions Unif orm interf acing f or device drivers Buf f ering Error reporting Allocating and releasing dedicate devices Providing a deice- independent block size Functions of the device- independent I / O sof tware

  24. Device- I ndependent I / O Sof tware I nterf ace (a) Without a standard driver interf ace (b) With a standard driver interf ace

  25. Device- I ndependent I / O Sof tware Buf f ering (a) Unbuf f ered input (b) Buf f ering in user space (c) Buf f ering in the kernel f ollowed by copying to user space (d) Double buf f ering in the kernel

  26. Copying Overhead in Network I / O Networking may involve many copies

  27. User- Space I / O Sof tware Layers of the I / O system and the main f unctions of each layer

  28. Devices as f iles Bef ore mounting, � � f iles on f loppy are inaccessible Af ter mounting f loppy on b, � � f iles on f loppy are part of f ile hierarchy

  29. Disk Geometry � Disk head, platters, surf aces Track Sector cylinder

  30. Physical vs. logical disk geometry � Constant Angular Velocity vs. Constant Linear Velocity

  31. Disks Disk parameters f or the original I BM PC f loppy disk and a Western Digital WD 18300 hard disk

  32. CD- ROMs

  33. CD- ROM data layout Logical data layout on a CD- ROM

  34. CD- R Structure Cross section of a CD- R disk and laser � � not t o scale Silver CD- ROM has similar structure � � wit hout dye layer � wit h pit t ed aluminum layer inst ead of gold

  35. Double sided dual layer DVD

  36. Plastic technology � CDs � Appr oximat ely 650 Mbyt es of dat a � Appr oximat ely 74 minut es of audio � DVDs � Many t ypes of f or mat s • DVD- R, DVD- ROM, DVD- Video � Single layer vs. mult i-layer � Single sided vs. double sided � Aut hor ing vs. non-aut hor ing

  37. Disk Formatting A disk sector

  38. Disk f ormatting with cylinder skew

  39. Disk f ormatting with interleaving � No interleaving � Single interleaving � Double interleaving

  40. Disk scheduling algorithms � Time required to read or write a disk block determined by 3 f actors � Seek t ime � Rot at ional delay � Act ual t r ansf er t ime � Seek time dominates � Error checking is done by controllers

  41. Disk scheduling algorithms � First- come f irst serve � Shortest seek time f irst � Scan � back and f orth to ends of disk � C- Scan � only one direction � Look � back and f orth to last request � C- Look � only one direction

  42. Disk scheduling algorithms

  43. Error handling complicates scheduling � A disk track with a bad sector � Substituting a spare f or the bad sector � Shif ting all the sectors to bypass the bad one

  44. RAI D levels 0 to 2

  45. RAI D levels 3 to 5

  46. Part B File Systems

  47. Long- term I nf ormation Storage Must store large amounts of data � I nf ormation stored must survive the termination � of the process using it Multiple processes must be able to access the � inf ormation concurrently

  48. File naming and f ile extensions Typical f ile extensions.

  49. File Structure � Three kinds of f ile structure � byt e sequence � r ecor d sequence � t r ee

  50. File Types (a) An executable f ile (b) An archive

  51. File access � Sequential access � r ead all byt es/ r ecor ds f r om t he beginning � cannot j ump ar ound, could r ewind or back up � convenient when medium was mag t ape � Random access � byt es/ r ecor ds r ead in any or der � essent ial f or dat a base syst ems � r ead can be … • move f ile marker (seek), then read or … • read and then move f ile marker

  52. File attributes

  53. File operations Cr eat e Append Delet e Seek Open Get at t r ibut es Close Set At t r ibut es Read Rename Wr it e

  54. Exmple Program Using File System Calls (1/ 2)

  55. Example Program Using File System Calls (2/ 2)

  56. Memory- mapped f iles (a) Segmented process bef ore mapping f iles into its address space (b) Process af ter mapping exist ing f ile abc int o one segment cr eat ing new segment f or xyz

  57. Directories - single level � A single level directory system � cont ains 4 f iles � owned by 3 dif f er ent people, A, B, and C

  58. Directories - two- level Letters indicate owners of the directories and f iles

  59. Hierarchical directory systems

  60. Path names in Unix

  61. Directory operations Readdir Create Rename Delete Link Opendir Unlink Closedir

  62. File system implementation on disk A possible f ile system disk layout

  63. I mplementing f iles - contiguous allocation (a) Contiguous allocation of disk space f or 7 f iles (b) State of the disk af ter f iles D and E have been removed

  64. I mplementing f iles - linked allocation Storing a f ile as a linked list of disk blocks

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend