problem set 4

4
Problem Set #4 Brian Kidd 4/12/2015 1. (+12) Describe at least 3 general approaches in memory management than can help solve the external fragmentation problem. Worst fit finds the largest chunk that is big enough. Best fit finds the smallest chunk that is big enough. First fit finds the first chunk that is big enough, and next fit finds the next sequential (with respect to the last block allocated) chunk that is big enough. 2. (+12) A memory manager for a variable-sized region strategy has a free list of blocks of size 600, 400, 1000, 2200, 1600, and 1050 bytes. What block will be selected to honor a request for: a. The block of 2200 bytes will be selected. b. The block of 1000 bytes will be selected. c. The block of 2200 bytes will be selected. d. The block of 2200 bytes will be selected. e. The block of 2200 bytes will be selected. f. The block of 2200 bytes will be selected. 3. (+20) Suppose two processes need to be mapped into main memory using pages. Process P1 consists of 7 pages, and process P2 consists of 4 pages. Assume main memory consists of 16 frames, a logical page is the same size as a physical frame, and that 4 entries in a page table fills up a frame of memory. Assume also that within the process' allocated address spaces, there are two pages of shared code 'X' and 'Y' common to both address spaces.

Upload: john-ham

Post on 11-Jan-2016

220 views

Category:

Documents


5 download

DESCRIPTION

Some difficult programming problems

TRANSCRIPT

Problem Set #4Brian Kidd

4/12/2015

1. (+12) Describe at least 3 general approaches in memory managementthan can help solve the external fragmentation problem.

Worst fit finds the largest chunk that is big enough. Best fit finds the smallest chunk that is big enough. First fit finds the first chunk that is big enough, and next fit finds the next sequential (with respect to the last block allocated) chunk that is big enough.

2. (+12) A memory manager for a variable-sized region strategy has afree list of blocks of size 600, 400, 1000, 2200, 1600, and 1050bytes. What block will be selected to honor a request for:a.

The block of 2200 bytes will be selected.b.

The block of 1000 bytes will be selected.c.

The block of 2200 bytes will be selected.d.

The block of 2200 bytes will be selected.e.

The block of 2200 bytes will be selected.f.

The block of 2200 bytes will be selected.

3. (+20) Suppose two processes need to be mapped into main memoryusing pages. Process P1 consists of 7 pages, and process P2consists of 4 pages. Assume main memory consists of 16 frames, alogical page is the same size as a physical frame, and that 4entries in a page table fills up a frame of memory. Assume alsothat within the process' allocated address spaces, there are twopages of shared code 'X' and 'Y' common to both address spaces.

Design a memory management system that can store these twoprocesses and their page tables in RAM. Identify which frames youhave chosen to assign to which process pages and page tables inmain memory/RAM. Also show possible page tables for P1 and P2(e.g. page table for P1 should have 7 entries).

P1 P2 RAM PAGE TABLES

X XFRAME#

PAGE# P1 P1

Y Y 1 XLOGICAL PAGE

PHYSICAL FRAME

LOGICAL PAGE

PHYSICAL FRAME

1 6 2 Y X 1 X 12 7 3 1 Y 2 Y 23 4 2 1 3 6 84 5 3 2 4 7 95 6 4 3 5

7 5 4 68 6 5 79 7

10 11 12 13 14 15 16

4. (+12) Suppose on-demand paging is employed in addition to TLBcaching. The time for a TLB hit is T = 1 ns, a memory read M = 10ns, and a disk read D = 10 ms. Let p_TLB = the probability of aTLB hit, and p = the probability of a page fault given a TLB miss.What is a general formula for the average memory access timeexpressed as a function of T, M, D, p, and p_TLB? Once parametervalues are substituted, and assuming assuming p = .001 and p_TLB =90%, what is the calculated average memory access time?

5. (+12) The Least Recently Used (LRU) page replacement policy does notsuffer from Belady's Anomaly. Explain intuitively why this is thecase. Construct an example page fault sequence to illustrate yourpoint.

Beladay’s Anomoly points out that by changing the size of the queue, the order in which things are replaced changes.

LRU 1 2 3 4 5 6 1 5 4 2

1 1 1 4 4 4 1 1 1 22 2 2 5 5 5 5 5 5

3 3 3 6 6 6 4 4PAGE FAULT

1 1 1 1 5 5 1 1 1 12 2 2 2 6 6 6 6 2

3 3 3 3 3 5 5 54 4 4 4 4 4 4

PAGE FAULT

6. (+20) Given a frame allocation of 3, and the following sequence ofpage references 3 2 4 3 4 2 2 3 4 5 6 7 7 6 5 4 5 6 7 2 1, andassuming main memory is initially unloaded, show the page faultingbehavior using the following page replacement policies. How many page faults are generated by each page replacement algorithm? Whichgenerates the fewest page faults?a. FIFO – Minimum number of page faultsb. OPTc. LRU

7. (+12) Assume the same sequence of page references as in problem #6,and assume memory is initially unloaded, but now assume that a dynamicpaging working-set algorithm is applied to the same sequence ofpage references, with a window size of 6. Draw the page faultingbehavior. Your solution chart should show the frame allocation atany given time to the process.