《unix操作系统设计》英文版习题答案1_第1页
《unix操作系统设计》英文版习题答案1_第2页
《unix操作系统设计》英文版习题答案1_第3页
《unix操作系统设计》英文版习题答案1_第4页
《unix操作系统设计》英文版习题答案1_第5页
免费预览已结束,剩余2页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

《unix操作系统设计》英文版习题答案1S.1

UnixInternals(April/May-2024,Set-1)JNTU-Anantapur

B.Tech.III-YearII-Sem.(JNTU-Anantapur)

CodeNo.:9A05602/R09

B.Tech.IIIYearIISemesterRegularExaminations

April/May-2024UNIXINTERNALS

(ComputerScienceandEngineering)

Time:3Hours

Max.Marks:70

AnsweranyFIVEQuestionsAllQuestionscarryequalmarks

---1.

(a)DrawandexplainthearchitectureofUNIXsystems.(Unit-I,TopicNo.1.5.1)(b)Discussindetailthesleepandwakeupprocedures.(Unit-V,TopicNo.5.6)

2.

(a)

Ifseveralprocessescontendforabuffer,thekernelguaranteesthatnoneofthemsleepforever,butitdoesnotguaranteethataprocesswillnotbestarvedoutfromuseofabuffer.Redesigngetblksothataprocessisguaranteedeventualuseofabuffer.(Unit-II,TopicNo.2.2)(b)Whataretheadvantagesofbuffercache?(Unit-II,TopicNo.2.5)

3.

(a)Givebriefdescriptionabouttheaccessingofinodes.(Unit-III,TopicNo.3.1)(b)Explainindetailthecontinuousfileallocationsystem.(Unit-III,TopicNo.3.7)

4.

(a)Whatisthepurposeoflinksystemcall?Writeandexplainthealgorithmforthesame.(Unit-IV,TopicNo.4.12)(b)Writeshortnotesonmaintenanceofthefilesystem.(Unit-IV,TopicNo.4.15)5.

(a)Whatareregions?Explaintheirroleinthecreationofprocesses.(Unit-V,TopicNo.5.2)(b)Describeindetailaboutthecontextofaprocess.(Unit-V,TopicNo.5.3)

6.

(a)Explainthesecurityproblemsthatexistsifasetuidprogramisnotwriteprotected.(Unit-VI,TopicNo.6.6)(b)Writeaprogramthataparentandchildsharesafileaccess.(Unit-VI,TopicNo.6.1)7.

(a)Discussindetailabouttheschedulingparameters.(Unit-VII,TopicNo.7.1)(b)Whatisprofiling?Explainitindetail.(Unit-VII,TopicNo.7.3)8.

(a)Explainclistsindetail.(Unit-VIII,TopicNo.8.3)

(b)

Writeaprogramforreadingdatafromriskbyusingblockandrawinterfaces.

(Unit-VIII,TopicNo.8.3)

S.2

SpectrumALL-IN-ONEJournalforEngineeringStudents,2024

B.Tech.III-YearII-Sem.(JNTU-Anantapur)

(a)

DrawandexplainthearchitectureofUNIXsystems.

Answer:April/May-12,Set-1,Q1(a)

ForanswerreferUnit-I,Q10.

(b)Discussindetailthesleepandwakeup

procedures.

Answer:April/May-12,Set-1,Q1(b)

ForanswerreferUnit-V,Q17.

(a)Ifseveralprocessescontendforabuffer,

thekernelguaranteesthatnoneofthemsleepforever,butitdoesnotguaranteethataprocesswillnotbestarvedoutfromuseofabuffer.Redesigngetblksothataprocessisguaranteedeventualuseofabuffer.

Answer:April/May-12,Set-1,Q2(a)

Algorithmgetblk

Input:filesystemnumber

blocknumber

Output:lockedbufferthatcannowbeusedforblock{

While(buffernotfound)

{

If(blockisnotinhashqueue)

If(therearenobuffersonfreelist){

sleep(eventanybufferbeesfree);continue;

}}}}

(b)Whataretheadvantagesofbuffer

cache?

Answer:April/May-12,Set-1,Q2(b)

ForanswerreferUnit-II,Q12,Topic:AdvantagesofBufferCache.

(a)Givebriefdescriptionaboutthe

accessingofinodes.

Answer:April/May-12,Set-1,Q3(a)

Accessingofinodescanbeexplainedwellthroughthealgorithmthatallocatesin-coreinodes.

(b)Explainindetailthecontinuousfileallocationsystem.

Answer:

April/May-12,Set-1,Q3(b)

Note:Ingivenquestion,thewordcontiguousismisprintedascontinous.

