solution8.pdf
-
Upload
peter1234u -
Category
Documents
-
view
215 -
download
3
Transcript of solution8.pdf
SpringTerm2014OperatingSystemsandNetworksAssignment8Assignedon: 10thApril2014Dueby: 17thApril20141 FileSystemsa) Istheopensystemcall inUNIXabsolutelyessential?Whatwouldbetheconsequencesofnothavingit?Answer: Iftherewerenoopensystemcall,itwouldbenecessarytospecifythenameoftheletobeaccessedforeveryreadoperation. Thesystemwouldthenhavetofetchthei-nodeforit,althoughitcouldbecached. Oneissuethatquicklyarisesiswhentoushtheinodebacktodisk. Itcouldbebasedonatimeout,howeveritwouldbeclumsy. Overall,itmaywork,butwithmuchmoreoverheadinvolved.b) Some OSes provide a system call rename to give a le a new name. Is there any dierenceatall betweenusingthiscall torenamealeandjustcopyingtheletoanewlewiththenewname,followedbydeletingtheoldone?Answer: Yes, therenamecall does not changethecreationtime, or thetimeof lastmodication, butcreatinganewlecausesittogetthecurrenttimeasboththecreationandlastmodicationtimes. Also,ifthediskisfull,thecopywillfail.c) Nameoneadvantageof hardlinksoversymboliclinksandoneadvantageof symboliclinksoverhardlinks.Answer: Hardlinksdonotrequireanyadditional diskspace, justacounterintheinodetokeeptrackofhowmanythereare. Ontheotherhand,symboliclinksneedspacetostorethenameofthelepointedtoit. Symboliclinkscanpointtolesonothermachines,evenovertheinternet. Hardlinksarerestrictedtopointingtoleswithintheirownpartition.d) It has been suggested that the rst part of each le be kept in the same disk block as its inode.Whatgoodwouldthisdo?Answer: Often,lesare short. Iftheentire le tinthesame blockas theinode,onlyonediskaccesswouldbeneededtoreadthele, insteadoftwo, asispresentlythecase. Evenforlongerlestherewouldbeagain,sinceonefewerdiskaccesseswouldbeneeded.e) AnOperating Systemonly supports a single directory, but allows that directory to havearbitrarilymanyleswitharbitrarilylonglenames. Cansomethingapproximatingahier-archical lesystembesimulated?How?Answer: Onewaytosimulatethatistoappendtoeachlenamethenameof directorythatcontainsit.Forexample: UsrStudentsZivaPrivateFileXf ) Systemsthat support sequential lesalwayshaveanoperationtorewindles. Dosystemsthatsupportrandomaccesslesneedthistoo?Answer: No, random access of les does not need the rewind operation since if you wanttoreadtheleagain,youcanjustaccessbyte0.g) Contiguousallocationof lesleadstodiskfragmentation. Isthisinternal fragmentationorexternal fragmentation?Answer: Contiguousallocationoflesleadstodiskinternalfragmentation, sincediskaredividedintoblockstheonlydiskspacewasteisintheblockitself.h) Onewaytousecontiguous allocationof diskandnot suerfromholes is tocompact thediskeverytimealeisremoved. Sincealllesarecontiguous,copyingalerequiresaseekandrotational delaytoreadthele, followedbythetransferat full speed. Writingthelebackrequiresthesamework. Assumingaseektimeof5msec,arotationaldelayof4msec,atransferrateof8MB/secandanaveragelesizeof8KB,howlongdoesittaketoreadaleintomainmemorythenwriteit backtothediskat anewlocation? Usingthesenumbers,howlongwouldittaketocompacthalfofa16GBdisk?Answer: It takes 9msec to start the transfer (due to 5msec seek and 4msec rotation delay).Toread213bytes(8KB)atthetransferrateof223bytes/sec(8MB/sec)requires210sec(0.977msec). Hencethetotal timetoseek, rotateandtransferis9.977msec. Writingbacktakesanother9.977msec. Thuscopyinganaverageletakes19.954msec.To compact half of a 16GB disk would involve copying 8GB of storage, which is 220les. At19.954msecperle,thistakes20,923seconds,whichis5.8hours. Clearly,compactingthediskaftereveryleremovalisnotagreatidea.i) Considertheinodestructurewith10directaddressesandoneindirectaddress. Iftheinodecontains10directaddressesof 4byteseachandall diskblocksare1024Bytes, whatisthelargestpossiblele?Consider32-bitaddressing.Answer: Withthe 10direct addresses we get le size of 10KB. Withasingle indirectaddress we can point to one block ofaddresses which means102432/4= 256 addresses to blocks.Thisalsomeansthatwecanaddress256KBwiththeindirectaddressing. Alltogether,wecanhavethelargestpossibleleof256 + 10 = 266KB.j) Freediskspacecanbekept trackof usingfreelist orabit map. DiskaddressesrequireDbits. ForadiskwithBblocks,Fofwhicharefree,statetheconditionunderwhichthefreelistuseslessspacethanthebitmap. ForDhavingthevalue16bits,expressyouranswerasapercentageofthediskspacethatmustbefree.Answer: ThebitmaprequitesBbits. ThefreelistrequiresDFbits. Thefreelistrequiresfewer bits if DF< B. Alternatively, the free list is shorter ifFB