# MEMORY MANAGEMENT (Best-Fit & First-Fit)

## Presentation on theme: "MEMORY MANAGEMENT (Best-Fit & First-Fit)"— Presentation transcript:

MEMORY MANAGEMENT (Best-Fit & First-Fit)
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) How would each of the First-fit and Best-fit algorithms place processes of 212KB, 417KB, 112KB and 426KB (in order)? Compute the total memory size that is not used for each algorithm. Which algorithm makes the efficient use of the memory?

Answer 1 a) Partition Size First-Fit Fragmentation 100K 500K P1(212K)
Best-Fit Fragmentation 100K 500K P2(417K) =83K 200K P3(112K) =88K 300K P1(212K) =88K 600K P4(426K) =174K

Answer 1 b) Total Fragmentation First-fit: Total Fixed Partitions – Total Process First-fit Size =959 Total Fragmentation Best-fit: Total Fixed Partitions – Total Process Best-fit Size =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: 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 Hole Used 10K 20K 30K 5K 15K 1 2 3 12 4 5 6 7 8 9 12K 11

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