当前位置:文档之家› 西安电子科技大学操作系统期末试题及答案解析

西安电子科技大学操作系统期末试题及答案解析

西安电子科技大学考试时间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 andapplication programs.A.Control busB. data busC.Address busD. 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 in aprocess? .A. Address spaceB. RegisterC. Open filesD. Accounting information5.In the paged memory management system, the address is composedof page number and the offset within the page. In the address structure shown in the following figure, .31 10 9 0A. page size is 512, 2M 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 thefollowing statements about The Principle of Locality is correct?A. Program executes codes in orderB.Program assesses(访问)memory in a non-uniform mannerC.Program accesses a lot of variables continuouslyD.Program accesses a relatively small portion of the address space atany instant of time7.In UNIX i-node scheme, a directory entry contains only two fields: thefile name (14 bytes) and the number of the i-node for that file (2 bytes).These parameters(参数)limit the number of files per file system to.A. 64kB. 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. 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 present that the file’s owner may read, write, and execute the file, while all others may only read the file? .A. 755B. 744C. 644D. 61110.The method listed below doesn’t need CPU toparticipate in the transfer of data block.A.Interrupt-Driven I/OB. DMAC. Programmed I/OD. None of abovePart2: Fill Blanks (Total 20, each 2)1.Operating System is an extended machine and .2.Parallel Systems include Symmetric(对称)multiprocessingand .3.A semaphore(信号量)S is an integer variable that is accessed onlythrough two standard atomic operations: and .4.Address binding of instructions and data to memory addresses canhappen at three different stages, Compile time, Load time and .5.Four Conditions for Deadlock: , Hold and wait, Nopreemption 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 integrityand .Part3: Essay Questions (Total 20, each 4)1.What is system call? Use an example to illustrate(举例说明)the stepsof 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 management?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. Theproduct produce numbers from 1 to MAX and the consumer will read it. Please fill blanks in the code#include <stdio.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(&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_signal(&condp);⑥printf(“buffer=%d\n” , 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);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 :Answer the following questions using the banker’s 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 begranted(允许)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)Shorted 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 (2048bytes), and main memory consists of 4 page frames. Now consider a process which requires 8 pages of storage. At some point during its execution, the page table is as shown below:Answer 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 the main memory (physical) addresses for each of thefollowing 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计算机系统由硬件和软件(系统程序+应用程序)组成。

相关主题