一、进程调度
注意:
第三问哈,看见没,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.
注意:
三、银行家算法
(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矩阵,否,则不可以。然后判断请求是否小于可获得的资源,否,则不可以。假装分配了资源,看看是否能找到安全的序列,否,则不可以。)
(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矩阵,否,则不可以;然后判断请求是否小于可获得的资源,否,则不可以;假装分配了资源,看看是否能找到安全的序列,否,则不可以。)
四、资源分配图
五、页置换算法
15;
15;
10.
注意:
(1)绘制格子时候格子应与引用串错位一些;
(2)OPT/MIN方法:如果最后有多用于两个页后面都没有用到了,可以置换排序在前的那个(假设遍历是根据表中顺序依次遍历的就是了)。
12;
14;
9
六、内存管理之地址转换、多分页
(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)34;2^23;(只知道顶级页表最多只能存在一个页面里面)假设是四级页表:10 9 9 9 11
(2)0.98*(10+100)+0.02*(10+100+100)