admin 管理员组文章数量: 1184232
2024年6月7日发(作者:if和vlookup函数套用)
MODERN
OPERATING
SYSTEMS
THIRDEDITION
PROBLEMSOLUTIONS
AUM
VrijeUniversiteit
Amsterdam,TheNetherlands
PRENTICEHALL
UPPERSADDLERIVER,NJ07458
CopyrightPearsonEducation,Inc.2008
SOLUTIONSTOCHAPTER1PROBLEMS
rogrammingistherapidswitchingoftheCPUbetweenmultipleproc-
mmonlyusedtokeeptheCPUbusywhileoneor
moreprocessesaredoingI/O.
poolingisthetechniqueofreadinginjobs,forexample,fromcards,
ontothedisk,sothatwhenthecurrentlyexecutingprocessesarefinished,
spoolingconsistsoffirst
copyingprintablefilestodiskbeforeprintingthem,ratherthanprintingdi-
poolingonapersonalcomputerisnot
verylikely,butoutputspoolingis.
mereasonformultiprogrammingistogivetheCPUsomethingtodo
whilewaitingforI/eisnoDMA,theCPUisfullyoccu-
pieddoingI/O,sothereisnothingtobegained(atleastintermsofCPUutili-
zation)erhowmuchI/Oaprogramdoes,the
CPUwillbe100%courseassumesthemajordelayisthewait
ulddootherworkiftheI/Owereslowfor
otherreasons(arrivingonaserialline,forinstance).
mple,IntelmakesPentiumI,II,andIII,and4CPUs
withavarietyofdifferentpropertiesincludingspeedandpowerconsumption.
fferonlyin
priceandperformance,whichistheessenceofthefamilyidea.
5.A25×
1024×768pixel24-bitcolorbitmaprequires2,359,1980these
twooptionswouldhavecost$10and$11,520,rent
prices,checkonhowmuchRAMcurrentlycosts,probablylessthan$1/MB.
ssrequiresthateachprocessbeallo-
cateditsresourcesinafairway,withnoprocessgettingmorethanitsfair
therhand,realtimerequiresthatresourcesbeallocatedbased
-
timeprocessmaygetadisproportionateshareoftheresources.
s(a),(c),and(d)shouldberestrictedtokernelmode.
ake20,25or30msectocompletetheexecutionoftheseprograms
0andP1are
scheduledonthesameCPUandP2isscheduledontheotherCPU,itwill
0andP2arescheduledonthesameCPUandP1is
scheduledontheotherCPU,1andP2arescheduled
onthesameCPUandP0isscheduledontheotherCPU,itwilltake30msec.
IfallthreeareonthesameCPU,itwilltake35msec.
2
PROBLEMSOLUTIONSFORCHAPTER1
ansthe
notmatterat
allhowmanystagesthepipelinehas.A10-stagepipelinewith1nsecper
tmattersis
howoftenafinishedinstructionpopsouttheendofthepipeline.
eaccesstime=
0.95×2nsec(wordiscache)
+0.05×0.99×10nsec(wordisinRAM,butnotincache)
+0.05×0.01×10,000,000nsec(wordondiskonly)
=5002.395nsec
=5.002395μsec
uscriptcontains80×50×700=,of
course,impossibletofitintotheregistersofanycurrentlyavailableCPUand
istoobigfora1-MBcache,butifsuchhardwarewereavailable,the
manuscriptcouldbescannedin2.8msecfromtheregistersor5.8msecfrom
reapproximately27001024-byteblocksofdata,soscan-
ningfromthediskwouldrequireabout27seconds,andfromtape2minutes7
se,singand
rewritingthedatawouldincreasethetime.
allergetscontrolbackandimmediatelyoverwritesthedata,
whenthewritefinallyoccurs,r,ifthe
driverfirstcopiesthedatatoaprivatebufferbeforereturning,thenthecaller
rpossibilityistoallowthe
callertocontinueandgiveitasignalwhenthebuffermaybereused,butthis
istrickyanderrorprone.
nstructionswitchestheexecutionmodeofaCPUfromtheusermode
structionallowsauserprogramtoinvokefunc-
tionsintheoperatingsystemkernel.
rogramis
runagainandagain,thetrapwillalwaysoccuratexactlythesamepositionin
rruptiscausedbyanexternaleventandits
timingisnotreproducible.
cesstableisneededtostorethestateofaprocessthatiscurrently
suspended,tneededinasingleprocesssys-
tembecausethesingleprocessisneversuspended.
ngafilesystemmakesanyfilesalreadyinthemountpointdirectory
inaccessible,r,asystemadmin-
istratormightwanttocopysomeofthemostimportantfilesnormallylocated
inthemounteddirectorytothemountpointsotheycouldbefoundintheir
normalpathinanemergencywhenthemounteddevicewasbeingrepaired.
PROBLEMSOLUTIONSFORCHAPTER1
3
mcallallowsauserprocesstoaccessandexecuteoperatingsystem
ogramsusesystemcallstoinvokeoperat-
ingsystemservices.
18.
Fork
canfailiftherearenofreeslotsleftintheprocesstable(andpossiblyif
thereisnomemoryorswapspaceleft).
Exec
canfailifthefilenamegiven
doesnotexistorisnotavalidexecutablefile.
Unlink
canfailifthefiletobe
unlinkeddoesnotexistorthecallingprocessdoesnothavetheauthorityto
unlinkit.
allfails,forexamplebecausefdisincorrect,itcanreturn−
alsofailbecausethediskisfullanditisnotpossibletowritethenumberof
recttermination,italwaysreturnsnbytes.
ainsthebytes:1,5,9,2.
retrievethefile=
1*50ms(Timetomovethearmovertrack#50)
+5ms(Timeforthefirstsectortorotateunderthehead)
+10/100*1000ms(Read10MB)
=155ms
pecialfilesconsistofnumberedblocks,eachofwhichcanbereador
ssibletoseektoanyblock
notpossiblewithcharacterspecialfiles.
callsdonotreallyhavenames,otherthaninadocumentationsense.
Whenthelibraryprocedurereadtrapstothekernel,itputsthenumberofthe
mberisusedtoindexintoa
therhand,thename
ofthelibraryprocedureisveryimportant,sincethatiswhatappearsinthe
program.
an,especiallyifthekernelisamessage-passingsystem.
sprogramlogicisconcerneditdoesnotmatterwhetheracalltoali-
erformanceisanissue,ifa
taskcanbeaccomplishedwithoutasystemcalltheprogramwillrunfaster.
Everysystemcallinvolvesoverheadtimeinswitchingfromtheusercontext
rmore,onamultiusersystemtheoperatingsys-
temmayscheduleanotherprocesstorunwhenasystemcallcompletes,
furtherslowingtheprogressinrealtimeofacallingprocess.
l
UNIX
callshavenocounterpartintheWin32API:
Link:aWin32programcannotrefertoafilebyanalternativenameorseeit
,attemptingtocreatealinkisaconvenient
waytotestforandcreatealockonafile.
4
PROBLEMSOLUTIONSFORCHAPTER1
Mountandumount:aWindowsprogramcannotmakeassumptionsabout
standardpathnamesbecauseonsystemswithmultiplediskdrivesthedrive
namepartofthepathmaybedifferent.
Chmod:Windowsusesaccesscontrollists
Kill:Windowsprogrammerscannotkillamisbehavingprogramthatisnot
cooperating.
ystemarchitecturehasitsownsetofinstructionsthatitcanexecute.
ThusaPentiumcannotexecuteSPARCprogramsandaSPARCcannotexe-
,differentarchitecturesdifferinbusarchitecture
used(suchasVME,ISA,PCI,MCA,SBus,...)aswellasthewordsizeofthe
CPU(usually32or64bit).Becauseofthesedifferencesinhardware,itisnot
y
portableoperatingsystemwillconsistoftwohigh-levellayers---amachine-
hine-dependent
layeraddressesthespecificsofthehardware,andmustbeimplementedsepa-
yerprovidesauniforminterfaceonwhich
hine-independentlayerhasto
ghlyportable,thesizeofthemachine-
dependentlayermustbekeptassmallaspossible.
tionofpolicyandmechanismallowsOSdesignerstoimplementa
rimitivesaresim-
plified,nthen
beusedtoimplementmorecomplexmechanismsandpoliciesattheuser
level.
versionsarestraightforward:
(a)Amicroyearis10
−6
×365×24×3600=31.536sec.
(b)1000metersor1km.
(c)Thereare2
40
bytes,whichis1,099,511,627,776bytes.
(d)Itis6×10
24
kg.
SOLUTIONSTOCHAPTER2PROBLEMS
ethataprocess
isblockedonI/OandtheI/OfiPUisotherwiseidle,theproc-
ermissingtransition,
fromreadytoblocked,processcannotdoI/Oorany-
unningprocesscanblock.
PROBLEMSOLUTIONSFORCHAPTER2
5
ldhavearegistercontainingapointertothecurrentprocesstable
/Ocompleted,theCPUwouldstorethecurrentmachinestatein
wouldgototheinterruptvectorforthe
interruptingdeviceandfetchapointertoanotherprocesstableentry(theser-
viceprocedure).Thisprocesswouldthenbestartedup.
lly,high-levellanguagesdonotallowthekindofaccesstoCPUhard-
tance,aninterrupthandlermayberequiredto
enableanddisabletheinterruptservicingaparticulardevice,ortomanipulate
datawithinaprocess’,interruptserviceroutinesmustexe-
cuteasrapidlyaspossible.
,youdonotwanttheoperatingsystemtocrashbe-
causeapoorlywrittenuserprogramdoesnotallowforenoughstackspace.
Second,ifthekernelleavesstackdatainauserprogram’smemoryspace
uponreturnfromasystemcall,amalicioususermightbeabletousethisdata
tofindoutinformationaboutotherprocesses.
jobhas50%I/Owait,thenitwilltake20minutestocompleteinthe
equentially,thesecondonewillfinish40
minutesafterthefiojobs,theapproximateCPUutiliza-
tionis1−0.5
2
.Thuseachonegets0.375CPUminuteperminuteofreal
mulate10minutesofCPUtime,ajobmustrunfor10/0.375
minutes,nningsequentiallythejobsfinish
after40minutes,butrunninginparalleltheyfinishafter26.67minutes.
dbedifficult,ifnotimpossible,tokeepthefi-
posethataclientprocesssendsarequesttoserverprocess1toupdateafile.
ythereafter,anoth-
erclientprocesssendsarequesttoserver2toreadthatfiunately,if
thefileisalsocachedthere,server2,initsinnocence,willreturnobsolete
firstprocesswritesthefilethroughtothediskaftercachingit,
andserver2checksthediskoneveryreadtoseeifitscachedcopyisup-to-
date,thesystemcanbemadetowork,butitispreciselyallthesediskac-
cessesthatthecachingsystemistryingtoavoid.
gle-threadedprocessisblockedonthekeyboard,itcannotfork.
user-levelthreadsarebeingused,thisactionwillblocktheentireprocess,
isessentialthatkernelthreads
areusedtopermitsomethreadstoblockwithoutaffectingtheothers.
erverisentirelyCPUbound,thereisnoneedtohavemultiple
ample,consideratele-
phonedirectoryassistancenumber(like555-1212)foranareawith1million
6
PROBLEMSOLUTIONSFORCHAPTER2
(name,telephonenumber)recordis,say,64characters,the
entiredatabasetakes64megabytes,andcaneasilybekeptintheserver’s
memorytoprovidefastlookup.
hreadisstopped,stbesaved,
ro-
grammingthreadsisnodifferentthanmultiprogrammingprocesses,soeach
threadneedsitsownregistersavearea.
d-
ingisneededforthegoodoftheapplication,
all,itisusuallythesameprogrammerwhowritesthecodeforallofthem.
-levelthreadscannotbepreemptedbytheclockunlessthewholeproc-
ess’-levelthreadscanbepreemptedindivi-
attercase,ifathreadrunstoolong,theclockwillinterruptthe
nelisfreetopickadif-
ferentthreadfromthesameprocesstorunnextifitsodesires.
ingle-threadedcase,thecachehitstake15msecandcachemissestake
ghtedaverageis2/3×15+1/3×emeanre-
ltithreaded
server,allthewaitingforthediskisoverlapped,soeveryrequesttakes15
msec,andtheservercanhandle662/3requestspersecond.
gestadvantageistheeffistothekernelareneededto
gestdisadvantageisthatifonethreadblocks,theen-
tireprocessblocks.
,achcalltopthread
版权声明:本文标题:现代操作系统(第三版)答案 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/b/1717699267a711128.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
更多相关文章
Postgresql12 recovery.conf 并入postgresql.conf以及主备切换函数介绍
从 12版本开始,不再有recovery.conf文件,recovery.conf配置的内容全部并入到postgesql.conf中。新增了两个文件recovery.signal和standby.
C程序设计基础(5):函数基础详解(函数定义、调用、原型、参数)
上一节中,我们学习了有关数组和字符串的常用方法。数组和字符串的加持大大降低了我们命名和使用变量的复杂程度,节约了代码量,但这还不够。程序编写过程中,我们
内核函数之schedule()函数
schedule()函数对于进程的切换,主要有两部分需要理解,一个是进程切换的时机,一个是schedule函数的调用过程。对于进程切换的时机,中断处理
Java多线程问题--schedule函数和scheduleAtFixedRate的用法和区别
本文内容部分引自《Java多线程编程核心技术》,感谢作者!!!代码地址:https:githubxianzhixianzhi
掌握技巧:实现SWF文件与Adobe Flash Player内全局热键功能,提升操作效率
软件环境:Visual Studio 2008 SP1本次目的:实现全局热键的效果 我们知道,通常在聊QQ的时候有新信息到来的时候,同时按下Ctrl+Alt+Z就能弹出新消息的聊天窗口。现在让我们来实现系统热键。
聪明选择,智慧使用:窗口化助手让你的PC游戏体验更流畅、更舒适!
内容参考于: 易道云信息技术研究院VIP课上一个内容: 码云地址(游戏窗口化助手 分支): 码云版本号:e85c0fc8b85895c8c2d3417ec3c75bcad8e7c41d
掌握技术,玩转游戏:调优窗口化分辨率的adjustwindowrectex指南
免责声明: 内容仅供学习参考,请合法利用知识,禁止进行违法犯罪活动!内容参考于: 易道云信息技术研究院上一个内容: 首先使用 Ollydbg.exe 调试它生成的exe文件
Adobe Flash Player幕后技术:深入探讨游戏窗口化助手的制作与优化方法
内容参考于: 易道云信息技术研究院VIP课上一个内容: 码云地址(游戏窗口化助手 分支): 码云版本号:e85c0fc8b85895c8c2d3417ec3c75bcad8e7c41d
办公软件大对决!Office2019 VS Office2016,究竟选哪一个提升效率?
Office2019与Office2016:功能对比与选择建议在当今的办公环境中,Office软件无疑是必备的工具之一。随着技术的不断进步,Office软件也在持续更新迭代。尽管Office软件已经升级至Office20
深入解读Vulkan API:当遇到"Segmentation Fault"时,尝试通过"VkCreateInstance"的解决策略
学习vulkan有不短的时间了,几年前就遇到这个bug,直到最近才终于彻底解决了,泪目本文记录了作者在使用Vulkan创建实例时,如果想加入调试回调以跟踪实例本身创建过程,遇到的问题及解决方法。 分类:笔记
Qt应用中的右键菜单功能揭秘:打造个性化用户界面
1、右键菜单创建和显示 作为一种交互性强、使用方便的右键菜单在程序中是非常常用的,在Qt中可以轻松的实现。 QMenu menu; 添加菜单项,指定图标、名称、响应函数menu.addAction(QIcon("
MTK CAM源码解析:Android 8.1系统下Camera open的全过程揭秘
之前已经写过一篇关于camera框架的文章,现在开始写camera相关的功能流程,总结一下常用的camera流程,算是对camera开发的一个回顾。 首先先看下camera open流程,基于mtk release代码,使用c
掌握QQ音乐播放器的DC:破解桌面歌词画面的提取策略
在直播项目中 需要捕获某个窗口的画面并共享 总结了如下几种场景中窗口的捕获方法 1、dc拷贝(BitBlt、PrintWindow) 这是最基本的方法 直接拿到窗口dc 然后从dc中拷贝窗口画面 可优先使用PrintW
ComfyUI揭秘:轻松捕捉SWF与Flash中心窗口画面的秘密
在直播项目中 需要捕获某个窗口的画面并共享 总结了如下几种场景中窗口的捕获方法 1、dc拷贝(BitBlt、PrintWindow) 这是最基本的方法 直接拿到窗口dc 然后从dc中拷贝窗口画面 可优先使用PrintW
解锁音乐新技能:网易云、酷狗、QQ音乐的DC窗口,你真的会用吗?
在直播项目中 需要捕获某个窗口的画面并共享 总结了如下几种场景中窗口的捕获方法 1、dc拷贝(BitBlt、PrintWindow) 这是最基本的方法 直接拿到窗口dc 然后从dc中拷贝窗口画面 可优先使用PrintW
掌握Qt右键菜单实现,提升应用功能多样性
Qt实现右键菜单 1、前言 在GUI编程中,右键菜单被广泛使用。Qt作为一个流行的GUI框架,也提供了很好的支持。本文将介绍Qt中如何实现右键菜单。 2、实现方法 Qt中实现右键菜单有两种方法:
Qt中的秘密武器:深度解析右键菜单设计与管理
1、右键菜单创建和显示 作为一种交互性强、使用方便的右键菜单在程序中是非常常用的,在Qt中可以轻松的实现。 QMenu menu; 添加菜单项,指定图标、名称、响应函数menu.addAction(QIcon("
VLOOKUP大揭秘:在Excel中快速查找并匹配两个表格中的相同数据
最近学习了vlookup函数,写个笔记。 文件1.xlsx如下(最后一列“说明”为查找而添加,不包含在原文件中): 文件2.xlsx如下(最后一列“说明”为查找而添加,不包含在原文件中): 文件1、2中有一部分
解锁WinPcap新技能:揭秘wpcap.dll和_winpcap.lib的隐藏功能
wpcap.dll是一个包含了公共WinPcap API的动态链接库,它输出了一组依赖于系统的函数,用来捕获和分析网络流量。wpcap.dll与libpcap兼容,其中的函数用途有: (1)获取网络适配器列表 (2)获
掌握WinPcap的两大法宝:wpcap.dll和Winpcap.lib,成就专业级网络工程师
wpcap.dll是一个包含了公共WinPcap API的动态链接库,它输出了一组依赖于系统的函数,用来捕获和分析网络流量。wpcap.dll与libpcap兼容,其中的函数用途有: (1)获取网络适配器列表 (2)获
发表评论