17.2.09

Memory Management: Virtual Memory

Question 1:

Q: Explain the differences between a page and a segment.
A: Paged memory allocation is based on the concept of dividing each incoming job into pages of equal size. A page is a fixed-size section of a user’s job that corresponds in size to page frames in main memory. With segmented memory allocation, each job is divided into several segments of different sizes, one for each module that contains pieces that perform related functions. A segment is a variable-size section of a user’s job that contains a logical grouping of code.



Question 2:

Q: List the advantages and disadvantages for each of the memory management schemes presented.



1. The primary advantage of paged memory allocation is that it stores programs in noncontiguous locations, allowing main memory to be used more efficiently because an empty page frame can be used by any page of any job. This also means that there is no internal or external fragmentation. The disadvantage is that the Memory Manager now needs a mechanism to keep track of each job’s pages because they can be located anywhere in memory.



2. Demand Paging introduced the concept of loading only part of the program into memory for processing. It takes advantage of the fact that programs are written sequentially so that while one section is processed all of the other sections (modules) are idle. Most importantly, demand paging made virtual memory possible. The disadvantage with demand paging is a phenomenon called thrashing. This is occurs when an excessive amount of page swapping between main memory and secondary memory takes place, causing the operation to become inefficient.



3. Segmented Memory Allocation is based on the concept on the common practices by programmers in how they structure their programs- logical grouping of code. Segmented memory allocation reduces page faults that resulted from having a segment’s loop split over two or more pages. The disadvantage is the return of external fragmentation; therefore recompaction of available memory is necessary.



4. Segmented/Demand Paged Memory Allocation is a combination of segmentation and demand paging. The advantage is that it offers the logical benefits of segmentation, as well as the physical benefits of paging. The major disadvantages of this scheme are the overhead required for the extra tables and the time required to reference the segment table and the page table.



Question 3:

Q: What purpose does the modified bit serve in a demand paging system?
A: The modified bit determines in the page has been modified. It is used to same time when pages are removed from main memory and returned to secondary storage. If the contents of the page haven’t been modified, then the page doesn’t have to be rewritten to secondary storage.



Question 4:

4A. What is the cause of thrashing?
Thrashing occurs when there is an excessive amount of page swapping between main memory and secondary storage, causing the operation to become inefficient. Typically it is when a page is removed from memory, and then called back quickly.

4B. How does the operating system detect thrashing?
The operating system can detect thrashing by evaluating the level of CPU utilization as compared to the level of multiprogramming.

4C. Once thrashing is detected, what can the OS do to eliminate it?
Thrashing can be eliminated by reducing the level of multiprogramming.



Question 5:

What purpose does the referenced bit serve in a demand paging system?
The reference bit indicates any recent activity, it is used to determine which pages show the most processing activity, and which are relatively inactive. This information is used by several page-swapping policy schemes to determine which pages should remain in memory and which should be swapped out when the system needs to make room for other pages being requested.

No comments:

Post a Comment