admin管理员组

文章数量:1558050

操作系统第八次作业

问题一:**A certain computer provides its users with a virtual-memory space of 2 32 2^{32} 232 **bytes. The computer has 2 18 2^{18} 218 bytes of physical memory. The virtual memory is implemented by paging, and the page size is 4,096 bytes. A user process generates the virtual address 11123456. Explain how the system establishes the corresponding physical location. Distinguish between software and hardware operations.

  • 11123456转化为二进制为:
    0001 0001 0001 0010 0011 0100 0101 0110

​ 地址为32位

  • 已知页大小为 4096 = 2 12 4096=2^{12} 4096=212

​ 故32位地址后12位为页内偏移地址,前二十位为页号,且页表大小为 2 20 2^{20} 220

  • 物理内存为 2 18 2^{18} 218= 64 × 2 12 64\times2^{12} 64×212bytes

故共有64个帧

  • 11123456前二十位0001 0001 0001 0010 0011在页表中寻找对应的物理块,

后12位0100 0101 0110为物理帧内的偏移地址

实际的物理地址为物理块号首地址+偏移量(0100 0101 0110)

问题二: Consider a demand-paging system with the following time-measured utilizations:
CPU utilization20%
Paging disk97.7%
Other I/O devices5%

For each of the following, say whether it will (or is likely to) improve CPU utilization. Explain your answers.

a. Install a faster CPU.

b. Install a bigger paging disk.

c. Increase the degree of multiprogramming.

d. Decrease the degree of multiprogramming.

e. Install more main memory.

f. Install a faster hard dist or multiple controllers with multiple hard disks.

g. Add prepaging to the page-fetch algorithms.

h. Increase the page size.

a、b、c不可以

d、e、f、g、h可以

d减少进程个数之后可以为余下的进程分配更多的页帧,进而减小缺页率、降低分页磁盘利用率的同时提高CPU利用率

e则是通过扩大内存帧的数量来为进程分配更多页帧

f则是通过提高页面置换的速度来使进程的等待时间更短,更快地进入就绪状态

g通过预先调页使得CPU不需要等待就可以获得数据,从而提高CPU利用率

h通过增加页的大小可以减少页面置换、降低缺页率进而提高CPU利用率

问题三: A page-replacement algorithm should minimize the number of page faults. We can achieve this minimization by distributing heavily used pages evenly over all of memory, rather than having them compete for a small number of page frames. We can associate with each page frame a counter of the number of pages associated with that frame. Then, to replace a page, we can search for the page frame with the smallest counter.

a. Define a page-replacement algorithm using this basic idea. Specifically address these problems:

1. What the initial value of the counters is

2. When counters are increased

3. When counters are decreased

4. How the page to be replaced is selected

b. How many page faults occur for your algorithm for the following reference string, with four page frames?

1,2,3,4,5,3,4,1,6,7,8,7,8,9,7,8,9,5,4,5,4,2.

c. What is the minimum number of page faults for an optimal page-replacement strategy for the reference string in part b with four page frames?

答:

  • a
  • 1、计数器初值为0
  • 2、当一个新的页和此页帧相关联
  • 3、与该页帧相关联的一个页不再被需要时
  • 4、选择计数器最少的页帧,当计数器相同时使用FIFO
  • b:4+10=14
  • c:4+7=11

本文标签: 作业第八次操作系统