天天看點

cs439 - problem set 6輔導

  1. What are overlays? How and why were they created?

overlay is also named swapping.

Overlaying means replacement of sections of stored instructions or data".

This is achieved by treating main memory as a cache of hard disk.

Overlays are created since the size of main memory is limited. To allow

memory-consuming program to proceed, we have to swap out the data or

instructions that are not used any more and swap in those to be used.

  1. What causes a page fault? What is the end result for the running process?

Cache miss causes a page fault.

The running process will proceed after the required data is loaded from

virtual space to physical space.

  1. Sam P. Hacker is a Head Guru in a software company known for operating systems with very poor quality. Hacker suggested a trick to reduce the pressure on the swap space.

    Instead of swapping out pages that belong to code texts into the swap area, the operating system could just take away the memory frames. If the code page is needed later, it could be paged directly from its binary file. Hacker’s argument is that the operating system will save time by not storing the code page into the swap space, and will save space in the swap area. The code text exists on disk anyway, and could be fetched from there. Would

    you approve of this design? Why or why not?

    這道題的意思是說,磁盤上反正有二進制的代碼文本檔案,是以幹脆不把記憶體中的代碼檔案交換到磁盤,不夠的時候,直接删除。然後需要的時候再從磁盤拿。

不同意 這種方法,因為忽視了一個問題。

如果在程式在記憶體執行的過程中,磁盤上放的那個二進制的可執行檔案發生變化了,怎麼辦?比如,我删除了它,或者 我更改了它,那重新加載的代碼就是錯誤的。

除非,在記憶體執行某個可執行檔案的時候,直接鎖定這個二進制檔案,不允許重新覆寫這個檔案。

  1. Name two advantages of using small pages and two advantages of using large pages in a paging mechanism. Why are page sizes growing in paging memory systems?

Small Pages: Less internal fragmentation. 但是,小page size需要更多數量的page,而這也就需要更多的page table,更多的記憶體。

Large pages can be used for program instructions. Small pages can be used for threads. Most operating system support only one page size.

選大頁面還是小頁面需要經過權衡:

Size of the page table - to keep it relatively small, we need bigger pages).

Memory utilization - better with smaller pages because of less internal fragmentation.

I/O time - latency / throughput characteristics call for bigger pages.

選大頁面的原因:

記憶體越來越便宜,使用率不用太在乎。但是I/O是比較慢的,是以頁面的size越來越大。而且現在越來越使用多線程,每個程式都不小。

Memory is cheap so we care less about utilization.

Disk access advances in slower pace compared with memory/CPU so I/O factor is most important.

  1. In a 32-bit machine we subdivide the virtual address into 4 segments as follows:
cs439 - problem set 6輔導

We use a 3-level page table, such that the first 10-bits are for the first level and so on.

1.

What is the page size in such a system?

The page size depends on the bits used for representing page offset.

The former three sections of address identifies a particular page.

Assume it is a byte-addressible system, that is

2^8 = 256 bytes

2.

What is the size of a page table for a process that has 256K of memory starting at address 0?

256 KB / 256 bytes = 1024 pages

繼續閱讀