Inacontiguousallocationmethodallthefilesarearrangedinasequentialblocksofmemory.Therefore,accordingtothistechnique,ifafilesizeiskblocksanditstartsfromablocksthenitspanstillstk-1blocknumbers.Withthisapproachfileaccessismuchfasterasallfilesoccupycontiguousblocks.Forsequentialaccessoffilesthephysicaladdressofthelastreferredblockisnoted,sothatfileaccesscanstartfromthenextblocktoavoidrepeatedaccesseofthepreviousblocks.Directaccessisalsosupportedsinceonlythestartingaddressandtheblocknumbersarerequired.

Thoughaccesstimeisminimal,contiguousallocationdoesnotmakeefficientuseofthediskspace.Thismeansthattheallocationofspaceforanewfileshouldbeefficientenoughsothatdiskspaceisnotwasted.

0123456

7

891011IMP121314

15

16171819USER2024222324252627CHAT

2829303132

33

34

35

DISK

FOODirectory

FilenameStartinglocation

SizeFooImpUserChat

0614263764

Figure:ContiguousAllocation

S.3

UnixInternals(April/May-2024,Set-1)JNTU-Anantapur

B.Tech.III-YearII-Sem.(JNTU-Anantapur)

monstrategiesusedforthispurposesarebestfit,worstfitandfirstfit.Firstfitisconsideredtousuallybefasterthanothertwostrategies.However,bestfitisalsoconsideredtobeefficientthanworsefitintermsofbothtimeanddiskspaceutilization.

Evenifanyofthesestrategiesareusedallofthemsufferwithexternalfragmentation.Externalfragmentationoccurswhenarequestforanewfilecannotbesatisfiedbecausethelargestavailablecontinouschunkofblocksisnotsufficientenoughforthefile.Therefore,eventhoughthereisenoughspaceavailableforthefile,butitisnotutilizedbecauseitisnotcontiguous.

Externalfragmentationcanberesolvedwiththehelpofaschemecalled“paction”.Compactioninvolvesrearrangingallfreememorylocationsinasequentialordersothatcontiguousdiskspacecanbeallocatedfornewfilesinsteadofspacegettingwasted.Compactioniscarriedoutinbothofflineandonlinemodes.Inofflinemode,alloperationsaresuspendedandthefilesystemisunmountedandfinallypactionisperformed.Inthisstrategyalotoftimeiswastedandhenceitisavoided.Inonlinemode,pactionisperformedalongwithothersystemoperations,butiteffectsbusinessperformanceandreducestimewastages.

However,contiguousallocationschemealsorequirestoknowthesizeofthenewfileforstorageallocation.Thisrequirementlookssimplebutitmightbedifficulttodeterminethesizeofanoutputfileafteritsexecution.Alsoifthesizeofthefileisdeterminedinadvanceandthefiletakesalotoftimetoreachitsfinalsize,thenalotofspaceiswastedwhenthefilehasnotreacheditsfinalsize.Therefore,amodifiedcontiguousallocationschemeisusedthatallocatessomefixedamountofspaceforthefirsttimeandifthefilerequiresmorespacethenanotherchunkofcontiguousblocksisallocated.Thechunksoffreeblocksallocatedafterthefirstallocationiscalled“infant”andthesetwochunksofcontiguousblocksarelinkedtooneanother.

Q4.(a)Whatisthepurposeoflinksystemcall?

Writeandexplainthealgorithmforthesame.

Answer:April/May-12,Set-1,Q4(a)Link()SystemCall

Linksystemcallcreatesanewdirectoryforaninodethatalreadyexists.Itdoesthisbylinkingafiletoanewnameinthefilesystemdirectory.Ithasthefollowingsyntax,

Link(existingfilename,newfilename)

Thefilesystemconsistsofpathnamesforeachlink.Processesusethepathnamestoaccessfiles.AllthefilenamesaregivenequalprioritiessincetheKernelisunawareoftheoriginalfilename.

Figure:FilesLinkedintheFileSystemTreeAfterexecutingthesystemcalls

Link(“/usr/foo/sys/src”,“/usr/lib/src'');

Link(“/usr/lib/file3.h”,“/usr/Foo/src/file2h”);Thepaths–“/usr/Foo/sys/file2.h”,“/usr/lib/file3.h”and“/usr/lib/src/file2-h”belongtothesamefile.

TheKernelgivestheauthorityoflinkingdirectoriesonlytothesuperuses.Thismakesthecodingparteasyfortheprogramthattraversesthefilesystemtree.Superusershavetobecarefulenoughwhilelinkingdirectories.Theabilityoflinkingdirectoriesmustbesupportedonearlyversionsofthesystem.Thisisbecause,themkdirmandusedforcreatingnewdirectoriesdependsontheabilityoflinkingdirectories.Algorithmoflinksystemcall,thefollowingalgorithmshowsthelinkingoffiles.

