operating system question

profilexiaoxiao
HW3.docx

What is the effect of allowing two entries in a page table to point to the

same page frame in memory? Explain how this effect could be used to

decrease the amount of time needed to copy a large amount of memory

from one place to another. What effect would updating some byte on the

one page have on the other page?

Answer:

By allowing two entries in a page table to point to the same page frame

in memory, users can share code and data. If the code is reentrant, much

memory space can be saved through the shared use of large programs

such as text editors, compilers, and database systems. “Copying” large

amounts of memory could be effected by having different page tables

point to the same memory location.

However, sharing of nonreentrant code or data means that any user

having access to the code can modify it and these modifications would

be reflected in the other user’s “copy.”

Compare the 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

Answer:

The contiguous memory allocation scheme suffers from external fragmentation

as address spaces are allocated contiguously and holes

develop as old processes die 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 noncontiguous finegrained segments. Pure

segmentation also suffers fromexternal 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 frominternal 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.

Consider the following page reference string:

7, 2, 3, 1, 2, 5, 3, 4, 6, 7, 7, 1, 0, 5, 4, 6, 2, 3, 0 , 1.

Assuming demand paging with three frames, how many page faults

would occur for the following replacement algorithms?

• LRU replacement

• FIFO replacement

• Optimal replacement

Answer:

• 18

• 17

• 13