心得分享

Card image cap

沈同學 報告/作業 分享經驗 5/20 5/13 os作業

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

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: The number id used as an index into a page table . The page table contains the base address of each page in physical memory . This base address id combined with the page offset to define the physical memory address that is sent to the memory unit.
TLB: If the page number is not in the TLB , a memory reference to the page table must be made .Depending on the CPU , this may be done automatically in hardware or via an interrupt to the operating system .When the frame number is obtained , we can use it to access memory.
Reason: 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) indicate size of the page table .In this scheme every data/instruction access requires two memory accesses .One for the page table and one of the data/instruction .This problem can be solved by the use of a special fast-lookup hardware cache called translation look-aside buffers.
2. What is the purpose of paging the page table?
Page table can be implemented as a set of registers with very high-speed logic.
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.
2K<2^11;
so it may consist of 2^32/2^11=2^21;

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
External fragmentation Contiguous allocation with fixed size partions does not suffer from external fragmentation, but contiguous allocation with variable sized partitions does. Pure paging does not suffer from external fragmentation, since partitions and pages are fixed in size. Segmentation does suffer from external fragmentation.
b. internal fragmentation
Internal fragmentation Segmentation and variable-sized partitions do not suffer from internal fragmentation, since by definition, a segment/partition is exactly as large as it needs to be. However, contiguous allocation with fixed-size partitions and paging both may suffer from internal fragmentation when partitions and pages are not completely filled.
c. ability to share code across processes
Ability to share code across processes Contiguous allocation provides no support for code sharing. In segmentation, as long as the segments of a process do not mix text and data, we can easily share code between processes. We simply adjust the segment tables of each process to point to the same segment of code in memory. For security reasons, however, it would probably be desirable to have some method of preventing processes from modifying code, since doing so would allow one process to change the code executed by another. In pure paging, code can be shared across processes simply by sharing page frames. To do this, adjust the page tables of the two processes so that their different logical pages map to the same physical page frame. However, we do need to make certain that no page frame contains any data, which should not be shared. We could accomplish this by, for example, padding the last page of the text segment of the process with no-op machine language instructions.

更新日期:2016/5/21 下午 11:54:05