第七次作业
问题一:Explain the difference between internal and external fragmentation.
答:
内部碎片就是已经被分配出去(能明确指出属于哪个进程)却不能被利用的内存空间;
外部碎片指的是还没有被分配出去(不属于任何进程),但由于太小了无法分配给申请内存空间的新进程的内存空闲区域。
问题二:Given five memory partitions of 100 KB, 500 KB, 200 KB, 300 KB, and 600 KB (in order), how would each of the first-fit, best-fit, and worst-fit algorithms place processes of 212 KB, 417 KB, 112 KB, and 426 KB (in order)? Which algorithm makes the most efficient use of memory?
答:
first-fit:
212KB->500KB 空闲分区288KB
417KB->600KB 空闲分区183KB
112KB->288KB 288KB空闲分区变为176KB
426KB等待
best-fit:
212KB->300KB 空闲分区88KB
417KB->500KB 空闲分区83KB
112KB->200KB 空闲分区88KB
426KB->600KB 空闲分区174KB
worst-fit:
212KB->600KB 空闲分区388KB
417KB->500KB 空闲分区83KB
112KB->388KB 388空闲分区变为276KB
426KB等待
综上,best-fit对内存利用最高效,因为只有best-fit使得所有进程得以运行
问题三:Consider a paging system with the page table stored in memory.
a. If a memory reference takes 200 nanoseconds, how long does a paged memory reference take?
b. If we add TLBs, and 75 percent of all page-table reference are found in the TLBs, what is the effective memory reference time?(Assume that finding a page-table entry in the TLBs takes zero time, if the entry is there)
答:
a:
每一次的数据/指令存取需要两次内存存取,一次是存取页表,一次是存取数据,所以一次分页内存引用需要时间为: 200 n s × 2 = 400 n s 200ns\times 2=400ns 200ns×2=400ns
b:
如果引入TLBs,有效内存引用时间为: 200 n s × 2 × 25 % + 200 n s × 75 % = 250 n s 200ns\times 2 \times 25\%+200ns\times 75 \%=250ns 200ns×2×25%+200ns×75%=250ns
问题四:Consider the following segment table:
Segment | Base | Length |
---|---|---|
0 | 219 | 600 |
1 | 2300 | 14 |
2 | 90 | 100 |
3 | 1327 | 580 |
4 | 1952 | 96 |
What are the physical addresses for the following logical addresses?
a. 0,430
b. 1,10
c. 2,500
d. 3,400
e. 4,112
**a:**219+430=649
b:2300+10=2310
c:500>100越界错误
d:1327+400=1727
**e:**112>96越界错误