1.Obtaintheinodeforexistingfilenameusingthe

“namei”algorithm.2.Iftherearemanylinksonfile/linkingdirectory

withoutsuperuserpermission.

(a)Releasetheinodeusing“iput”algorithm.(b)Returnerror.3.Incrementthelinkcount.4.Updatethediskcopyofinode.5.Unlockinode.6.Obtaintheparentforthenewfilenameinode

using“namei”algorithm.7.Ifthenewfilealreadyexists,

(a)Undotheupdatedoneinstep(4)(b)Returnerror.8.Makeanewdirectoryintheparentdirectoryof

thenewfilename.9.Addthenewfilenameandtheinodenumberof

theexistingfilename.

10.Releaseparentdirectoryinodeusing“iput”

algorithm.

11.Releasetheinodeoftheexistingfileusing“iput”

algorithm.

S.4SpectrumALL-IN-ONEJournalforEngineeringStudents,2024TheKerneluses“namei”algorithmtolookupfortheinodeforthesourcefile.Itincrementsthelinkcountandupdatesthediskcopyoftheinode.Thenitunlockstheinodeandsearchesforthetargetfile.The“Link”callwillfailifthefileisnotavailable.TheKerneldecrementsthelinkcountwhichwaspreviouslyincremented.Ifthefileisnotavailablethenitfindsafreeslotintheparentdirectoryofthetargetfile.Itwritesthenameofthetargetfileandinodenumberofthesourcefileintoit.Usingthe“iput”algorithm,itreleasestheinodeofthetargetfileparentdirectory.Thetargetfiledidnotexistinactual.Hencenomoreinodesaretheretobereleased.

Finally,theKernelreleasesthesourcefileinodewhichisaccessedbyanotherfileinthefilesystem.Thelinkcountincreasesby1.Itkeepstrackofthecountofdirectoryentriesbelongingtothefile.Thisdifferentiatesitfromtheinodereferencecount.Ifthefileisnotaccessedbyanyotherprocesstheninodereferencecountofthefilebees0andthelinkcountwillbeatleast2.

(b)Writeshortnotesonmaintenanceofthefilesystem.

Answer:April/May-12,Set-1,Q4(b)ForanswerreferUnit-IV,Q17.

Q5.(a)Whatareregions?Explaintheirroleinthecreationofprocesses.

Answer:April/May-12,Set-1,Q5(a)ForanswerreferUnit-V,Q3,Topic:Regions.

(b)Describeindetailaboutthecontextofaprocess.

Answer:April/May-12,Set-1,Q5(b)ForanswerreferUnit-V,Q7.

Q6.(a)Explainthesecurityproblemsthatexistsifasetuidprogramisnotwriteprotected.Answer:April/May-12,Set-1,Q6(a)Thesecurityproblemsthatexistsifasetuidprogramisnotwriteprotectedareasfollows,

1.Thefirstproblemisassociatedwithexecutingasequenceofmandsdefinedbytheattacker.

2.Thesecondproblemisassociatedwithsubstitutingdataoftheattacker’schoosingfordatacreatedbya

program.

Inthefirstproblem,anattackertakesadvantageofthesetuidprogram’srunningwithspecialprivilegestoforceittoexecutewhatevermandstheattackerneeds.Forinstance,assumethatanattackerfoundacopyoftheBourneshellthatwassetuidtoroot.Theattackercouldthenexecutetheshellsince,theshellissetuidtorootthesemandswouldbeexecutedasthoughroothadtypedthem.Hence,theattackercoulddoanythinghewants,sincerootisthemosthighlyprivilegeduseronthesystem.Eveniftheshellwerechangedtoreadfromamandfileratherthanacceptmandsinteractively,theattackercouldfilesimplycreatehisownscriptandruntheshellusingit.Thissituationmustbeavoidedanditiseasytoavoidbutitoccursfrequently.

Severalproblemsarepossiblewithworld-writablefiles.Occasionallyprogramswillusetemporaryfilesforvariouspurposes,thefunctionoftheprogramdependingonwhatisinthefile.Iftheprogramclosesthetemporaryfileatanypointandthenreopensitlater,anattackercanreplacethetemporaryfilewithafilewithotherdatathatwillcausetheprogramtoactastheattackerdesires.Ifthereplacementfilehasthesameownerandgroupasthetemporaryfile,itcanbeverydifficultfortheprogramtodetermineifitisbeingspoofed.

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论