File - Mr Rizal Arbain

advertisement
TUTORIAL
MEMORY
MANAGEMENT
(Best-Fit & First-Fit)
QUESTION 1
Assume that the main memory has the following 5 fixed
partitions with the following sizes: 100KB, 500KB,
200KB, 300KB and 600KB (in order)
a)
How would each of the First-fit and Best-fit
algorithms place processes of 212KB, 417KB, 112KB
and 426KB (in order)?
b)
Compute the total memory size that is not used for
each algorithm.
c)
Which algorithm makes the efficient use of the
memory?
ANSWER 1
a)
Partition Size
First-Fit
Fragmentation
500K
P1(212K)
500-212=288K
200K
P3(112K)
200-212=88K
600K
P2(417K)
600-417=183K
Partition Size
Best-Fit
Fragmentation
500K
P2(417K)
500-417=83K
200K
P3(112K)
200-112=88K
300K
P1(212K)
300-112=88K
600K
P4(426K)
600-426=174K
100K
300K
100K
ANSWER 1
b)
Total Fragmentation First-fit:
Total Fixed Partitions – Total Process First-fit Size
1700-741 =959
Total Fragmentation Best-fit:
Total Fixed Partitions – Total Process Best-fit Size
1700-1167 =533
ANSWER 1
c)
Memeory Utilization Ratio:
i. First-fit = 741 / 1700 = 43.5%
ii. Best-fit = 1167 / 1700 = 68.6%
*Best-fit has the most efficient use of the memory
QUESTION 2
In a variable partition memory management, assume memory
is allocated as specified in a diagram below:
1
2
10K
10K
3
4
20K
30K
Hole
5
6
10K
5K
7
8
9
12K
11
12
30K
20K
10K
15K
20K
20K
Used
Suppose the request for memory is as follows:
18K, 12K, 7K
Redraw the diagram to show how memory would look after all
requests has been allocated by using the following memory
allocation strategies:
a)First-fit
b)Best- fit
ANSWER 2
a) FIRST-FIT:
18K will be allocated at the first hole of size 30K
12K will be allocated at the first hole of size 12K
7K will be allocated at the first hole of size 10K
ANSWER 2
b)BEST-FIT:
18K will be allocated at the first hole of size 20K
12K will be allocated at the first hole of size 15K
7K will be allocated at the first hole of size 20K
Download