西安电子科技大学操作系统期末试题及答案解析_第1页
西安电子科技大学操作系统期末试题及答案解析_第2页
西安电子科技大学操作系统期末试题及答案解析_第3页
西安电子科技大学操作系统期末试题及答案解析_第4页
西安电子科技大学操作系统期末试题及答案解析_第5页
已阅读5页,还剩12页未读 继续免费阅读

下载本文档

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

文档简介

1、 西 安 电 子 科 技 大 学考试时间 120 分钟 试题题号一二三四五六七八九十总分分数1.考试形式:闭卷 2.考试日期: 年 月 日 3.本试卷共 四 大题,满分100分班级 学号 姓名 任课老师 Part 1: Select one answer (A through D) for each question ( Total 20, each 2 )1. A computer system consists of , system programs and application programs.A. Control bus B. data busC. Address bus D.

2、hardware2. Thread(线程)can be implemented in .A. Kernel SpaceB. User SpaceC. Kernel Space or User SpaceD. None of the above3. In OS, short term schedule(调度)means .A. Job schedulingB. Process schedulingC. Thread schedulingD. CPU scheduling4. Which one of the following item is not shared by all threads

3、in a process? .A. Address spaceB. RegisterC. Open files D. Accounting information5. In the paged memory management system, the address is composed of page number and the offset within the page. In the address structure shown in the following figure, . 31 10 9 0page numberoffsetA. page size is 512, 2

4、M pages at mostB. page size is 1k, 4M pages at mostC. page size is 2k, 8M pages at mostD. page size is 4k, 16M pages at most6. Virtual memory is based on The Principle of Locality. Which of the following statements about The Principle of Locality is correct? A. Program executes codes in orderB. Prog

5、ram assesses(访问)memory in a non-uniform mannerC. Program accesses a lot of variables continuouslyD. Program accesses a relatively small portion of the address space at any instant of time7. In UNIX i-node scheme, a directory entry contains only two fields: the file name (14 bytes) and the number of

6、the i-node for that file (2 bytes). These parameters(参数)limit the number of files per file system to .A. 64k B. 32kC. 16kD. 4k8. The time required to read or write a disk block is determined(决定)by three factors. Which one dominates(主导,占优势)the other two times? .A. Seek timeB. Rotational delay timeC.

7、Data transfer timeD. None of above9. The chmod command(命令)is used to change the permission(许可)of file in Linux. To use it, you specify the desired permission setting and the file or files that you wish to modify. The permission settings are usually a series of bits. Which of the following bits prese

8、nt that the files owner may read, write, and execute the file, while all others may only read the file? .A. 755 B. 744 C. 644D. 61110. The method listed below doesnt need CPU to participate in the transfer of data block.A. Interrupt-Driven I/OB. DMAC. Programmed I/OD. None of abovePart2: Fill Blanks

9、 (Total 20, each 2)1. Operating System is an extended machine and .2. Parallel Systems include Symmetric(对称)multiprocessing and .3. A semaphore(信号量)S is an integer variable that is accessed only through two standard atomic operations: and .4. Address binding of instructions and data to memory addres

10、ses can happen at three different stages, Compile time, Load time and .5. Four Conditions for Deadlock: , Hold and wait, No preemption and .6. Sector 0 of the disk is called the .7. In Linux, the file metadata(元数据)is stored in .8. The security goals include data confidentiality(机密性),data integrity a

11、nd .Part3: Essay Questions (Total 20, each 4)1. What is system call? Use an example to illustrate(举例说明)the steps of system call.2. Please describe the diagram(图)of Process State.3. What is Monitor? Can you use Monitor to implement a data structure?4. What is TLB? What role does it play in memory man

12、agement?5. The difference of programming I/O and interrupt-driven I/O.Part4: Integrate Questions (Total 40, each 10)1. The code below is an example program of producer-consumer. The product produce numbers from 1 to MAX and the consumer will read it. Please fill blanks in the code#include <stdio.

