《操作系统概念》第六版作业解答1-6章.ppt

上传人:za****8 文档编号:3175024 上传时间:2019-12-06 格式:PPT 页数:35 大小:264.96KB
返回 下载 相关 举报
《操作系统概念》第六版作业解答1-6章.ppt_第1页
第1页 / 共35页
《操作系统概念》第六版作业解答1-6章.ppt_第2页
第2页 / 共35页
《操作系统概念》第六版作业解答1-6章.ppt_第3页
第3页 / 共35页
点击查看更多>>
资源描述
Chapter1,1.1Whatarethethreemainpurposesofanoperatingsystem?环境提供者,为计算机用户提供一个环境,使得能够在计算机硬件上方便、高效的执行程序资源分配者,为解决问题按需分配计算机的资源,资源分配需尽可能公平、高效控制程序监控用户程序的执行,防止出错和对计算机的不正当使用管理I/O设备的运行和控制,1-cont.,1.3Whatisthemainadvantageofmultiprogramming?高效地使用CPU,通过重叠来自不同用户对CPU和I/O设备的需求增加CPU的利用,设法让CPU执行有意义的指令,1-cont.,1.5Inamultiprogrammingandtime-sharingenvironment,severaluserssharethesystemsimultaneously.Thissituationcanresultinvarioussecurityproblems.a.Whataretwosuchproblems?b.Canweensurethesamedegreeofsecurityinatime-sharedmachineaswehaveinadedicatedmachine?Explainyouranswer.用户之间互相偷数据、代码对系统资源使用的记账信息,1-cont.,1.6Definetheessentialpropertiesofthefollowingtypesofoperatingsystems:a.Batch相似需求的Job分批、成组的在计算机上执行,Job由操作员或自动Job程序装置装载;可以通过采用buffering,off-lineoperation,spooling,multiprogramming等技术使CPU和I/O不停忙来提高性能批处理适合于需要极少用户交互的Job。b.Interactive由许多短交易组成,下一次交易的结果可能不可预知需要响应时间短,1-cont.,1.6Definetheessentialpropertiesofthefollowingtypesofoperatingsystems:c.Timesharing使用CPU调度和多道程序提供对系统的经济交互式使用,CPU快速地在用户之间切换一般从终端读取控制,输出立即打印到屏幕d.Realtime在专门系统中使用,从传感器读取信息,必须在规定时间内作出响应以确保正确的执行,1-cont.,1.6Definetheessentialpropertiesofthefollowingtypesofoperatingsystems:e.Network在通用OS上添加联网、通信功能远程过程调用文件共享f.Distributed具有联网、通信功能提供远程过程调用提供多处理机的统一调度调度统一的存储管理分布式文件系统,1-cont.,1.9Describethedifferencesbetweensymmetricandasymmetricmultiprocessing.Whatarethreeadvantagesandonedisadvantageofmultiprocessorsystems?Symmetricmultiprocessing中所有处理器同等对待,I/O可以在任意CPU上处理。Asymmetricmultiprocessing具有一个主CPU和多个从CPU,主CPU将任务分派到从CPU,I/O通常只能由主CPU处理。多处理机系统的优点比多个计算机系统可能更省钱(同样CPU个数)执行程序更快可靠性更高缺点:软硬件更复杂,Chapter2,2.2Howdoesthedistinctionbetweenmonitormodeandusermodefunctionasarudimentaryformofprotection(security)system?通过建立一组只能在monitormode才能执行的特权指令集,OS能够确保总是能控制整个系统。,2-cont.,2.3Whatarethedifferencesbetweenatrapandaninterrupt?Whatistheuseofeachfunction?Aninterrupt是硬件产生的系统内的流的改变Atrap是软件产生的“中断”。interrupt可以被I/O用来产生完成的信号,从而避免CPU对设备的轮询Atrap可以用来调用OS的例程或者捕获算术错误,2-cont.,2.5Whichofthefollowinginstructionsshouldbeprivileged?a.Setvalueoftimer.b.Readtheclock.c.Clearmemory.d.Turnoffinterrupts.e.Switchfromusertomonitormode.a.Setvalueoftimer.c.Clearmemory.d.Turnoffinterrupts.e.Switchfromusertomonitormode.,2-cont.,2.8Protectingtheoperatingsystemiscrucialtoensuringthatthecomputersystemoperatescorrectly.Provisionofthisprotectionisthereasonbehinddual-modeoperation,memoryprotection,andthetimer.Toallowmaximumflexibility,however,wewouldalsoliketoplaceminimalconstraintsontheuser.Thefollowingisalistofoperationsthatarenormallyprotected.Whatistheminimalsetofinstructionsthatmustbeprotected?a.Changetousermode.b.Changetomonitormode.c.Readfrommonitormemory.d.Writeintomonitormemory.e.Fetchaninstructionfrommonitormemory.f.Turnontimerinterrupt.g.Turnofftimerinterrupt.b.Changetomonitormode.c.Readfrommonitormemory.d.Writeintomonitormemory.g.Turnofftimerinterrupt.,Chapter3,3.1Whatarethefivemajoractivitiesofanoperatingsysteminregardtoprocessmanagement?用户和系统进程地创建和删除进程的挂起和恢复提供进程同步的机制提供进程通信的机制提供死锁处理的机制,3-cont.,3.2Whatarethethreemajoractivitiesofanoperatingsysteminregardtomemorymanagement?跟踪内存使用情况(哪一部分被使用、谁使用)当内存空间可用的时候,确定将哪些进程调入内存(job调度)按需要分配和回收内存,3-cont.,3.3Whatarethethreemajoractivitiesofanoperatingsysteminregardtosecondary-storagemanagement?剩余空间的管理存储分配磁盘调度,3-cont.,3.4Whatarethefivemajoractivitiesofanoperatingsysteminregardtofilemanagement?文件创建和删除目录创建和删除目录和文件操作原语的支持文件到二级存储的映射将文件备份到非易失存储设备,3-cont.,3.5Whatisthepurposeofthecommandinterpreter?Whyisitusuallyseparatefromthekernel?读取命令(从用户或者命令文件)并执行(转化成系统调用)可能会经常改变,3-cont.,3.7Whatisthepurposeofsystemcalls?让用户级进程可以请求操作系统所提供的服务,3-cont.,3.10Whatisthepurposeofsystemprograms?为程序开发和运行提供了方便的环境给用户提供基本的公共功能函数,为用户在不用自己写代码的情况下解决公用问题试着安装虚拟机VMWARE,然后在这台虚拟机上安装一个操作系统阅读Linux源码,给出某一个systemcall的源码并分析,分析init/main.c给出流程图,Chapter4,4.2Describethedifferencesamongshort-term,medium-term,andlong-termscheduling.Short-term,CPU调度Long-term,job调度Medium-term,分时系统中的中间调度级,4-cont.,4.4Describetheactionsakerneltakestocontextswitchbetweenprocesses.保存正在运行的进程的状态、恢复欲调度到CPU进程的状态,4-cont.,4.5Whatarethebenefitsanddetrimentsofeachofthefollowing?Considerboththesystemsandtheprogrammerslevels.a.Symmetricandasymmetriccommunicationb.Automaticandexplicitbufferingc.Sendbycopyandsendbyreferenced.Fixed-sizedandvariable-sizedmessages,4-cont.,4.6ThecorrectproducerconsumeralgorithminSection4.4allowsonlyn-1bufferstobefullatanyonetime.Modifythealgorithmtoallowallbufferstobeutilizedfully.,4-cont.,4.7Considertheinterprocess-communicationschemewheremailboxesareused.a.SupposeaprocessPwantstowaitfortwomessages,onefrommailboxAandonefrommailboxB.Whatsequenceofsendandreceiveshoulditexecute?b.WhatsequenceofsendandreceiveshouldPexecuteifPwantstowaitforonemessageeitherfrommailboxAorfrommailboxB(orfromboth)?c.Areceiveoperationmakesaprocesswaituntilthemailboxisnonempty.Eitherdeviseaschemethatallowsaprocesstowaituntilamailboxisempty,orexplainwhysuchaschemecannotexist.areceive(A,m1)receive(B,m2)send(c,m3)receive(B,m1)receive(A,m2)send(c,m3)breceive(A,m1)receive(B,m2)send(c,m3)receive(B,m1)receive(A,m2)send(c,m3)receive(A,m1)send(c,m3)receive(B,m2)receive(B,m1)send(c,m3)receive(A,m2),4-cont.,阅读分析Linux终止进程的源码编程,实现一个简单网络聊天程序,用到socket和fork()(接受和发送在fork出的进程中),Chapter5,5.1Providetwoprogrammingexamplesofmultithreadinggivingimprovedperformanceoverasingle-threadedsolution.可以并发的多任务Web浏览器,数据可并行处理5.2Providetwoprogrammingexamplesofmultithreadingthatwouldnotimproveperformanceoverasingle-threadedsolution.不可以并发的单任务用多个线程读一个文件后续的结果必须依赖于前面的,5cont.,5.3Whataretwodifferencesbetweenuser-levelthreadsandkernel-levelthreads?Underwhatcircumstancesisonetypebetterthantheother?内核可知与不可知调度者不同与进程的关系运行效率、内核复杂度、用户可控程度5.6Whatresourcesareusedwhenathreadiscreated?Howdotheydifferfromthoseusedwhenaprocessiscreated?,5cont.,5.6Whatresourcesareusedwhenathreadiscreated?Howdotheydifferfromthoseusedwhenaprocessiscreated?TCB,寄存器组,栈,调度信息PCB,所有与进程执行和调度相关的资源与信息,内存,打开的文件,环境变量,5-cont.,5.9WriteamultithreadedPthreadorJavaprogramthatoutputsprimenumbers.Thisprogramshouldworkasfollows:Theuserwillruntheprogramandwillenteranumberonthecommandline.Theprogramwillthencreateaseparatethreadthatoutputsalltheprimenumberslessthanorequaltothenumberthattheuserentered.编程,实现一个简单网络聊天程序,用到socket和pthread(接受和发送在pthread创建的线程中),Chapter6,6.1ACPUschedulingalgorithmdeterminesanorderfortheexecutionofitsscheduledprocesses.Givennprocessestobescheduledononeprocessor,howmanypossibledifferentschedulesarethere?Giveaformulaintermsofn.N个进程的排列问题Pnn=n!6.2Definethedifferencebetweenpreemptiveandnonpreemptivescheduling.Statewhystrictnonpreemptiveschedulingisunlikelytobeusedinacomputercenter.对CPU控制权的主动还是被动放弃不可能采用纯非剥夺机制:考虑到多道程序、分时共享,公平和轻重缓急,6-cont.,6.3Considerthefollowingsetofprocesses,withthelengthoftheCPU-bursttimegiveninmilliseconds:TheprocessesareassumedtohavearrivedintheorderP1,P2,P3,P4,P5,allattime0.a.DrawfourGanttchartsillustratingtheexecutionoftheseprocessesusingFCFS,SJF,anonpreemptivepriority(asmallerprioritynumberimpliesahigherpriority),andRR(quantum=1)scheduling.b.Whatistheturnaroundtimeofeachprocessforeachoftheschedulingalgorithmsinparta?c.Whatisthewaitingtimeofeachprocessforeachoftheschedulingalgorithmsinparta?d.Whichoftheschedulesinpartaresultsintheminimalaveragewaitingtime(overallprocesses)?,6-cont.,6.3a.b.c.d.SJF,6-cont.,6.4Supposethatthefollowingprocessesarriveforexecutionatthetimesindicated.Eachprocesswillrunthelistedamountoftime.Inansweringthequestions,usenonpreemptiveschedulingandbasealldecisionsontheinformationyouhaveatthetimethedecisionmustbemade.a.WhatistheaverageturnaroundtimefortheseprocesseswiththeFCFSschedulingalgorithm?(8-0)+(12-0.4)+(13-1.0)/3=10.53b.WhatistheaverageturnaroundtimefortheseprocesseswiththeSJFschedulingalgorithm?(8-0)+(13-0.4)+(9-1.0)/3=9.53c.TheSJFalgorithmissupposedtoimproveperformance,butnoticethatwechosetorunprocessP1attime0becausewedidnotknowthattwoshorterprocesseswouldarrivesoon.ComputewhattheaverageturnaroundtimewillbeiftheCPUisleftidleforthefirst1unitandthenSJFschedulingisused.RememberthatprocessesP1andP2arewaitingduringthisidletime,sotheirwaitingtimemayincrease.Thisalgorithmcouldbeknownasfuture-knowledgescheduling.(14-0)+(6-0.4)+(2-1.0)/3=6.87,6-cont.,6.7Considerthefollowingpreemptivepriority-schedulingalgorithmbasedondynamicallychangingpriorities.Largerprioritynumbersimplyhigherpriority.WhenaprocessiswaitingfortheCPU(inthereadyqueuebutnotrunning),itsprioritychangesatarateA;whenitisrunning,itsprioritychangesatarateB.Allprocessesaregivenapriorityof0whentheyenterthereadyqueue.TheparametersAandBcanbesettogivemanydifferentschedulingalgorithms.a.WhatisthealgorithmthatresultsfromBA0?b.WhatisthealgorithmthatresultsfromAB0?FCFSLIFO,6-cont.,6.8ManyCPUschedulingalgorithmsareparameterized.Forexample,theRRalgorithmrequiresaparametertoindicatethetimeslice.Multilevelfeedbackqueuesrequireparameterstodefinethenumberofqueues,theschedulingalgorithmsforeachqueue,thecriteriausedtomoveprocessesbetweenqueues,andsoon.Thesealgorithmsarethusreallysetsofalgorithms(forexample,thesetofRRalgorithmsforalltimeslices,andsoon).Onesetofalgorithmsmayincludeanother(forexample,theFCFSalgorithmistheRRalgorithmwithaninfinitetimequantum).What(ifany)relationholdsbetweenthefollowingpairsofsetsofalgorithms?a.PriorityandSJF(最短job优先级最高)b.MultilevelfeedbackqueuesandFCFS(MLFQ的最低级是FCFS)c.PriorityandFCFS(FCFS给存在时间最长的优先级最高)d.RRandSJF(none),6-cont.,6.9Supposethataschedulingalgorithm(atthelevelofshort-termCPUscheduling)favorsthoseprocessesthathaveusedtheleastprocessortimeintherecentpast.WhywillthisalgorithmfavorI/O-boundprogramsandyetnotpermanentlystarveCPU-boundprograms?阅读分析Linuxsched.c,
展开阅读全文
相关资源
相关搜索

当前位置:首页 > 图纸专区 > 课件教案


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!