版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025版1A13365国际贸易实务操作手册授权合同3篇
- 2024-2030年中国耐磨陶瓷涂料行业市场深度分析及发展趋势预测报告
- 二零二五版海外科技园区劳务派遣与研发支持协议2篇
- 2025年房屋代持合同样本与资产评估协议4篇
- 个性化私人借贷合同(2024版)版B版
- 2025版国家级屠宰场高品质牛肉供货合同范本下载3篇
- 2025年离职后研发成果保密及竞业限制协议
- 2025年度路灯广告合作营销策划合同4篇
- 二零二五年度辅导班学生安全协议及学业辅导合同
- 二零二五年度智慧城市建设融资租赁合同主体权益与智慧应用
- 中国成人暴发性心肌炎诊断和治疗指南(2023版)解读
- 新生儿低血糖课件
- 自动上下料机械手的设计研究
- 电化学储能电站安全规程
- 幼儿园学习使用人民币教案教案
- 2023年浙江省绍兴市中考科学真题(解析版)
- 语言学概论全套教学课件
- 大数据与人工智能概论
- 《史记》上册注音版
- 2018年湖北省武汉市中考数学试卷含解析
- 《肾脏的结构和功能》课件
评论
0/150
提交评论