Sei sulla pagina 1di 12

Chapter 7 Homework Solutions

7.3, 7.4, 7.5, 7.6, 7.7, 7.12

Problem 7.3
Consider a dynamic partitioning scheme. Show that, on average, the memory has half as many holes as segments Let s and h denote the average number of segments and holes, respectively. The probability that a given segment is followed by a hole in memory (and not by another segment) is 0.5, because deletions and creations are equally probable in equilibrium. So, with s segments in memory, the average number of holes must be s/2. It is intuitively reasonable that the number of holes must be less than the number of segments because neighboring segments can be combined into a single hole on deletion.

Problem 7.4
To implement the various placement algorithms for dynamic partitioning, a list of free blocks of memory must be kept. For each of best-fit, first-fit, next-fit, what is the average length of the search? By problem 7.3, we know that the average number of holes is s/2, where s is the number of resident segments. Regardless of fit strategy, in equilibrium, the average search length is s/4.

Problem 7.5
Worst-fit placement uses the largest free block for placement. Discuss the pros and cons versus the other three placement algorithms. A criticism of the best fit algorithm is that the space remaining after allocating a block of the required size is so small that in general it is of no real use. The worst fit algorithm maximizes the chance that the free space left after a placement will be large enough to satisfy another request, thus minimizing the frequency of compaction. The disadvantage of this approach is that the largest blocks are allocated first Therefore a request for a large area is more likely to fail.

Problem 7.6
A dynamic partitioning scheme is being used and the following is the memory configuration at a given point in time. The shaded areas are allocated blocks, the white areas free blocks. The next three memory requests are for 40M, 20M and 10M.

20M 20M

20M 10M

40M

60M

60M

40M

20M

30M 40M 40M

a. Indicate the starting address for each of the three blocks using first-fit The 40 M block fits into the second hole, with a starting address of 80M. The 20M block fits into the first hole, with a starting address of 20M. The 10M block is placed at location 120M.

20M 20M

20M 10M

40M

60M

60M

40M

20M

30M 40M 40M

Problem 7.6
A dynamic partitioning scheme is being used and the following is the memory configuration at a given point in time. The shaded areas are allocated blocks, the white areas free blocks. The next three memory requests are for 40M, 20M and 10M.

20M 20M

20M 10M

40M

60M

60M

40M

20M

30M 40M 40M

b. Indicate the starting address for each of the three blocks using best-fit The 40 M block fits into the hole with starting address of 230M. The 20M block fits into the hole with starting address of 20M. The 10M block is placed at location 160M.

20M 20M

20M 10M

40M

60M

60M

40M

20M

30M 40M 40M

Problem 7.6
A dynamic partitioning scheme is being used and the following is the memory configuration at a given point in time. The shaded areas are allocated blocks, the white areas free blocks. The next three memory requests are for 40M, 20M and 10M.

20M 20M

20M 10M

40M

60M

60M

40M

20M

30M 40M 40M

c. Indicate the starting address for each of the three blocks using next-fit The 40 M block fits into the hole with starting address of 80M. The 20M block fits into the hole with starting address of 120M. The 10M block is placed at location 160M.

20M 20M

20M 10M

40M

60M

60M

40M

20M

30M 40M 40M

Problem 7.6
A dynamic partitioning scheme is being used and the following is the memory configuration at a given point in time. The shaded areas are allocated blocks, the white areas free blocks. The next three memory requests are for 40M, 20M and 10M.

20M 20M

20M 10M

40M

60M

60M

40M

20M

30M 40M 40M

d. Indicate the starting address for each of the three blocks using worst-fit The 40 M block fits into the hole with starting address of 80M. The 20M block fits into the hole with starting address of 230M. The 10M block is placed at location 360M.

20M 20M

20M 10M

40M

60M

60M

40M

20M

30M 40M 40M

Problem 7.7
a. A 1-Mbyte block of memory is allocated using the buddy system. Show the result of the given sequence in a figure similar to problem 7.6.

Problem 7.7
b. Show the binary tree representation following Return B.

Problem 12
Consider a simple paging system with the following parameters: 232 bytes of physical memory; page size of 210 bytes; 216 pages of logical addresses. a. How many bits are in a logical address? The number of bytes in the logical address space is (216 pages) (210 bytes/page) = 226 bytes. Therefore, 26 bits are required for the logical address. b. How many bytes are there in a frame? A frame is the same size as a page, 210 bytes. c. How many bits in the physical address specify the frame? The number of frames in main memory is (232 bytes of main memory)/(210 bytes/frame) = 222 frames. So 22 bits is needed to specify the frame.

Problem 7.12
Consider a simple paging system with the following parameters: 232 bytes of physical memory; page size of 210 bytes; 216 pages of logical addresses. d. How many entries are there in the page table? There is one entry for each page in the logical address space. Therefore there are 216 entries. e. How many bits are there in each page table entry? Assume each page table entry contains a valid/invalid bit. In addition to the valid/invalid bit, 22 bits are needed to specify the frame location in main memory, for a total of 23 bits.

Potrebbero piacerti anche