- 1. a) 64 pages x 1024 words = 2^16 x 2^10 = 2^16
- There are 16 bits in the logical address.
- b) 32 frames x 1024 words = 2^5 x 2^10 = 2^15
- There are 15 bits in the physical address.
- 2. a) The issue with external fragmentation is that as memory is allocated contiguously, and processes are loaded and then removed, holes are created in the memory space, causing fragmentation. Pure segmentation has this issue as well, however pure paging avoids the fragmentation.
- b) While pure paging does not lead to external fragmentation, it does cause internal fragmentation when the allocated space is not completely used.
- c) Code sharing is not possible with contiguous memory allocation because processes are located in different memory spaces and therefore no sharing of memory.
- 3. a) page = 2375/1024 = 2
- offset = 2375 % 1024 = 327 2.327
- b) page = 19366/1024 = 18
- offset = 19366 % 1024 = 934 18.934
- c) page = 30000/1024 = 29
- offset = 30000 % 1024 = 304 29.304
- d) page = 256/1024 = 0
- offset = 256 % 1024 = 256 .256
- e) page = 16385/1024 = 16
- offset = 16385 % 1024 = 1 16.1
- 4. a) 4KB page size = 2^12
- (2^32 logical address) / (2^12 page size) = 2^20 entries
- b) 4KB page size = 2^12
- 32-12=20 bits left for the page number
- 2^(20/2) = 2^10 entries
- c) Level has 22-bit logical address
- 4KB page size = 2^12
- (2^22 logical address) / (2^12 page size) = 2^10 entries per page
- 5. a) 100 nanoseconds to access the page table plus 100 nanoseconds to access the word from memory.
- It will take 200 ns for the paged memory reference.
- b) 85% of the time it will take 100 ns, and the 200 ns for 15% of the time.
- So… (.85 * 100) + (.15 *200) = 115 ns effective memory reference time
- 6. Both of these issues are caused by a particular program referencing its own code without knowing the segment or page number for the address. This problem is solved by associating four registers with the processes. All references must be indirect by means of a register mapped to the segment or page number. Changing these registers allows the same code to execute for separate processes without a same page or segment.
- 7. a) Yes, the thread changes from the Running state to the Blocked state when a page fault occurs.
- b) If the page is already in main memory, the TLB is updated for the new page entry. If the page is not in main memory, a page fault is generated. The process is then changed to the Blocked state.
- c) No, because no I/O operation is needed because this indicates that the page needed is already in main memory.
- 8. Every time memory is accessed, the page table must be checked as to whether or not the page exists and whether or not the program has read/write privileges for accessing that page. It is required that these checks be performed within the hardware.