版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
AdvancedOperatingSystem
--TheDesignoftheUNIXOperationSystemCh1GeneralOverviewoftheSystemCh2IntroductiontotheKernelCh3TheBufferCacheCh4InternalRepresentationofFilesCh5SystemcallsfortheFilesystemCh6TheStructureofProcessesCh7ProcessControlCh8ProcessSchedulingandTimeCh9MemoryManagementPolicies整体概述THEFIRSTPARTOFTHEOVERALLOVERVIEW,PLEASESUMMARIZETHECONTENT第一部分AdvancedOperatingSystem
--TheDesignoftheUNIXOperationSystemCh4InternalRepresentationofFilesTopicscovered4.1Inodes4.2StructureofaRegularFile4.3Directories4.4ConversionofaPathNametoanInode4.5SuperBlock4.6InodeAssignmenttoaNewFile4.7AllocationofDiskBlocksEveryfileonUNIXhasauniqueinodeTheinodecontainstheinformationnecessaryforaprocesstoaccessafileProcessesaccessfilesbysystemcallandspecifiesafilebyapathnameThekernelconvertsthepathnametothefile’sinode4.1InodesInodesexistinastaticformondiskThekernelreadsinodeintoanin-coreinodetomanipulatethem4.1Inodes-DefinitionDiskinodesconsistofthefollowingfields:FileowneridentifierownergroupsuperuserFiletypeRegular,directory,characterorblockspecial,orFIFO(pipes)Fileaccesspermissionsowner,groupowner,otherusers;read,write,executeFileaccesstimesLastmodified,lastaccessed,whentheinodewaslastmodifiedNumberoflinkstothefileThenumberofnamesthefilehasTableofcontentsforthediskaddresstodatainafileDiskblocksthatcontainthefile’sdataFilesizeStartfrombyteoffset04.1Inodes-Definition4.1Inodes-DefinitionWritethecontentsofafiletodiskThecontentsofafilechangeonlywhenwritingitWritethecontentsofaninodetodiskChangthecontentsofafileChangeitsowner,permission,orlinksettings…4.1Inodes-DefinitionThein-corecopyoftheinodecontainsthefollowingfieldsinadditiontothefieldsofthediskinode:Thestatusofthein-coreinodeThelogicaldevicenumberofFSthatcontainsthefileTheinodenumberPointerstootherin-coreinodesAreferencecount—indicatingthenumberofinstancesofthefilethatareactive(suchaswhenopen)4.1Inodes-DefinitionThestatusofthein-coreinode,indicatewhether:TheinodeislockedAprocessiswaitingfortheinodetobecomeunlockedThein-corerepresentationoftheinodediffersfromdiskcopyasaresultofachangetothedataintheinodeThein-corerepresentationofthefilediffersfromdiskcopyasaresultofachangetothefiledataThefileisamountpoint4.1Inodes-DefinitionManyfieldsinthein-coreinodeareanalogoustofieldsinthebufferheaderThedifference:in-corehaveareferencecountCountsthenumberofactiveinstancesofthefileAninodeisonthefreelistonlyitsreferencecountis0Thekernelcanreallocatethein-coreinodetoanotherdiskinodeIfaprocessattemptstoaccessafilewhoseinodeisnotcurrentlyinthein-coreinodepool,thekernelreallocateanin-coreinodefromthefreelistforitsuse.4.1Inodes-Accessigetallocateanin-corecopyofaninodeThekernelmapsthedevicenumberandinodenumberintoahashqueueSearchthequeuefortheinodeIfcannotfind,allocatesonefromthefreelistandlocksitThenreadthediskcopyintothein-corecopy4.1Inodes-AccessBlocknum=((inodenum-1)/numberofinodesperblock)+startblockofinodelistStartblockofinodelist:2Numberofinodesperblock:8Block0Block1inode1inode2inode8inode9inode16……Block2Block34.1Inodes-AccessByteoffsetoftheinodeintheblock:((inodenumber-1)mod(numberofinodesperblcok)*sizeofdiskinodeEachdiskinode:64bytesNumberofinodesperblock:8inode1inode2inode8…Block063641274485114.1Inodes-AccessThekernellocktheinodeduringexecutionofasystemcallThekernelreleasethelockattheconclusionofthesystemcallThekernelincrementsthereferencecountforeveryactivereferencetoafile(openthefile)Decrementthereferencecountwhenthereferencebecomeinactive(closethefile)ThelockisfreebetweensystemcallstoallowprocessestosharesimultaneousaccesstoafileThereferencecountremainsetbetweensystemcall4.1Inodes-igetigetAtthebeginningofsystemcallWhenaprocessfirstaccessafileReturnalockedinodewithreferencecount1greaterthanbeforeThekernelunlockstheinodebeforereturningfromthesystemcall4.1Inodes-igetiget4.1Inodes-iputiputReleasinginodesDecrementsitsin-corereferencecountIfthecount0,andthein-corecopydifferfromthediskcopy,thekernelwritetheinodetodiskPlacetheinodeonthefreelistofinodesReleasealldatablockassociatedwiththefile4.1Inodes-iputiput4.2StructureofaRegularFileEachblockonadiskisaddressablebynumberTheinodecontainthetableofcontentstolocateafile’sdataondisk4.2StructureofaRegularFileStoreinacontiguoussectionofdisk4.2StructureofaRegularFileThekernelallocatefilespaceoneblockatatimeandallowsthedatainafiletobespreadthroughoutthefilesystemThetablecouldconsistofalistofblocknumbersAlogicalblock=1k10kfileanindexof10blocknumbers100kfileanindexof100blocknumber4.2StructureofaRegularFileTheSystemVUNIX:13entriesintheinodetableofcontents10directblock1indirect1doubleindirect1tripleindirect4.2StructureofaRegularFile4.2StructureofaRegularFileAssume:Alogicalblock=1KbytesAblocknumber=32bit(4byte)integerAblockholdupto:256blocknumbers10directblock =10K1indirect =256*1K=256k1doubleindirect =256*256*1K=64M1tripleindirect =256*256*256*1K=16G4.2StructureofaRegularFileProcessesaccessdatainafilebybyteoffsetThekernelaccessfilebyblockThekernelaccesstheinodeandconvertsthelogicalfileblockintotheappropriatediskblockAlgorithmbmap4.2StructureofaRegularFile4.2StructureofaRegularFile4.2StructureofaRegularFileAdiskblock=1024bytesIfaprocesswantstoaccessbyteoffset9000:9000/1024=8…808Theblocknumber=367Theoffsetoftheblock=808Ifaprocesswantstoaccessbyteoffset35000:35000/1024=341…816341-(10+256)=753333:8164.2StructureofaRegularFileBlockentriesintheinodeare0:ThelogicalblockentriescontainnodataNoprocesseverwrotedataintothefileatanybyteoffsetscorrespondingtothoseblocksandhencetheblocknumbersremainattheirinitialvalue04.2StructureofaRegularFileTwoextensiontotheinodestructure:LargerlogicaldiskblockMoredatathekernelcanaccessonthediskinasingleoperation,thefasterfileaccessbecomeStorefiledataintheinodeExpandingtheinodetooccupyanentirediskblock4.3DirectoriesAdirectoryisafileItsdataisasequenceofentries:aninodenumber(2bytes)thenameofafilecontainedinthedirectory(14bytes)Everydirectorycontainsthefilenamesdotanddot-dot(“.”and“..”)Theinodenumbersarethoseofthedirectoryanditsparentdirectory4.3Directories4.3DirectoriesThekernelstoresdataforadirectoryjustasitstoresdataforanordinaryfileProcessesmayreaddirectoriesinthesamewaytheyreadregularfileThekernelreservesexclusiverighttowriteadirectoryTheaccesspermissionsofadirectory:Read:allowsaprocesstoreadadirectoryWrite:allowsaprocesstocreatenewdirectoryentries/removeoldone(creat,mknod,link,unlink)Execute:searchthedirectoryforafilename4.4ConversionofaPathNametoanInodeTheprocessaccesstoafilebyitspathnameThekernelworksinternallywithinoderatherthanwithpathnamesThekernelconvertsthepathnametoinode4.4ConversionofaPathNametoanInodeEveryprocessisassociatedwithacurrentdirectoryTheuareacontainsapointertothecurrentdirectoryinodeThecurrentdirectoryofthefirstprocess(process0),istherootdirectoryThecurrentdirectoryofeveryotherstartsoutasthecurrentdirectoryofitsparentprocessatthetimeitwascreated4.4ConversionofaPathNametoanInodenameiWorkinginode:nameiuseintermediateinodesasitparsesapathnameTheinodewherethesearchstartsisthefirstworkinginode.MakesuretheworkinginodeisadirectoryTheprocessmusthavepermissiontosearchthedirTheuserIDoftheprocessmustmatchtheownerorgroupIDofthefile4.4ConversionofaPathNametoanInodeThekerneldoesalinersearchofthedirectoryTrytomatchthepathnamecomponenttoadirectoryentryname.Iffindamatch,itrecordstheinodenumberofthematcheddirectoryentry,Allocatetheinodeofthematchedcomponent(iget).ThenewinodebecomestheworkinginodeThekernelrepeattheprocedureuntilitmatchesthepathname,oruntilitreachestheendofthedirectory4.4ConversionofaPathNametoanInode4.5SuperBlockSuperblockThesizeofthefilesystemThenumberoffreeblocksinthefilesystemAlistoffreeblocksavailableonthefilesystemTheindexofthenextfreeblockinthefreeblocklistThesizeofinodelistThenumberoffreeinodesinthefilesystemAlistoffreeinodesinthefilesystemTheindexofthenextfreeinodeinthefreelnodelistLockfieldsforthefreeblockandfreeinodelistsAflagindicatingthatthesuperblockhasbeenmodified4.6InodeAssignmenttoaNewFileigetAknowninode(inodenumberwaspreviouslydetermined)iallocAssignadiskinodetoanewlycreatedfile4.6InodeAssignmenttoaNewFileThefilesystemcontainsalinearlistofinodesAninodeisfreeifitstypefieldiszeroWhenaprocessneedsanewinode,thekernelsearchtheinodelistforafreeinodeFilesystemsuperblockcontainsanarraytocachethenumbersoffreeinodes.4.6InodeAssignmenttoaNewFileiallocIfthelistoffreeinodesisnotemptyAssignafreeinodenumberAllocateafreein-coreinodeforthisinode(iget)Copythediskinodetothein-corecopyInitializethefieldsintheinodeReturnthelockedinodeDecrem
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 给水排水工程质量控制方案
- 教学评价体系与标准建立计划
- 生活部数字化转型的挑战与应对计划
- 小班班级的学生评价安排计划
- 财务管理中的伦理问题计划
- 提高工作效率的方法与计划
- 西南林业大学《比较文学概论》2022-2023学年第一学期期末试卷
- 西南交通大学《算法和数据结构》2022-2023学年第一学期期末试卷
- 西南交通大学《数据结构》2022-2023学年第一学期期末试卷
- 西京学院《C语言程序设计》2021-2022学年第一学期期末试卷
- 人教部编版八年级数学上册期末考试卷及答案一
- 哲学与人生第12课《实现人生价值》12.2
- 微创冠脉搭桥手术
- 新古典经济学中的神经经济学理论
- 变译的七种变通手段
- 人教八年级英语大单元作业设计
- 企业并购与资产重组智慧树知到期末考试答案2024年
- 货物包装承诺函
- 企业资质代办服务方案投标技术方案技术标
- 2024-2029年中国折扣商店行业市场发展前瞻及投资战略研究报告
- 护理部副主任竞聘
评论
0/150
提交评论