资源描述:
《现代操作系统作业答案》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、ModernOperatingSystemsSolutionsZhangYangSpring2015Chapter21.Thetransitionfromblockedtorunningisconceivable.SupposethataprocessisblockedonI/OandtheI/Ofinishes.IftheCPUisotherwiseidle,theprocesscouldgodirectlyfromblockedtorunning.Theothermissingtransition,fromreadytoblocked,isimpossible.Areadyproc
2、esscannotdoI/Ooranythingelsethatmightblockit.Onlyarunningprocesscanblock.8.AworkerthreadwillblockwhenithastoreadaWebpagefromthedisk.Ifuser-levelthreadsarebeingused,thisactionwillblocktheentireprocess,destroyingthevalueofmultithreading.Thusitisessentialthatkernelthreadsareusedtopermitsomethreadst
3、oblockwithoutaffectingtheothers.11.Threadsinaprocesscooperate.Theyarenothostiletooneanother.Ifyieldingisneededforthegoodoftheapplication,thenathreadwillyield.Afterall,itisusuallythesameprogrammerwhowritesthecodeforallofthem.Figure2-8AmultithreadedWebserver14.Thebiggestadvantageisefficiency.Notra
4、pstothekernelareneededtoswitchthreads.Thebiggestdisadvantageisthatifonethreadblocks,theentireprocessblocks.28.Withkernelthreads,athreadcanblockonasemaphoreandthekernelcanrunsomeotherthreadinthesameprocess.Consequently,thereisnoproblemusingsemaphores.Withuser-levelthreads,whenonethreadblocksonase
5、maphore,thekernelthinkstheentireprocessisblockedanddoesnotruniteveragain.Consequently,theprocessfails.31.Itdoesnotleadtoraceconditions(nothingiseverlost),butitiseffectivelybusywaiting.37.(a)Forroundrobin,duringthefirst10minuteseachjobgets1/5oftheCPU.Attheendof10minutes,Cfinishes.Duringthenext8mi
6、nutes,eachjobgets¼oftheCPU,afterwhichtimeDfinishes.Theneachofthethreeremainingjobsgets1/3oftheCPUfor6minutes,untilBfinishes,andsoon.Thefinishingtimesforthefivejobsare10,18,24,28,and30,foranaverageof22minutes.Average=(10+18+24+28+30)/5=22minutes37.(b)priorityTurnaroundtimeofB=6minutesTurnaroundti
7、meofE=14minutesTurnaroundtimeofA=24minutesTurnaroundtimeofC=26minutesTurnaroundtimeofD=30minutesAverage=(6+14+24+26+30)/5=20minutes0B6EACD1424263037.(c)FCFSTurnaroundtimeofA=10minutesTurnaroundtimeofE=16minutesTurnaroundtime