心得分享

Card image cap

許同學 報告/作業 分享經驗 5/19 OS作業

5/19 OS作業
名稱 5/19 OS作業
日期 5/17
課程名稱 作業系統
指導教師 劉艾華

1. Give the methods that are used in page table and TLB for searching the accessing pages. Compare the differences on the searches between these two hardwares and give reasons why TLB will help the search of the pages.

Ans:
Page table: Address generated by CPU is divided into:
(1) Page number(p) – used as an index into a page table which contains base address of each page in physical memory.
(2) Page offset(d) – combined with base address to define the physical memory address that is sent to the memory unit.

TLB: When presented with an item, it is compared with all keys simultaneously. If the page number is found in the TLB, its frame number is immediately available and used to access memory. If the page number is not in the TLB, a memory reference to the page table must be made. TLB should be active.

The differences on the searches between page table and TLB are that page table uses a specify index in the page table then find the address directly while TLB uses the method that compares with all keys(page numbers) simultaneously.

When page numbers can’t find in TLB then go back to page table. Because the page table is in the main memory, in order to avoid wasting time, so we use TLB to help the search of pages.

2. What is the purpose of paging the page table?

Ans:
In certain situations the page tables could become large enough that by paging the page tables, one could simplify the memory allocation problem (by ensuring that everything is allocated as fixed-size pages as opposed to variable-sized chunks) and also enable the swapping of portions of page table that are not currently used.

3. Consider a 32bit address space with 2K bytes page size, assuming that each entry consists of 4 bytes, how much memory are required for the page table for each process? Explain your reason.

Ans:
The size of each page is 2K (2^11 bytes). Total number of pages is 2^32/2^11=2^21 pages. Since each entry is 4 bytes long, we require 4x2^21 = 2^23 bytes = 8 MB to hold this table.

4. Compare the main memory organization schemes of contiguous-memory allocation, pure segmentation, and pure paging with respect to the following issues:
a. external fragmentation
b. internal fragmentation
c. ability to share code across processes

Ans:
Contiguous memory allocation scheme suffers from external fragmentation as address spaces are allocated contiguously and holes develop as old processes dies and new processes are initiated. It also does not allow processes to share code, since a process’s virtual memory segment is not broken into non-contiguous fine grained segments.

Pure segmentation also suffers from external fragmentation as a segment of a process is laid out contiguously in physical memory and fragmentation would occur as segments of dead processes are replaced by segments of new processes.
Segmentation, however, enables processes to share code;for instance, two different processes could share a code segment but have distinct data segments.

Pure paging does not suffer from external fragmentation, but instead suffers from internal fragmentation. Processes are allocated in page granularity and if a page is not completely utilized, it results in internal fragmentation and a corresponding wastage of space.Paging also enables processes to share code at the granularity of pages.

更新日期:2016/5/17 下午 05:06:34