操作系统期中作业答案.docx
- 文档编号:16312277
- 上传时间:2023-07-12
- 格式:DOCX
- 页数:7
- 大小:33.26KB
操作系统期中作业答案.docx
《操作系统期中作业答案.docx》由会员分享,可在线阅读,更多相关《操作系统期中作业答案.docx(7页珍藏版)》请在冰点文库上搜索。
操作系统期中作业答案
操作系统期中作业(答案)
操作系统期中作业
姓名:
___学号:
专业:
一、Foreachofthefollowingstatements,ChoosingTrueorFalse
1.Binarysemaphoresarethosethatareusedbynomorethantwothreads.F
2.TheBanker'salgorithmisawayofpreventingdeadlock.F
3.Amulti-levelindexedfilepermitsfasterrandomaccessthanacontiguouslyallocatedfile.F
4.Anatomicoperationisamachineinstructionorasequenceofinstructionsthatmustbeexecutedtocompletionwithoutinterruption.T
5.Deadlockisasituationinwhichtwoormoreprocesses(orthreads)arewaitingforaneventthatwilloccurinthefuture.F
6.Starvationisasituationinwhichaprocessisdeniedaccesstoaresourcebecauseofthecompetitiveactivityofother,possiblyunrelated,processes.T
7.Whileaprocessisblockedonasemaphore'squeue,itisengagedinbusywaiting.F
8.Mutualexclusioncanbeenforcedwithageneralsemaphorewhoseinitialvalueisgreaterthan1.F
9.Aprinterisanexampleofalogicalresource.F
10.VersionsofOS/360arestillwidelyusedtoday.F
11.Whenanexecutingprocessisstoppedbythescheduler,itissaidtobeblocked.F
12.InterruptsareusedtoachieveatypicaltimesharingOS.T
二、MultipleChoiceQuestions
Foreachofthefollowingquestions,Thereisonlyonecorrectanswer.
1.Whatisthepurposeofsystemcalls?
a)Systemcallsallowuser-levelprocessestogainresourcesfromtheoperatingsystem.
b)Systemcallsarethestandardinterfacebetweenauserprocessandakernelprocess.
c)Systemcallsallowuser-levelprocessestorequestservicesoftheoperatingsystem.
d)Thereisnorealpurposetosystemcalls.
2.Threadsbelongingtothesameprocesssharethe
a)stackb)datasection
c)registersetd)threadID
3.InMany-to-Onethreadmodel,Whatwouldhappenifathreadinamultithreadedprocessmakesablockingsystemcall?
a)theotherthreadsoftheprocesswouldcontinuetorun
b)theentireprocesswouldgetblocked
c)theblockingthreadwillgetkilled
d)theblockingthreadwillnevergettorunagain
4.WhichofthefollowingOperatingsystemsusespreemptivescheduling?
a)MacOS8b)Windows3.x
c)Windows2000d)DOS6.0
5.Ameasureofthenumberofprocessescompletedpertimeunitiscalled
a)throughputb)waitingtime
c)responsetimed)CPUutilization
6.Oneoftheproblemswithpriorityschedulingis
a)agingb)starvation
c)processdeathd)averagewaitingtime
7.Inatime-sharingsystem,whichofthefollowingisthebestcriterionforCPUscheduling.
a)MinimizeCPUutilizationb)MaximizeCPUutilization
c)Maximizesystemthroughputd)Minimizeresponsetime.
8.TheinitialvalueofsemaphoreSis2.ifthevalueis-1atpresent,howmanyprocessesareblockedonthissemaphore.
a)1b)2c)3d)4
9.Asystemisinadeadlock,ifitsresourceallocationgraph
a)containsacycle
b)doesn’tcontainacycle
c)containsacycleandthereisjustoneinstanceofeveryresource
d)hasatleastoneoutgoingedgefromanyoneoftheprocessnodes
10.Preemptionofresourcescanbeenforcedtopreventoccurrenceofdeadlocks,butthiscan’tbeappliedtoalltheresourcetypes,aspreemptionmightleavetheresourceinanundeterminedstate.Whichofthefollowingresourcescan’thencebepreempted?
a)CPUregistersb)memoryspace
c)tapedrived)alloftheabove
11.Asystemissaidtobe___________ifitcancontinuetofunctionevenwhenanodeornodesinthesystemfail.
a)networkedb)distributed
c)realtimed)fault-tolerant
12.Whichofthefollowingactivityneedsnospecialhardwaresupport?
a)Processschedulingb)timermanagement
c)memorymappingd)interruptsystem
13.Whichofthefollowingstatementaboutprocessesisincorrect?
a)Aprocessisdynamic.
b)Aprocesshasalifetime.
c)Aprocessisasetofinstructions.
d)Multipleprocessesmayexecuteconcurrently.
三、Considerthefollowingsetofprocesses:
ProcessBurst-TimePriority
P1154
P238
P375
P452
P516
P626
TheprocessesareassumedtohavearrivedintheorderP1,P2,P3,P4,P5,P6,allattime0.UseFCFS,SJF,RoundRobin(quantumis2),Priority(lownumbershavehighpriority).Foreachofthealgorithms:
1DrawaGanttchart
2.Whatistheaveragewaitingtimeforeachoftheschedulingalgorithms?
3.Whatistheaverageturnaroundtimeforeachoftheschedulingalgorithms?
Answer:
FCFS:
P1
P2
P3
P4
P5
P6
151825303133
AWT=(0+15+18+25+30+31)/6=19.83
ATT=(15+18+25+30+31+33)/6=25.33
SJF:
P5
P6
P2
P4
P3
P1
AWT=(18+3+11+6+0+1)/6=6.5
ATT=(33+6+18+11+1+3)/6=12
Round-Robin(quantum=2):
P1
P2
P3
P4
P5
P6
P1
P2
P3
P4
P1
P3
P4
P1
P3
P1
AWT=(18+11+19+8+9)/6=13.83
ATT=(33+14+26+23+9+11)/6=19.33
Priority:
P4
P1
P3
P5
P6
P2
AWT=(5+30+20+0+27+28)/6=18.33
ATT=(20+33+27+5+28+30)/6=23.83
四、Twoconcurrentprocesseshaveinput,computingandprintingactions,respectively.ThatissaidI1,C1,P1forthe1stprocess,andI2,C2,P2forthe2ndprocess.Theirprecedentialrelationshipisshowninthefigure,i.e.I2musthappenafterI1,C2musthappenafterC1andI2,etc.Pleasedescribethesynchronizationrelationshipoftwoprocessesbymeansofsemaphoresandrelatedwait/signaloperations.
五、
Semaphore:
s1,s2,s3:
=0;
P1:
P2:
{{
I1;wait(s1);
signal(s1);I2
C1;wait(s2);
signal(s2);C2;
P1;wait(s3);
signal(s3);P2;
}}
五、TherearethreecooperativeprocessesP1,P2,andP3.Theyreaddata,denotedasa、bandc,fromthesameinputdevice,asshowninfigurebelow.Theinputdeviceisanexclusiveaccessdevice.Thefirstdatum(a)mustbereadbyprocessP1,theseconddatum(b)isreadbyprocessP2,andthethirddatum(c)byprocessP3.Thesethreeprocessesperformthefollowingcalculations:
P1:
x=a+b
P2:
y=a*b
P3:
z=y+c-a
P1,whichislinkedtotheprinter,shouldprinttheresultsofx,y,andz.Writethepseudocodeforthethreeprocesses,usingsemaphorestosynchronizetheiractivities.
Semaphore:
s1,s2,s3,s4,s5:
=0;
P1:
P2:
P3:
{{{
Input(a)wait(s1)wait(s3)
signal(s1)input(b)input(c)
wait(s2)signal(s2)wait(s4)
x=a+bsignal(s3)z=y+c-a
wait(s5)y=a*bsignal(s5)
Print(x,y,z)signal(s4)}
}}
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 操作系统 期中 作业 答案