心得分享

Card image cap

林同學 報告/作業 分享經驗 5/13 OS作業

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

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: For large page table , more feasible if keep it in main memory and use a page-table base register (PTBR) points to the page table and page-table length register (PRLR) indicates size of the page table .
In this scheme every data / instruction access requires two memory accesses .
One for the page table and one for the data / instruction .
This problem can be solved by the use of a special fast-lookup hardware cache called translation look-aside buffers (TLBs) .
When presented with an item , it is compared with all keys simultaneously in the TLB . 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 is updated for next reference .
2.
What is the purpose of paging the page table?
Ans:In certain situations the page tables could becomelarge 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 total memory is 232bytes, and the each page size is 2K=211 bytes, so a page table may consist of up to 2 million entries (232/211)=221 bytes.
Because each entry consist of 4 bytes, requires (4x221=223bytes)=8 megabytes page table for each process.
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/19 上午 09:30:55