中山大学软件学院操作系统概念上课课件第13章.ppt

上传人:asd****56 文档编号:87677794 上传时间:2023-04-16 格式:PPT 页数:42 大小:5.35MB
返回 下载 相关 举报
中山大学软件学院操作系统概念上课课件第13章.ppt_第1页
第1页 / 共42页
中山大学软件学院操作系统概念上课课件第13章.ppt_第2页
第2页 / 共42页
点击查看更多>>
资源描述

《中山大学软件学院操作系统概念上课课件第13章.ppt》由会员分享,可在线阅读,更多相关《中山大学软件学院操作系统概念上课课件第13章.ppt(42页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionChapter 13:I/O Systems13.2Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionChapter 13:I/O SystemsnI/O HardwarenApplication I/O InterfacenKernel I/O SubsystemnTransforming I/O Requests to Hardware Operationsn

2、STREAMSnPerformance13.3Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionObjectivesnExplore the structure of an operating systems I/O subsystemnDiscuss the principles of I/O hardware and its complexitynProvide details of the performance aspects of I/O hardware and software13.4Si

3、lberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionOverviewnI/O management is a major component of operating system design and operationlImportant aspect of computer operationlI/O devices vary greatlylVarious methods to control themlPerformance management lNew types of devices freq

4、uentnPorts,busses,device controllers connect to various devicesnDevice drivers encapsulate device detailslPresent uniform device-access interface to I/O subsystem13.5Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionI/O HardwarenIncredible variety of I/O deviceslStoragelTransmis

5、sionlHuman-interfacenCommon concepts signals from I/O devices interface with computerlPort connection point for devicelBus-daisy chain or shared direct accesslController(host adapter)electronics that operate port,bus,device4Sometimes integrated4Sometimes separate circuit board(host adapter)4Contains

6、 processor,microcode,private memory,bus controller,etcSome talk to per-device controller with bus controller,microcode,memory,etc13.6Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionA Typical PC Bus Structure13.7Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th Ed

7、itionI/O Hardware(Cont.)nI/O instructions control devicesnDevices usually have registers where device driver places commands,addresses,and data to write,or read data from registers after command executionlData-in register,data-out register,status register,control registerlTypically 1-4 bytes,or FIFO

8、 buffernDevices have addresses,used by lDirect I/O instructionslMemory-mapped I/O4Device data and command registers mapped to processor address space4Especially for large address spaces(graphics)13.8Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionDevice I/O Port Locations on P

9、Cs(partial)13.9Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionPollingnFor each byte of I/O1.Read busy bit from status register until 02.Host sets read or write bit and if write copies data into data-out register3.Host sets command-ready bit4.Controller sets busy bit,executes

10、transfer5.Controller clears busy bit,error bit,command-ready bit when transfer donenStep 1 is busy-wait cycle to wait for I/O from devicelReasonable if device is fastlBut inefficient if device slowlCPU switches to other tasks?4But if miss a cycle data overwritten/lost13.10Silberschatz,Galvin and Gag

11、ne 2009Operating System Concepts 8th EditionInterruptsnPolling can happen in 3 instruction cycleslRead status,logical-and to extract status bit,branch if not zerolHow to be more efficient if non-zero infrequently?nCPU Interrupt-request line triggered by I/O devicelChecked by processor after each ins

12、tructionnInterrupt handler receives interruptslMaskable to ignore or delay some interruptsnInterrupt vector to dispatch interrupt to correct handlerlContext switch at start and endlBased on prioritylSome nonmaskablelInterrupt chaining if more than one device at same interrupt number13.11Silberschatz

13、,Galvin and Gagne 2009Operating System Concepts 8th EditionInterrupt-Driven I/O Cycle13.12Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionIntel Pentium Processor Event-Vector Table13.13Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionInterrupts(Cont.)nInt

14、errupt mechanism also used for exceptionslTerminate process,crash system due to hardware errornPage fault executes when memory access errornSystem call executes via trap to trigger kernel to execute requestnMulti-CPU systems can process interrupts concurrentlylIf operating system designed to handle

15、itnUsed for time-sensitive processing,frequent,must be fast13.14Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionDirect Memory AccessnUsed to avoid programmed I/O(one byte at a time)for large data movement nRequires DMA controllernBypasses CPU to transfer data directly between

16、I/O device and memory nOS writes DMA command block into memory lSource and destination addresseslRead or write modelCount of byteslWrites location of command block to DMA controllerlBus mastering of DMA controller grabs bus from CPUlWhen done,interrupts to signal completion13.15Silberschatz,Galvin a

17、nd Gagne 2009Operating System Concepts 8th EditionSix Step Process to Perform DMA Transfer13.16Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionApplication I/O InterfacenI/O system calls encapsulate device behaviors in generic classesnDevice-driver layer hides differences among

18、 I/O controllers from kernelnNew devices talking already-implemented protocols need no extra worknEach OS has its own I/O subsystem structures and device driver frameworksnDevices vary in many dimensionslCharacter-stream or blocklSequential or random-accesslSynchronous or asynchronous(or both)lShara

19、ble or dedicatedlSpeed of operationlread-write,read only,or write only13.17Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionA Kernel I/O Structure13.18Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionCharacteristics of I/O Devices13.19Silberschatz,Galvin a

20、nd Gagne 2009Operating System Concepts 8th EditionCharacteristics of I/O Devices(Cont.)nSubtleties of devices handled by device driversnBroadly I/O devices can be grouped by the OS intolBlock I/OlCharacter I/O(Stream)lMemory-mapped file accesslNetwork socketsnFor direct manipulation of I/O device sp

21、ecific characteristics,usually an escape/back doorlUnix ioctl()call to send arbitrary bits to a device control register and data to device data register13.20Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionBlock and Character DevicesnBlock devices include disk driveslCommands i

22、nclude read,write,seek lRaw I/O,direct I/O,or file-system accesslMemory-mapped file access possible4File mapped to virtual memory and clusters brought via demand paginglDMAnCharacter devices include keyboards,mice,serial portslCommands include get(),put()lLibraries layered on top allow line editing1

23、3.21Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionNetwork DevicesnVarying enough from block and character to have own interfacenUnix and Windows NT/9x/2000 include socket interfacelSeparates network protocol from network operationlIncludes select()functionalitynApproaches va

24、ry widely(pipes,FIFOs,streams,queues,mailboxes)13.22Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionClocks and TimersnProvide current time,elapsed time,timernNormal resolution about 1/60 secondnSome systems provide higher-resolution timersnProgrammable interval timer used for

25、timings,periodic interruptsnioctl()(on UNIX)covers odd aspects of I/O such as clocks and timers13.23Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionBlocking and Nonblocking I/OnBlocking-process suspended until I/O completedlEasy to use and understandlInsufficient for some need

26、snNonblocking-I/O call returns as much as availablelUser interface,data copy(buffered I/O)lImplemented via multi-threadinglReturns quickly with count of bytes read or writtenlselect()to find if data ready then read()or write()to transfernAsynchronous-process runs while I/O executeslDifficult to usel

27、I/O subsystem signals process when I/O completed13.24Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionTwo I/O MethodsSynchronousAsynchronous13.25Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionKernel I/O SubsystemnSchedulinglSome I/O request ordering via

28、per-device queuelSome OSs try fairnesslSome implement Quality Of Service(i.e.IPQOS)nBuffering-store data in memory while transferring between deviceslTo cope with device speed mismatchlTo cope with device transfer size mismatchlTo maintain“copy semantics”lDouble buffering two copies of the data4Kern

29、el and user4Varying sizes4Full /being processed and not-full/being used4Copy-on-write can be used for efficiency in some cases13.26Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionDevice-status Table13.27Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionSun

30、 Enterprise 6000 Device-Transfer Rates13.28Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionKernel I/O SubsystemnCaching-faster device holding copy of datalAlways just a copylKey to performancelSometimes combined with bufferingnSpooling-hold output for a devicelIf device can se

31、rve only one request at a time li.e.,PrintingnDevice reservation-provides exclusive access to a devicelSystem calls for allocation and de-allocationlWatch out for deadlock13.29Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionError HandlingnOS can recover from disk read,device u

32、navailable,transient write failureslRetry a read or write,for examplelSome systems more advanced Solaris FMA,AIX 4Track error frequencies,stop using device with increasing frequency of retry-able errorsnMost return an error number or code when I/O request fails nSystem error logs hold problem report

33、s13.30Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionI/O ProtectionnUser process may accidentally or purposefully attempt to disrupt normal operation via illegal I/O instructionslAll I/O instructions defined to be privilegedlI/O must be performed via system calls4Memory-mappe

34、d and I/O port memory locations must be protected too13.31Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionUse of a System Call to Perform I/O13.32Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionKernel Data StructuresnKernel keeps state info for I/O compo

35、nents,including open file tables,network connections,character device statenMany,many complex data structures to track buffers,memory allocation,“dirty”blocksnSome use object-oriented methods and message passing to implement I/OlWindows uses message passing4Message with I/O information passed from u

36、ser mode into kernel4Message modified as it flows through to device driver and back to process4Pros/cons?13.33Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionUNIX I/O Kernel Structure13.34Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionI/O Requests to Ha

37、rdware OperationsnConsider reading a file from disk for a process:lDetermine device holding file lTranslate name to device representationlPhysically read data from disk into bufferlMake data available to requesting processlReturn control to process13.35Silberschatz,Galvin and Gagne 2009Operating Sys

38、tem Concepts 8th EditionLife Cycle of An I/O Request13.36Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionSTREAMSnSTREAM a full-duplex communication channel between a user-level process and a device in Unix System V and beyondnA STREAM consists of:-STREAM head interfaces with t

39、he user process-driver end interfaces with the device-zero or more STREAM modules between themnEach module contains a read queue and a write queuenMessage passing is used to communicate between queueslFlow control option to indicate available or busynAsynchronous internally,synchronous where user pr

40、ocess communicates with stream head13.37Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionThe STREAMS Structure13.38Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionPerformancenI/O a major factor in system performance:lDemands CPU to execute device driver,k

41、ernel I/O codelContext switches due to interruptslData copyinglNetwork traffic especially stressful13.39Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionIntercomputer Communications13.40Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionImproving Performance

42、nReduce number of context switchesnReduce data copying nReduce interrupts by using large transfers,smart controllers,polling nUse DMAnUse smarter hardware devicesnBalance CPU,memory,bus,and I/O performance for highest throughputnMove user-mode processes/daemons to kernel threads13.41Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionDevice-Functionality ProgressionSilberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionEnd of Chapter 12

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 技术资料 > 其他杂项

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