四川大學(xué)操作系統(tǒng)課件Chapter12_第1頁
四川大學(xué)操作系統(tǒng)課件Chapter12_第2頁
四川大學(xué)操作系統(tǒng)課件Chapter12_第3頁
四川大學(xué)操作系統(tǒng)課件Chapter12_第4頁
四川大學(xué)操作系統(tǒng)課件Chapter12_第5頁
已閱讀5頁,還剩64頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

OperatingSystemsChapter12FileManagement2Agenda12.1Overview12.2FileOrganizationandAccess12.3FileDirectories12.4FileSharing12.5RecordBlocking12.6SecondaryStorageManagement12.7Summary3FileManagementFilemanagementsystemconsistsofsystemutilityprogramsthatrunasprivilegedapplications(特權(quán)程序)ProvidesameansofdataI/OInputtoapplicationsisbymeansofafileOutputissavedinafileforlong-termstorage4FileSystemProperties(文件系統(tǒng)的特性)Long-termexistence(長期存在)Sharablebetweenprocesses(進(jìn)程共享)Structure(結(jié)構(gòu)化存儲)Havespecificstructureaccordingtoapplication5FileOperations(文件操作)CreateDeleteOpenCloseReadWrite6TermsUsedwithFiles(文件術(shù)語)Field(域)Basicelementofdata(基本數(shù)據(jù)單元)ContainsasinglevalueCharacterizedbyitslengthanddatatypeRecord(記錄)Collectionofrelatedfields(相關(guān)域的集合)TreatedasaunitExample:employeerecord7TermsUsedwithFilesFile(文件)CollectionofsimilarrecordsTreatedasasingleentityHavefilenamesMayrestrictaccessDatabase(數(shù)據(jù)庫)CollectionofrelateddataRelationshipsexistamongelements8FileManagementSystems(文件管理系統(tǒng))Thewayauserofapplicationmayaccessfiles(用戶和程序使用文件的唯一方式)Programmerdoesnotneedtodevelopfilemanagementsoftware9FileManagementFunctionsIdentify(標(biāo)識)andlocate(定位)aselectedfileUsefilenametoidentifyfilesUseadirectory(目錄)todescribethelocationofallfilesplustheirattributes(屬性)Onasharedsystemdescribeuseraccesscontrol(存取控制)Blocking(塊化)foraccesstofilesManagefreeblocksAllocatefreeblockstofiles(空閑塊分配)Reclaimfreeblocks(空閑塊回收)10Agenda12.1Overview12.2FileOrganizationandAccess12.3FileDirectories12.4FileSharing12.5RecordBlocking12.6SecondaryStorageManagement12.7Summary1112.2FileOrganizationandAccess12.2.1CriteriaforFileOrganization12.2.2ThePile12.2.3TheSequentialFile12.2.4TheIndexedSequentialFile12.2.5TheIndexedFile12.2.6TheDirectorHashedFile12CriteriaforFileOrganization(文件管理的評價標(biāo)準(zhǔn))Shortaccesstime(短的存取時間)Easeofupdate(易于修改)Economyofstorage(存儲經(jīng)濟性)Simplemaintenance(維護簡單)Reliability(可靠性)1312.2FileOrganizationandAccess12.2.1CriteriaforFileOrganization12.2.2ThePile12.2.3TheSequentialFile12.2.4TheIndexedSequentialFile12.2.5TheIndexedFile12.2.6TheDirectorHashedFile14ThePile(堆文件)ThePileDataarecollectedintheordertheyarrivePurposeistoaccumulateamassofdataandsaveitRecordsmayhavedifferentfieldsNostructureRecordaccessisbyexhaustivesearch(窮舉搜索)15ThePile1612.2FileOrganizationandAccess12.2.1CriteriaforFileOrganization12.2.2ThePile12.2.3TheSequentialFile12.2.4TheIndexedSequentialFile12.2.5TheIndexedFile12.2.6TheDirectorHashedFile17TheSequentialFile(順序文件)Allfieldsthesame(orderandlength)FieldnamesandlengthsareattributesofthefileAllrecordsthesamelengthOnefieldisthekeyfiled(關(guān)鍵域,關(guān)鍵字)UniquelyidentifiestherecordRecordsarestoredinkeysequence18TheSequentialFileNewrecordsareplacedinalogfile(日志文件)ortransactionfile(事務(wù)文件)Batchupdate(成批更新)isperformedtomerge(合并)thelogfilewiththemasterfile19TheSequentialFile2012.2FileOrganizationandAccess12.2.1CriteriaforFileOrganization12.2.2ThePile12.2.3TheSequentialFile12.2.4TheIndexedSequentialFile12.2.5TheIndexedFile12.2.6TheDirectorHashedFile21TheIndexedSequentialFile(索引順序文件)Sequentialfile+index+overflowfileIndexprovidesalookupcapabilitytoquicklyreachthevicinityofthedesiredrecord(索引提供了快速接近目標(biāo)記錄的查詢能力)IndexcontainsakeyfieldandapointertothemainfileIndexedissearchedtofindhighestkeyvaluethatisequaltoorprecedesthedesiredkeyvalue(索引查找關(guān)鍵字小于或者等于目標(biāo)關(guān)鍵字的最大記錄)22TheIndexedSequentialFile(索引順序文件)ComparisonofsequentialandindexedsequentialExample:afilecontains1000000recordsOnaverage500000accessesarerequiredtofindarecordinasequentialfileIfanindexcontains1000entriesandeachentriescontains1000pointerstomainfile,itwilltakeonaverage500accessestofindthekey,followedby500accessesinthemainfile.Nowonaverageitis1000accesses23OverflowFileofTheIndexedSequentialFileNewrecordsareaddedtoanoverflowfile(溢出文件)RecordinmainfilethatprecedesitisupdatedtocontainapointertothenewrecordTheoverflowismerged(合并)withthemainfileduringabatchupdateMultiplelevelindexes(多級索引)forthesamekeyfieldcanbesetuptoincreaseefficiency24IndexedSequentialFile2512.2FileOrganizationandAccess12.2.1CriteriaforFileOrganization12.2.2ThePile12.2.3TheSequentialFile12.2.4TheIndexedSequentialFile12.2.5TheIndexedFile12.2.6TheDirectorHashedFile26TheIndexedFile(索引文件)UsesmultipleindexesfordifferentkeyfieldsMaycontainanexhaustiveindex(完全索引)thatcontainsoneentryforeveryrecordinthemainfileMaycontainapartialindex(部分索引)Indexfilesitselfaresequentialfile27

