操作系统练习题(全).doc_第1页
操作系统练习题(全).doc_第2页
操作系统练习题(全).doc_第3页
操作系统练习题(全).doc_第4页
免费预览已结束,剩余1页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

答案仅供参考1How does the distinction between kernel mode and user mode function as a rudimentary form of protection (security) system? (内核态和用户态作为保护系统有什么区别)答:内核态和用户态的区别有以下方式,某些指令只有当CPU处于内核态时才可以执行。同样地,某些硬件设备只有当程序在内核态下执行才能够被访问。只有在CPU处于内核态时,才能够控制中断。因此,CPU处于用户态时的能力有限,从而强制保护关键的资源。2. Which of the following instructions should be privileged? (下列哪个指令是受保护的)a. Set value of timer.设置计时器的值b. Read the clock.读时钟c. Clear memory.清除内存d. Issue a trap instruction.解决一个陷阱指令e. Turn off interrupts.关中断f. Modify entries in device-status table.修改设备状态表中的条目g. Switch from user to kernel mode.从用户态转到内核态h. Access I/O device.访问I/O设备答:受保护的:a、c、e、f、h,剩下的可以在用户态执行。3.Why should an application programmer prefer programming according to an API rather than invoking actual system call? (为什么应用程序设计者更喜欢根据API编程)答:使用API编程的一个好处是程序的可移植性:程序员用API设计的程序可以在任何支持相同API的系统上编译和运行,并且,对于一个应用程序来说,实际系统调用比API更加复杂和困难,总之,API调用和与其相关的内核中的系统调用有着很强的相关性。4. What resources are used when a thread is created? How do they differ from those used when a process is created? (当线程创建时需要哪些资源,当进程创建时又需要哪些)答:因为一个线程小于一个进程,因此,创建线程所用的资源一般比创建进程所用的资源少。创建一个进程需要分配进程控制块(PCB),一个相当大的数据结构,PCB包括了一个内存映射,打开文件的目录和外界变量。分配和管理内存映射通常是最费时的活动。创建一个用户或内核线程包括分配一个小的数据结构来控制寄存器的设置,堆栈和优先级。5. Suppose that the following processes arrive for execution at the times indicated. Each process will run the listed amount of time. In answering the questions, use preemptive scheduling and base all decisions on the information you have at the time the decision must be made?(考点:调度算法)Process Arrival Time Burst TimeP1 0 8P2 1 4P3 2 9P4 3 5What is the average turnaround time for these processes with the preemptive SJF scheduling algorithm(抢占、最短作业优先调度算法)?答:甘特图:P1P2P4P1P3 0 1 5 10 17 26平均等待时间=(10-1)+ 0 +(17-2)+(5-3)/4=6.5ms6. Consider the following snapshot(快照)of a system:(考察银行家算法)allocationmaxavailableNeedP1(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(0,3,3,2)(0,6,5,2)(0,3,2,0)a. What OS the content of the matrix need?(求need矩阵的内容Need=Max-Allocation)答:Need(0,0,0,0)(0,7,5,0)(6,6,2,2)(2,0,0,2)(0,3,2,0)b. Is the system in a safe state?(系统是否处于安全状态)答:availableP1先执行,执行完后(2,1,1,2)P4先执行,执行完后(4,4,6,6)P5先执行,执行完后(4,7,9,8)P2先执行,执行完后(6,7,9,8)P3最后执行,执行完后(6,7,12,12)因此,系统存在安全序列,所以,系统安全7. The necessary conditions for arising deadlock in a system are发生死锁的必要条件是(互斥)、(循环等待)、(请求与保持)、(非剥夺分配)。8. The synchronization(同步)Problems:a. readers and writers problems(读者写者问题)一个缓冲区,读与读不互斥,读与写互斥,写与写互斥,写与读互斥,读优先信号量 mutex=1(readcount)信号量 wrt=1(写和读)信号量 readcount=0(记录读个数)读: 写:wait(mutex); wait(wrt);readcount+; /writingif(readcount= =1) signal(wrt);wait(wrt);signal(mutex);/readingwait(mutex);readcount-;if(readcount= =0) signal(wrt);signal(mutex);b. producers and consumers problems(生产者消费者问题)There is one buffer only can accommodate k products , m producer and n consumer (有一个缓冲区只能容纳k个产品,m个生产者和n个消费者)信号量 mutex=1(表示缓冲区个数)信号量 full=0(消费者,最开始使用资源为0)信号量 empty=k(生产者,k)生产者: 消费者:wait(empty); wait(full);wait(mutex); wait(mutex);/放入产品 /使用产品signal(mutex); signal(mutex);signal(full); signal(empty);c. busman and drivers(司机和售票员问题)司机:启动车辆,正常行车,到站停车售票员:关车门,售票,开车门信号量 S1=0(是否能启动车,司机)信号量 S2=0(时候能开门,售票员) 售票员:司机: /关车门wait(S1); signal(S1);/正常行车 /售票/到站停车 wait(S2);Signal(S2); /开门,上下车d. drinking problem between younger and elder Buddhist monk.(小和尚和老和尚喝水问题)m个小和尚,n个老和尚,一个水缸,容纳10桶水,一口井,一个桶取水小和尚:提水供老和尚饮用,3桶水 = 一缸水(一次一个桶)get():从井中取水,倒入缸中(小和尚)use():从缸中取水饮用(老和尚)信号量 mutex1=1(水井使用互斥)信号量 mutex2=1(水缸使用互斥)信号量 empty=10(水缸中还能装水数,小和尚)信号量 full=0(水缸中有多少水,老和尚)信号量 count=3(水桶使用互斥)get(): use():wait(empty); wait(full);wait(count); wait(count);wait(mutex1); wait(mutex2);/提水 /取水signal(mutex1); signal(mutex2);wait(mutex2); signal(count);/水倒入水缸 signal(empty);signal(mutex2);signal(count);signal(full);9. Consider a logical address space of eight pages of 1024 words each, mapped onto a physical memory of 32 frames,thus, there are (13)bits in the logical address, and there are (15) bits in the physical address。10.Considering the following string: 1、2、3、4、2、1、5、6、2、1、2、3、7、6、3、2、1、2、3、6;assuming that four frames are allocated to the current logical address. Using the following methods to compute the number of page fault.(1)LRU(最近最少使用算法)(2)FIFO(先进先出算法)(3)Optimal(最佳页面替换算法)解:(1)采用LRU页面置换算法,分配给进程的页面为4时,对应的页面置换情况如表所示。由表可知,缺页中断次数为10页面走向12342156212376321236物理块11111111166物理块2222222222物理块333553333物理块44466771缺页缺缺缺缺缺缺缺缺缺缺(2)采用FIFO页面置换算法,分配给进程的页面为4时,对应的页面置换情况如表所示,由表可知,缺页中断次数为14页面走向12342156212376321236物理块111115555333311物理块22222666677773物理块3333322226666物理块444441111222缺页缺缺缺缺缺缺缺缺缺缺缺缺缺缺(3)采用Optimal页面置换算法,分配给进程的页面为4时,对应的页面置换情况如表所示,由表可知,缺页中断次数为8页面走向12342156212376321236物理块111111171物理块22222222物理块3333333物理块445666缺页缺缺缺缺缺缺缺缺11. In demand paging management system, the Address change can be interrupt because of some reasons such as 缺页 ; 地址越界 ; 访问权限错误 . 12 In the paging management system, there are three ordinary Page Replacement algorithms, in A algorithm, the Replace page that will not be used for longest period of time, then A algorithm is called_最佳 _ algorithm; In B algorithm, the Replace page that remain in memory for the longest time than others, then B algorithm is called_先进先出_ algorithm; 13.When the semaphore is greater than zero, the Physical meaning of Semaphore is 可用资源的数目 ;When the semaphore is less than zero, the absolute value of Semaphore is 等待进程的个数 . 14.The logical constraint relations between processes in system is called 进程同步 . 15.If a process has been in critical section, what should the others who want to enter the critical section do? 等待 .16.If the current value of semaphore is -4, then how many processes are waiting for the semaphore? 4 个 .17. When a processs resource requests will cause the system to enter 不安全状态 from 安全状态 , the system will refuse it.18.The way which begins address transfer as soon as the jobs in memory is ca

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论