现代操作系统课件:Chapter5-Disks_第1页
现代操作系统课件:Chapter5-Disks_第2页
现代操作系统课件:Chapter5-Disks_第3页
现代操作系统课件:Chapter5-Disks_第4页
现代操作系统课件:Chapter5-Disks_第5页
已阅读5页,还剩35页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

ModernOperatingSystems

Chapter5–DisksZhangYangSpring2013ContentoftheLecture5.4DisksDiskHardwareMagneticDisksDiskFormattingDiskArmSchedulingAlgorithmErrorHandlingStableStorageMagneticDisks(1)OrganizedintocylindersEachcylinderscontainstrackswhosenumberisequaltothenumberofheadsinthediskdriveEachtrackisdividedintoanumberofsectors.E.g.forfloppydisks,8-32sectors/track.

Thesectorsizeisusually512bytes.ThereareIDE,SCSI,FiberChannel,andSATAharddisks.OnecylinderOnetrackOnesectorMagneticDisks(2)MagneticDisks(3)Figure5-18DiskparametersfortheoriginalIBMPCfloppydiskandaWesternDigitalWD18300harddiskAHardDiskDiskArmArmmotionpathDiskHeadOneplatterMagneticDisks(4)MagneticDisks(5)Figure5-19(a)Physicalgeometryofadiskwithtwozones(b)ApossiblevirtualgeometryforthisdiskMagneticDisks(6)DiskAddressingMillionsofsectorsonthediskmustbelabeledTwopossibilitiesCylinder/head/sector(CHS)Sequentialnumbering(LBA)ModerndrivesusesequentialnumbersDisksmapsequentialnumbersintospecificlocationLogicalBlockAddressingorLBA

MappingmaybemodifiedbythediskRemapbadsectorsOptimizeperformanceHidetheexactgeometry,makinglifesimplerfortheOSMagneticDisks(7)DiskFormatting(1)Aftermanufacturing,thereisnoinformationonthediskJustemptybitsEachplatterneedtohaveAlow-levelformatAhigh-levelformatbeforediskcanbeused.Low-levelFormattingDividingadiskintosectorsthatthediskcontrollercanreadandwrite.Low-levelformattingisusuallydonebyvendorsDiskFormatting(2)Low-LevelFormatting(ctd.)Eachtrackshouldhaveformattedinthefollowingway:Sectorsandinter-sector-gapbetweenthemAsectorwillbehaveformatlikethefollowing:Preamble–data(512bytes)–ChecksumsectorsectorsectorpreambleData(512bytes)ECC(~16bytes)certainbitpatterncylindernumbersectornumberDiskFormatting(3)Low-LevelFormatting(ctd.)CylinderSkewWhenreadingsequentialblocks,theseektimecanresultinmissingblock0inthenexttrack.Diskcanbeformattedusingacylinderskewtoavoidthis.CylinderSkew:Startcylindersatdifferentpointstogivetheheadtimetojumpfromonetothenext.Example:10000rpmdiskdrive,300sectorspertrack,seektime800us,thecylinderskewis40sectors10000rpmDriverotatesin6msTrackhas300sectorsNewsectorevery20µsIftrackseektime800µs40sectorspassonseekDiskFormatting(4)0123456789101112131415161718192021222301234567910111213141516171819202122232401234567891011121314151617181920212223DirectionofrotationSweeppath>timetochangetrack(cyclinder)DiskFormatting(5)Low-LevelFormatting(ctd.)InterleavingIfwehaveONEsectorbufferinthediskcontrollerAfterwehavetransferredonesectorofdatafromhard-disktocontrollerbuffer:WewillcopythecontrollerbuffertothememoryDuringthistime,thedisk-headwillpassthestartofthenextsector.Therefore,thenextlogicalsector,shouldnotbethenextphysicalsectorinhard-disk.Thereshouldbesomeinterleaving.DiskFormatting(6)01234567910111213141516171819202122232401234567891011121314151617181920212223registersregistersCPUMEMORYDiskController1sectorbuffer(1)(2)(3)DiskFormatting(7)Low-LevelFormatting(ctd.)Interleaving(ctd.)(a)Nointerleaving(b)Singleinterleaving(morecommon)Skippingonesectorbetweenreads(c)DoubleinterleavingSkippingtwosectorsbetweenreadsDiskFormatting(8)Low-LevelFormatting(ctd.)Interleaving(ctd.)Moderndrivesovercomeinterleavingtypeissuesbysimplyreadingtheentiretrack(orpartthereof)intotheon-diskcontrollerandcachingit.DiskFormatting(9)DiskPartitioningEachpartitionislikeaseparatediskSector0isMBR

