《操作系统》试题举例-综合性问题

一、进程调度

《操作系统》试题举例-综合性问题_第1张图片

注意:

  1. 抢占式SJF中,如果两个作业剩余量一样:给的答案中的意思,下一个被选择调入的进程是下标小的那个,即先到的那个。也就是说这里没有像RR中那样维持着一个循环队列。
  2. 注意优先级调度的注释,比如这题中,说明了a smaller priority number implies a higher priority,意思就是“小数字代表着高优先级”!!!
  3. RR中有个循环队列,知道吧?最好写甘特图的时候画出来。

 

《操作系统》试题举例-综合性问题_第2张图片

第三问哈,看见没,idle 空闲的,unit 单元,也就是说一个非抢占的SJF甘特图前两个时间段不能进行进程处理。那平均等待时间岂不是直接+2就ok?? 嗯。

 

二、进程同步问题

There is only one single-log bridge(独木桥) over the river connecting the west and the east.If there is some one on the bridge, people from other direction must wait until there is no person on the bridge.While if several people go the same direction,they can pass through at the same time. Write a code sketch for two kinds of people,people from west to east and people from east to west,which follows the given rules and guarantees that two kinds of people are never on the bridge at the same time using semaphores.

《操作系统》试题举例-综合性问题_第3张图片

注意:

  1. 这儿是信号量,不是信号灯。它是可以设置大小的,比如 semaphore empty=300,mutex=1,mutexStu=1,mutexTea=1;
  2. 这里是允许定义数字等数据类型的,比如int student=0;

《操作系统》试题举例-综合性问题_第4张图片

三、银行家算法

《操作系统》试题举例-综合性问题_第5张图片

(1)R1:6;R2:7;R3:12;R4:12

(2)Need

R1 R2 R3 R4

P0    0  0  0  0

P1    0  7  5  0

P2    6  6  2  2

P3    2  0  0  2

P4    0  3  2  0

(3)安全;存在安全序列(P0 P3 P4 P1 P2 )使得每个进程都能顺利完成。

(4)不能。分配之后的系统状态是不安全的。(判断方法:首先判断请求是否小于Need矩阵,否,则不可以。然后判断请求是否小于可获得的资源,否,则不可以。假装分配了资源,看看是否能找到安全的序列,否,则不可以。)

 

《操作系统》试题举例-综合性问题_第6张图片

(1)这里简写:

P1 7 4 3

P2 1 2 2

P3 6 0 0

P4 0 1 1

P5 4 3 3

(2)安全.P4 P2 P1 P3 P5

(3)不能。分配之后的系统状态是不安全的。(判断方法:首先判断请求是否小于Need矩阵,否,则不可以;然后判断请求是否小于可获得的资源,否,则不可以;假装分配了资源,看看是否能找到安全的序列,否,则不可以。)

四、资源分配图

《操作系统》试题举例-综合性问题_第7张图片

五、页置换算法

《操作系统》试题举例-综合性问题_第8张图片

15;

15;

10.

注意:

(1)绘制格子时候格子应与引用串错位一些;

(2)OPT/MIN方法:如果最后有多用于两个页后面都没有用到了,可以置换排序在前的那个(假设遍历是根据表中顺序依次遍历的就是了)。

 

《操作系统》试题举例-综合性问题_第9张图片

12;

14;

9

 

六、内存管理之地址转换、多分页

《操作系统》试题举例-综合性问题_第10张图片

(1)4*128+88=600;

(2)5*128+10=640;

(3)0*128+12=12.

 

(5 points)Consider a memory management system with paging. There are three jobs, J1, J2 and J3, are in the memory now. J2 has 4 pages, which are stored in the 3rd, 4th, 6th and 8th block of the main memory respectively. Suppose the page size is 1024 bytes, and the main memory is 10k bytes, please answer the following two questions:

(1)Draw the page table of J2;

(2)If J2 meets the instruction “MOV [2100], [3100]” (decimal) at its logical address 500 (decimal), give the physical addresses of the two operands above.

页表:略

逻辑转物理地址:3*1024+500=3572 bytes.

 

Given a computer system with a 48-bit virtual address,2KB pages,and 4bytes per page entry,suppose that the maximum physical memory size is 16GB,and the system is byte-addressable.Let paging be implemented for the system.Please answer the following questions:

  1. What is the number of bits for physical addresses? What is the maximum number of frames for the system? Suppose that multi-level paging is adopted. How many levels do we have?
  2. Let the memory access time and TLB access time be 100ns and 10ns,respectively. Suppose that the TLB hit ratio is 98%. What is the effective memory access time ?

(1)34;2^23;(只知道顶级页表最多只能存在一个页面里面)假设是四级页表:10 9 9 9 11

(2)0.98*(10+100)+0.02*(10+100+100)

 

你可能感兴趣的:(竞赛,比赛,考试)