操作系统练习题(全).pdf





《操作系统练习题(全).pdf》由会员分享,可在线阅读,更多相关《操作系统练习题(全).pdf(5页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、答案仅供参考1.How does the distinction between kernel mode and user mode function as a rudimentaryform of protection(security)system?(内核态和用户态作为保护系统有什么区别)答:内核态和用户态的区别有以下方式,某些指令只有当CPU处于内核态时才可以执行。同样地,某些硬件设备只有当程序在内核态下执行才能够被访问。只有在CPU处于内核态时,才能够控制中断。因此,CPU处于用户态时的能力有限,从而强制保护关键的资源。2.Which of the following instruct
2、ions should be privileged?(下列哪个指令是受保护的)a.Set value of timer.设置计时器的值b.Read the clock.读时钟c.Clear memory.清除内存d.Issue a trap instruction.解决一个陷阱指令e.Turn off interrupls.关中断f.Modify entries in device-status table.修改设备状态表中的条目g.Switch from user to kernel mode.从用户态转到内核态h.Access I/O de vice.访问 I/O 设备答:受保护的:a、c
3、、e、f、h,剩下的可以在用户态执行。3.Why should an application programmer prefer programming according to an API ratherthan invoking actual system c a ll?(为什么应用程序设计者更喜欢根据API编程)答:使用API编程的一个好处是程序的可移植性:程序员用API设计的程序可以在任何支持相同API的系统上编译和运行,并且,对于一个应用程序来说,实际系统调用比API更加复杂和困难,总之,API调用和与其相关的内核中的系统调用有着很强的相关性。4.What resources are
4、 used when a thread is created?How do they differ from those usedwhen a process is created?(当线程创建时需要哪些资源,当进程创建时又需要哪些)答:因为一个线程小于一个进程,因此,创建线程所用的资源一般比创建进程所用的资源少。创建一个进程需要分配进程控制块(PCB),一个相当大的数据结构,PCB包括了一个内存映射,打开文件的目录和外界变量。分配和管理内存映射通常是最费时的活动。创建一个用户或内核线程包括分配一个小的数据结构来控制寄存器的设置,堆栈和优先级。5.Suppose that the follow
5、ing processes arrive for execution at the times indicated.Eachprocess will run the listed amount of time.In answering the questions,use preemptivescheduling and base all decisions on the information you have at the time the decision mustbe made?(考点:调度算法)ProcessArrival TimeBurst TimePl08Pl14P329P435W
6、hat is the average turnaround time for these processes with the preemptive SJFscheduling algorithm(抢占、最短作业优先调度算法)?答:甘特图:0 1 5 10 17 26平均等待时间=(10-1)+0+(17-2)+(5-3)/4=6.5msPlP2P4PlP36.Consider the following snapshot(快 照)of a system:(考察银行家算法)a.What OS the content of the matrix need?(求need矩阵的内容Need=Max
7、AHocation)答:allocationmaxavailableNeedPl(0,0,1,2)(0,0,1,2)(2,1,0,0)(0,0,0,0)P2(2,0,0,0)(2,7,5,0)(0,7,5,0)P3(0,0,3,4)(6,6,5,6)(6,6,2,2)P4(2,3,5,4)(4,3,5,6)(2,0,0,2)P5(033,2)(0,6,5,2)(0.320)Need(0,0,0。)(0,750)(6,6,2,2)(2,0,0,2)(0,3,2。)b.Is the system in a safe state?(系统是否处于安全状态)答:availableP l先执行,执行完后(
8、2,1,1,2)P4先执行,执行完后(4,4,6,6)P5先执行,执行完后(4,7,9,8)P2先执行,执行完后(6,7,9,8)P3最后执行,执行完后(6,7,12,因此,系统存在安全序列vPl,P4,P5,P2,P3,所以,系统安全7.The necessary conditions for arising deadlock in a system are发生死锁的必要条件是(互斥)、(循环等待)、(请求与保持)、(非剥夺分配)。8.The synchronization(同步)Problems:a.readers and writers problems(读者写者问题)一个缓冲区,读与读
9、不互斥,读与写互斥,写与写互斥,写与读互斥,读优先信号量 mutex=1 (readcount)信 号 量 wrt=l(写和读)信 号 量 readcount=0(记录读个数)读:wait(mutex);readcount+;if(readcount=1)wait(wrt);signal(mutex);/readingwait(mutex);readcount-;if(readcount=0)signal(wrt);signal(mutex);写:wait(wrt);/writingsignal(wrt);b.producers and consumers problems(生产者消费者问题)
10、There is one buffer only can accommodate k products,m producer and n consumer(有 一个缓冲区只能容纳k个产品,m个生产者和n个消费者)信 号 量mutex=l(表示缓冲区个数)信 号 量full=0(消费者,最开始使用资源为0)信 号 量empty=k(生产者,k)生产者:消费者:wait(empty);wait(full);wait(mutex);wait(mutex);放入产品 使用产品signal(mutex);signal(mutex);signal(full);signal(empty);c.busman
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 操作系统 练习题

限制150内