《中科大操作系统原理与实现课件12_MassStorageSystems1.pdf》由会员分享,可在线阅读,更多相关《中科大操作系统原理与实现课件12_MassStorageSystems1.pdf(29页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、.操作系统原理与设计第12章 Mass-Storage structure(外存)陈香兰中国科学技术大学计算机学院2009年09月01日.提纲Overview of Mass Storage StructureDisk StructureDisk SchedulingDisk ManagementSwap-Space Management小结和作业.Overview of Mass Storage Structure IIMagnetic disks provide bulk of secondary storage of moderncomputersIDrives rotate at 60
2、 to 200 times per secondITransfer rate is rate at which data flow between drive andcomputerIPositioning time(random-access time)is time to move diskarm to desired cylinder(seek time)and time for desired sectorto rotate under the disk head(rotational latency)IHead crash results from disk head making
3、contact with thedisk surfaceIThats badIDisks can be removable.Overview of Mass Storage Structure IIIDrive attached to computer via I/O busIBusses vary,including EIDE,ATA,SATA,USB,Fibre Channel,SCSIIHost controller in computer uses bus to talk to disk controllerbuilt into drive or storage array.Overv
4、iew of Mass Storage Structure(Cont.)IMagnetic tapeIWas early secondary-storage mediumIRelatively permanent and holds large quantities of dataIAccess time slowIRandom access 1000 times slower than diskIMainly used for backup,storage of infrequently-used data,transfer medium between systemsIKept in sp
5、ool and wound or rewound past read-write headIOnce data under head,transfer rates comparable to diskI20-200GB typical storageICommon technologies are 4mm,8mm,19mm,LTO-2 andSDLT Oper.Disk Structure IIDisk drives are addressed as large 1-D arrays of logical blocks,Ithe logical block is the smallest un
6、it of transfer.Iusually,512BIThe 1-D array of logical blocks is mapped into the sectorsof the disk sequentially.ICylinder:track:sectorISector 0 is the first sector of the first track on the outermostcylinder.IMapping proceeds in order through that track,then the rest ofthe tracks in that cylinder,an
7、d then through the rest of thecylinders from outermost to innermost.Disk Structure II.Disk Structure IIIIHowever,in practise,the mapping is difficult,because1.Defective sectors2.Sectors/track=constant zones of cylinder.Disk Scheduling IIThe OS is responsible for using hardware efficiently for thedis
8、k drives,Ithis means having a fast access time and disk bandwidth.IAccess time has two major components1.Seek time is the time for the disk are to move the heads tothe cylinder containing the desired sector.2.Rotational latency is the additional time waiting for the diskto rotate the desired sector
9、to the disk head.IMinimize seek timeISeek time seek distanceIDisk bandwidth is the total number of bytes transferred,divided by the total time between the first request for serviceand the completion of the last transfer.Disk Scheduling IIIRequest queueIempty or notISeveral algorithms exist to schedu
10、le the servicing of disk I/Orequests.IWe illustrate them with a request queue(0-199).98,183,37,122,14,124,65,67Head points to 53 initially.FCFSISimplestITotal head movement=(hi hi1)=|98 53|+|183 98|+|37 183|+|122 37|+|14 122|+|124 14|+|65 124|+|67 65|=640.SSTF(shortest-seek-time-first)ISelects the r
11、equest with the minimum seek time from the current headposition.ISSTFSJF:starvationITotal head movement=|65 53|+|67 65|+|37 67|+|14 37|+|98 14|+|122 98|+|124 12|+|183 124|=236IOptimal?.SCAN(elevator algorithm)IThe disk arm starts at one end of the disk,and moves toward theother end,servicing request
12、s until it gets to the other end of the disk,where the head movement is reversed and servicing continues.IIllustration shows total head movement of 208 cylinders.IWaiting time:Maximum is?.C-SCAN IIProvides a more uniform wait time than SCAN.IThe head movesIfrom one end of the disk to the other.Iserv
13、icing requests as it goes.IWhen it reaches the other end,however,it immediatelyreturns to the beginning of the disk,without servicing anyrequests on the return trip.ITreats the cylinders as a circular list that wraps around fromthe last cylinder to the first one.C-SCAN II.C-LOOKIVersion of C-SCANIAr
14、m only goes as far as the last request in each direction,then reverses direction immediately,without first going all theway to the end of the disk.Selecting a Disk-Scheduling AlgorithmISSTF is common and has a natural appealISCAN and C-SCAN perform better for systems that place aheavy load on the di
15、sk.IPerformance depends onIthe number and types of requests,which can be influenced byIthe file-allocation methodIThe location of directories and index blocks(caching?)IThe disk-scheduling algorithm should be written as a separatemodule of the OS,allowing it to be replaced with a differentalgorithm
16、if necessary.IEither SSTF or LOOK is a reasonable choice for the defaultalgorithm.Disk Management IIDisk FormattingILow-level formatting,or physical formattingIDividing a disk intosectors that thedisk controller canread and write.(From:http:/ CH 7.files/image055.jpg).Disk Management IIITo use a disk
17、 to hold files,the operating system still needs torecord its own data structures on the disk.IPartition the disk into one or more groups of cylinders.ILogical formatting or“making a file system”.Disk Management IIIITo increase efficiency,most FSes group blocks together intolarger chunks,frequently c
18、alled clustersIBoot blockIThe(tiny)bootstrap is stored in ROM.IMostly,the only job of bootstrap is to bring in a full bootstrapprogram from disk(boot disk,or system disk)IMBRIboot partition&boot sectorIBooting from a Disk in Windows 2000.Disk Management IVIDisk failureIcomplete failure VS.only one o
19、r more sectors becomedefective,Bad blocksIMethods towards bad blocks.Disk Management VImanually:example,for MS-DOS,write a special value intoFAT entryIsector sparing(备用)Isector slipping(滑动).Swap-Space Management IISwapping&paging1.entire processes2.pagingISwap-spaceVirtual memory uses disk space as
20、an extension of mainmemory.ISwap-space canIbe carved out of the normal file systemIa large file with the file systemIor,more commonly,it can be in a separate disk partition.IExample1:4.3BSDIallocates swap space when process starts;Iholds text segment(the program)and data segment.IKernel uses swap ma
21、ps to track swap-space use.for text seg.for data seg.IExample2:SorlarisIVersion1:for text segment,no use of swap space;only usedas a backing store for pages of anonymous memory,includingmemory allocated for stack,heap,uninitialized dataIVersion2:allocates swap space only when a page is forced outof
22、physical memory,not when the virtual memory page is firstcreated.IExample3:LinuxIsimilar to Solaris1Iallows one or more swap areas with 4KB slotsIeach swap area is associated with a swap mapI0:free;0:occupied,sharing counts.小结Overview of Mass Storage StructureDisk StructureDisk SchedulingDisk ManagementSwap-Space Management小结和作业.作业I华夏班:12.2I非华夏班:14.2.谢谢!