13、h>#include <pthread.h>#define MAX 1000000000 /* how many numbers to produce */pthread_mutex_t the_mutex;pthread_cond_t condc, condp;int buffer = 0; /* buffer used between producer and consumer*/void *producer(void *ptr) /*produce data*/int i;for (i=1; i<=MaX; i+) pthread_mutex_lock(&

14、the_mutex);while ( )pthread_cond_wait (&condp, &the_mutex);buffer = i; pthread_exit (0);void *consumer (void *ptr) /*consume data*/int i, res;for (i = 1; i<=MAX; i+) pthread_mutex_lock (&the_mutex);while ( )pthread_cond_wait ( , &the_mutex);res = buffer;buffer = 0;pthread_cond_sig

15、nal(&condp); printf(“buffer=%dn” , res); pthread_exit (0);int main (int argc, char *argv)pthread_t pro,con;pthread_mutex_init (&the_mutex, 0);pthread_cond_init (&condc, 0);pthread_cond_init (&condp, 0);pthread_create (&con, 0, consumer, 0);pthread_create (&pro, 0, producer, 0

16、);pthread_join (pro, 0);pthread_join (con, 0);pthread_cond_destroy (&condc);pthread_cond_destroy (&condp);pthread_mutex_destroy (&the_mutex);2. Consider the following snapshot of a system : ResourcesProcessesAllocationA B C DMax NeedA B C DAvailableA B C DP0P1P2P3P40 0 1 21 0 0 01 3 5 40

17、 6 3 20 0 1 40 0 1 21 7 5 02 3 5 60 6 5 20 6 5 6 1 5 2 0Answer the following questions using the bankers algorithm:(1) What is the content of the matrix Need? (4 points)(2) Is the system in safe state? Why? (3 points)(3) If a request from process P1 arrives for (0,4,2,0), can the request be granted(

18、允许)immediately? (3 points)3. Disk requests come in to the disk driver for cylinders 10,22,20,2,40,6, and 38, in that order. In all cases, the arm is initially at cylinder 20. A seek takes 6 msec per cylinder moved. How much seek times is needed for(1) First Come First Served (FCFS).(3 points)(2) Sho

19、rted Seek Time First (SSTF).(3 points)(3) Elevator algorithm (SCAN, initially moving upward)(4 points)4. Consider a system where the virtual memory page size is 2K (2048 bytes), and main memory consists of 4 page frames. Now consider a process which requires 8 pages of storage. At some point during

20、its execution, the page table is as shown below:Virtual pageValidPhysical page0No1No2Yes13No4Yes35No6Yes07Yes2Answer the following questions:(1) List the virtual address ranges for each virtual page.(3 points)(2) List the virtual address ranges that will result in a page fault. (3 points)(3) Give th

21、e main memory (physical) addresses for each of the following virtual addresses (all numbers decimal): (i) 8500, (ii) 1400, (iii) 5000, (iv) 2100.(4 points)AnswersPart 1: Select one answer (A through D) for each question1.D计算机系统由硬件和软件(系统程序+应用程序)组成。2.C线程实现的两种方式用户空间和内核中 在用户空间中实现线程 内核对线程包一无所知,从内核角度考虑,就是

22、按正常的方式 管理,即单线程进程(存在运行时系统) 在内核中实现线程 在某个线程希望创建一个新线程或撤销一个已有线程时,它进行一个系统调用,这个系统调用通过对线程表的更新完成线程创建和撤销工作。 混合实现 在此模型中,每个内核级线程有一个可以轮流使用的用户级线程集合。3.D三级调度: long-term schedule(长期调度,又称作业调度):哪个程序被系统选中并创建进程运行它 medium-term schedule(中期调度,又称内存调度):决定是否将进程调入内存 short-term schedule(短期调度,又称CPU调度):哪个进程获得处理器资源(通常所说的调度)4.B一个进程

