admin 管理员组

文章数量: 1086019


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

本文标签: 套用 函数

更多相关文章

程序设计总结(推荐12篇)

3月前

年月日发(作者:网上商城系统平台)程序设计总结第篇文件的定义:存储在外部存储介质(外存)上数据的集合。语言将每一个与主机相连的输入或输出设备都看作是一个文件文件的使用和管理:在程序运行时由程序在外存上建立或打开一个文件,通过写操作将数据存入

C语言程序设计试题及答案解析[1]

3月前

年月日发(作者:网络命令大全及用法)语言程序设计试题第、、章概述、类型、表达式一、选择题、一个程序由若干个函数组成,各个函数在文件中的位置顺序为:()、任意、第一个函数必须是主函数,其他函数任意、必须完全按照执行的顺序排列、其他函数可以任意

Python等级考试——第一课优质word(1)练习

3月前

年月日发(作者:)等级考试——第一课优质()练习一、选择题.语句""""*的运行结果是()..()..()..()..().在中,返回的绝对值的函数是()。.以下程序运行后的输出结果为()....::()():(,”)()程序代码中处正确的

程序设计语言 复习资料

3月前

年月日发(作者:数据库文件还原)程序设计语言复习资料一、单项选择题、一台完整的计算机系统包括()。、硬件系统和软件系统、系统硬件和系统软件、控制器、运算器、存储器、输入设备和输出设备、操作系统、机器语言、汇编语言、高级语言、下列属于#语言的

C语言第一二三章习题

3月前

年月日发(作者:文件夹)(一)判断题(用表示正确,表示错误)说明:在以下提供的若干陈述中,逐一判断其正确与否,选表示正确,选表示错误。、函数是程序的基本单位,每个程序中允许有多个函数。()、在程序中允许行有多个语句,一个语句分多行写。()、

程序设计基础(C语言)智慧树知到课后章节答案2023年下温州理工学院

3月前

年月日发(作者:访问路由方式)程序设计基础(语言)智慧树知到课后章节答案年下温州理工学院温州理工学院第一章测试.以下哪个叙述是不正确的编程风格()。答案:程序中的注释可有可无.语言程序的执行,总是起始于()。答案:函数.以下叙述中正确的是(

Python语言程序设计基础(第2版)全答案v3-20180823

3月前

年月日发(作者:编程设计软件)语言程序设计基础(第版)全答案(..,年月)嵩天礼欣黄天羽著(本文档由该书原作者提供,有任何修改意见请反馈:黄天羽@。)目录目录.........................................

各种编程语言的区别与联系

3月前

年月日发(作者:字符代码对照表)各种编程语言的区别与联系:分三大平台(),(),()是和的基础是目前位置企业级开发平台中最牛的是用来开发移动嵌入式程序的,例如手机游戏的优点是非常适合用于开发大型企业级项目,我们曾为网通公司开发过的上千万级的

程序设计基础试题及答案

3月前

年月日发(作者:配置文件加密)程序设计基础试题及答案一、选择题(每题分,共分).下列哪个选项是语言中正确的整型常量表示?....和答案:.在语言中,下列哪个关键字用于声明一个函数?....答案:.以下哪个选项是合法的语言变量名?..._.答

程序设计基础试题一及答案

3月前

年月日发(作者:商店下载)程序设计基础试题一及答案考试时间:总分:题号一二三四五得分一、填空题(每空分,共分)()__________语言是计算机唯一能够识别并直接执行的语言。()算法的复杂度包含两方面:和。()__函数是语言程序启动时惟一

C语言 程序设计基础试题四及答案

3月前

年月日发(作者:)《程序设计基础》考试试卷四班级姓名学号一、选择题(每题分,共分)题号一二得分三四五总得分评卷人审核人.以下叙述中正确的是().程序中注释部分可以出现在程序中任意合适的地方.花括号"{"和"}"只能作为函数体的定界符.构成程

2023年山东省德州市全国计算机等级考试数据库技术真题(含答案)

3月前

年月日发(作者:脚本函数)年山东省德州市全国计算机等级考试数据库技术真题(含答案)学校:________班级:________姓名:________考号:________一、.选择题(题).计算机的技术性能指标主要是指.所配备语言、操作系统

C语言各章节复习题(带答案)

3月前

年月日发(作者:鼠标放上去改变背景颜色)一、语言概述练习题选择.一个程序的执行是从。)本程序的函数开始,到函数结束)本程序文件的第一个函数开始,到本程序文件的最后一个函数结束)本程序文件的第一个函数开始,到本程序函数结束)本程序的函数开始,

c语言缺少函数头怎么办,c语言编译时如何解决缺少头文件和库的问题

2月前

问题原因: 我们都知道我们写一个程序不可能所有东西都重头去开发,因此我们会使用一些其它人写好的文件或者说叫做库函数等。但是有时候因为路径的设置不对,或者是文件的丢失&

Windows.h中的函数有哪些?

2月前

今天我来给大家介绍一些常用的Windows.h中的函数。 这些函数非常适合做病毒,,对病毒感兴趣的朋友可以来看看。 Windows.h 是 Windows API 的主要头文件&#xf

RFdiffusion get_potential_gradients函数解读

2月前

get_potential_gradients是Denoise类中一个方法。get_potential_gradients方法的目的是计算每个 Cα 原子的势能梯度,用于指导扩散更新。这些梯度可以提供物理或几何约束,使扩散生成的坐标更加合理

Qt5.9获取Windows所有盘符(函数QFileInfoList QIr::drives())

1月前

1.1Qt5.9获取所有盘符用函数QFileInfoList QIr::drives(),代码如下: foreach (QFileInfo my_info, QDir::drives()){qD

Android readelf 工具查找函数符号

1月前

ELF(Executable and Linkable Format)是一种执行文件和可链接文件的格式。它是一种通用的二进制文件格式,用于在各种操作系统中存储可执行程序、共享

在Windows环境下使用fork()函数的解决方案

1月前

在windows下使用linux环境的folk会出现:‘fork’ was not declared in this scope. 下面是免装虚拟机系统,或者换LINux系统的办法。 请下载安装cygwin,安装特定的版本的G++,GC

windows客户端开发--通过ShellExecute函数打开浏览器

1月前

在我们的客户端中常常会有一些link,点击后希望通过浏览器导航到该链接。 我们是通过ShellExecute函数来实现的。 ShellExecute的功能是运行一个外部程序(或者是打开一个已注册的文件、打开一个目录、打印一个文件等等),

发表评论

全部评论 0
暂无评论