TheIndexedFile2812.2FileOrganizationandAccess12.2.1CriteriaforFileOrganization12.2.2ThePile12.2.3TheSequentialFile12.2.4TheIndexedSequentialFile12.2.5TheIndexedFile12.2.6TheDirectorHashedFile29TheDirectorHashedFile(直接文件或者散列文件)DirectlyaccessablockataknownaddressKeyfieldrequiredforeachrecordHashbasedonthekeyfield30Agenda12.1Overview12.2FileOrganizationandAccess12.3FileDirectories12.4FileSharing12.5RecordBlocking12.6SecondaryStorageManagement12.7Summary3112.3FileDirectories12.3.1Contents12.3.2Structure12.3.3Naming32FileDirectoriesContainsinformationaboutfilesAttributes(屬性)Location(位置)Ownership(所有者)Directoryitselfisafileownedbytheoperatingsystem(一個目錄本身是一個文件)Providesmappingbetweenfilenamesandthefilesthemselves(提供文件名和文件之間的映射)3312.3FileDirectories12.3.1Contents12.3.2Structure12.3.3Naming34SimpleStructureforaDirectory(簡單目錄結(jié)構(gòu))Representedbyasimplesequentialfilewiththenameofthefileservingasthekey(用順序文件代表目錄,該目錄下的文件名做該順序文件的關(guān)鍵字)Forcesusertobecarefulnottousethesamenamefortwodifferentfiles(文件不能重名)35Two-levelSchemeforaDirectory(兩級目錄方案)Amasterdirectory(主目錄)Onedirectoryforeachuser(用戶目錄)MasterdirectorycontainsentryforeachuserProvidesaddressandaccesscontrolinformationEachuserdirectoryisasimplelistoffilesforthatuserStillprovidesnohelpinstructuringcollectionsoffiles(不能建子目錄)36Hierarchical,orTree-StructuredDirectory(層次/樹狀結(jié)構(gòu)目錄)MasterdirectorywithuserdirectoriesunderneathitEachuserdirectorymayhavesubdirectoriesandfilesasentries373812.3FileDirectories12.3.1Contents12.3.2Structure12.3.3Naming39Hierarchical,orTree-StructuredDirectoryFilescanbelocated(文件定位)byfollowingapathfromtheroot,ormaster,directorydownvariousbranchesThisisthepathnameforthefileCanhaveseveralfileswiththesamefilename(文件同名)aslongastheyhaveuniquepathnames4041Hierarchical,orTree-StructuredDirectoryPathname(路徑名)Currentdirectoryistheworkingdirectory(工作目錄)Filesarereferencedrelativetotheworkingdirectory(相對路徑)42Agenda12.1Overview12.2FileOrganizationandAccess12.3FileDirectories12.4FileSharing12.5RecordBlocking12.6SecondaryStorageManagement12.7Summary43FileSharingInmultiusersystem,allowfilestobesharedamongusersTwoissuesAccessrights(存取權(quán)限)Managementofsimultaneousaccess(同時存取控制)44AccessRightsNone(無)UsermaynotknowoftheexistenceofthefileUserisnotallowedtoreadtheuserdirectorythatincludesthefileKnowledge(知道)Usercanonlydeterminethatthefileexistsandwhoitsowneris45AccessRightsExecution(執(zhí)行)TheusercanloadandexecuteaprogrambutcannotcopyitReading(讀)Theusercanreadthefileforanypurpose,includingcopyingandexecutionAppending(追加)Theusercanadddatatothefilebutcannotmodifyordeleteanyofthefile’scontents46AccessRightsUpdating(更新)Theusercanmodify,deleted,andaddtothefile’sdata.Thisincludescreatingthefile,rewritingit,andremovingallorpartofthedataChangingprotection(更改保護)UsercanchangeaccessrightsgrantedtootherusersDeletion(刪除)Usercandeletethefile47AccessRightsOwners(所有者)HasallrightspreviouslylistedMaygrantrightstoothersusingthefollowingclassesofusersSpecificuser(指定用戶)Usergroups(用戶組)Allforpublicfiles(所有用戶)48SimultaneousAccess(同時訪問)UsermaylockentirefilewhenitistobeupdatedUsermaylocktheindividualrecordsduringtheupdateMutualexclusionanddeadlockareissuesforsharedaccess49Agenda12.1Overview12.2FileOrganizationandAccess12.3FileDirectories12.4FileSharing12.5RecordBlocking12.6SecondaryStorageManagement12.7Summary50FixedBlocking51Variable-LengthSpannedBlocking52Variable-LengthUnspannedBlocking53Agenda12.1Overview12.2FileOrganizationandAccess12.3FileDirectories12.4FileSharing12.5RecordBlocking12.6SecondaryStorageManagement12.7Summary5412.6SecondaryStorageManagement(二級存儲管理)12.6.1FileAllocation12.6.2FreeSpaceManagement12.6.3Reliability55FileAllocationTable(FAT)FATisusedtotrackportionsallocatedtofiles56Preallocation(預(yù)分配)VSDynamicallocation(動態(tài)分配)PreallocationNeedthemaximumsizeforthefileatthetimeofcreationDifficulttoreliablyestimatethemaximumpotentialsizeofthefileDynamicallocationAllocatesspacetoafileinportionsasneeded.57Contiguousallocation(連續(xù)分配)Singlesetofblocksisallocatedtoafileatthetimeofcreation(文件創(chuàng)建時分配一組連續(xù)的塊)OnlyasingleentryinthefileallocationtableStartingblockandlengthofthefileExternalfragmentationwilloccurNeedtoperformcompaction58Contiguousallocation59Contiguousallocation60Chainedallocation(鏈?zhǔn)椒峙?Allocationonbasisofindividualblock(基于單個塊進(jìn)行分配)EachblockcontainsapointertothenextblockinthechainOnlysingleentryinthefileallocationtableStartingblockandlengthoffileNoexternalfragmentationBestforsequentialfiles(適合順序文件)Noaccommodationoftheprincipleoflocality(局部性原理不再適用),soconsolidation(遷移、集結(jié))isneedtomoveblocksadjacenteachother61Chainedallocation62Chainedall

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論