23、中所有线程共享的内容(进程的属性): 每个线程独有的内容: 5.B页面数(page number) = = = 4M由页内偏移(offset)得,页面大小(page size) = = = 1K6.D 答案:程序在一段时间内访问相对小的一段地址空间虚拟内存基于程序的局部性原理而设计的。程序的局部性原理是指程序在执行时呈现出局部规律,即在一段时间内,整个程序的执行仅限于程序中的某一部分。相应地,执行所访问的存储空间也局限于某个内存区域。(根据程序的局部性理论,Denning 提出了工作集理论)7.AUNIX的一个目录项包含了两个域,文件名(14个字节)和节点的编号(2个字节),这些参数决定了每个

24、文件系统的文件数目为64K( )8.ATime required to read or write a disk block determined by 3 factors: Seek time (the time to move the arm to the proper cylinder)(寻道时间) Rotational delay (the time for the proper sector to rotate under the head)(旋转延迟) Actual data transfer time (实际数据传输时间)For most disks, the seek time

25、 dominates the other two times.9.Bchmod 命令,改写文件的读写许可设置语法为:chmod abc file其中a,b,c各为一个数字,分别表示User, Group, Other的权限r = 4, w = 2, x = 1所以,a = 4+2+1 = 7b = 4c = 410. B I/O可以以三种不同方式实现: 程序控制I/O (Programmed I/O) 让CPU做全部的工作。CPU通过程序主动读取状态寄存器以了解接口情况,并完成相应的数据操作。 中断驱动I/O (interrupt-driven I/O) 当程序常规运行时,若外部有优先级更高的

26、事件出现,则通过中断请求通知CPU,CPU再读取状态寄存器确定事件的种类,执行不同的分支处理。 DMA (Direct Memory Access) 直接内存存取即数据传送的具体过程直接由硬件(DMA控制器)在内存和I/O之间完成,CPU只在开始时将控制权暂时交予DMA,直到数据传输结束。Part2: Fill Blanks1. a resource manager2. asymmetric multiprocessing (非对称多处理)3. PV4. execution time5. Mutual exclusion Circular wait6. MBR(Master Boot Reco

27、rd) 主引导记录7. i-node8. system availabilityPart3: Essay Questions1. 操作系统的主要功能是为应用程序的运行创建良好的环境,为了达到这个目的,内核提供一系列具备预定功能的多内核函数,通过一组称为系统调用(system call)的接口呈现给用户。系统调用把应用程序的请求传给内核,调用相应的的内核函数完成所需的处理,将处理结果返回给应用程序,如果没有系统调用和内核函数,用户将不能编写大型应用程序。2. 1)Running运行态 2)Ready 就绪态.,暂无CPU分配得它。3)Blocked 阻塞态,等待输入 3. 管程是一个由过程、变量

28、和数据结构等组成的一个集合,它们组成一个特殊的模块或软件包。进程可在任何需要的时候调用管程中的过程,但它们不能在管程之外声明的过程中直接访问管程内的数据结构。任一时刻管程中只能有一个活跃进程,这一特性使管程能有效地完成互斥。4. TLB即Translation Lookaside Buffer(转换检测缓冲区),是一个小型的硬件设备将虚拟地址直接映射到物理地址,不必再访问列表。它通常存在在MMU中,包含少量的表项,每个表项记录了一个页面的相关信息,包括虚拟页号、页面的修改位、保护码(读/写/执行权限)和该页所对应的物理页框。它是一个内存管理单元用于改进虚拟地址到物理地址转换速度的缓存。5. 程序控制I/O (Programmed I 让CPU做全部的工作。CPU通过程序主动读取状态寄存器以了解接口情况,并 完成相应的数据操作。 中断驱动I/O (interrupt-driven I/O) 在等待设备就绪的时候允许CPU做其他的事情。当程序常规运行时,若外部有优先级更高的事件出现,则通过中断请求通知CPU,CPU再读取状态寄存器确定事件的种类,执行不同的分支处理。Part4: Integrate Questions1. buffer != 0 pt

温馨提示

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

最新文档

评论

0/150

提交评论