Containsbootcode+partitiontablePartitiontablehasstartingsectorandsizeofeachpartitionHigh-levelformattingDoneforeachpartitionSpecifiesbootblock,freelist,rootdirectory,emptyfilesystemWhathappensonboot?BIOSloadsMBR,bootprogramcheckstoseeactivepartitionReadsbootsectorfromthatpartitionthatthenloadsOSkernel,etcDiskFormatting(10)DiskPartitioning(ctd.)DiskFormatting(11)DiskPartitioning(ctd.)DiskQueues(1)DiskQueues(2)DiskSectorXMem

Ptr0nextentryEntry1SectorYMem

Ptr1nextentryEntry2SectorZMem

Ptr2nextentryEntry3headtailDiskArmScheduling(1)Howlongdoesittaketoreadablock(sector)PositioningTime+TransferTimePositioningTimeSeekTimeMovearmtothecorrectcylinderRotationalDelayWaituntilcorrectsectorcomesunderhead.ActualdatatransfertimeFormostsystems,theseektimedominatestheothertwotimes.DiskArmScheduling(2)Assumethediskisheavilyloaded.Therearealotofrequestsfordiskblocksthatarearrivingtotheharddiskdriver.Thedriversqueuestherequests.Thedriverknowsforeachblockrequest,whereinharddisktheblockshouldbestored(thecylindernumber).Sincemovingbetweencylinders(seektime)iscostly,weshouldtrytominimizetheseseektimes.DiskArmScheduling(3)DiskDriverKeepsatableofrequests.TableisindexedbythecylindernumberBlocksrequestsforthesamecylinderareputinalinkedlist.xxxxx05101520InitialpositionpendingrequestscylindernumberDiskArmSchedulingAlgorithmsFCFS(1)Servetherequestintheordertheyarrive(don’tlooktothecylindernumbers)ExampleAssumethecurrentpositioniscylinder11.Thefollowingrequestsarriveinthegiventimeorder:1,36,16,34,9,12Therequestwillbeservedinthesameorder.Theheadwillgoto:Cylinder1first(10cylindermotion)Cylinder36next(35cylindermotion)Cylinder16next(20)Cylinder34next(18)Cylinder9next(25)Cylinder12next(3)Totalof111cylindersareskipped.Cost=111FCFS(2)xxxxx

xx051015

20253035

Newrequestarrivalsequence:1,36,16,34,9,12Initialheadpositionxxxxx

xx051015

20253035

Newrequestarrivalsequence:1,36,16,34,9,12InitialheadpositionIssueThegoalsofminimalresponsetimeandfairnessareinconflicthere.Examplexxxxx

xx051015

20253035

Newrequestarrivalsequence:1,36,16,34,9,12InitialheadpositionAftergoingto16,anewrequestfor8ispresent,then13.ElevatorAlgorithm(1)AlsocalledSCANalgorithm.Dolikewhatanelevatordoes.1.Moveinonedirectionuntilallrequestinthatdirectionisserved2.Thenchangedirection.3.Moveinthenewdirectionuntilallrequestinthatdirectionareserver.Repeatsteps1,2,and3.InthepreviousexampleAssumeinitialpositionwas11andinitialdirectionwasup(goingtohighernumberedcylinders).ElevatorAlgorithm(2)Therequestareserverinthefollowingorder:12,16,34,36,9,1Armmotions(#ofcylinderskips)1,4,18,2,27,8Totalcost=60cylinders.Performsgoodandisfair.Softwareshouldmaintain1bittoknowthedirection.ElevatoralsoshouldknowwhetheritisgoingUPorDOWNElevatorAlgorithm(3)xxxxx

xx051015

20253035

Newrequestarrivalsequence:1,36,16,34,9,12InitialheadpositionC-SCAN(1)Providesamoreuni

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论