118k views
0 votes
Given ten memory partitions of 85 MB, 45 MB, 57 MB, 49 MB, 82 MB, 65 MB, 17 MB, 53 MB, 74 MB, and 40 MB

(in order), how would the first-fit, best-fit, and worst-fit algorithms place processes of size 50 MB, 42 MB, and 70

MB (in order)? Rank the algorithms in terms of how efficiently they use memory

User Stackit
by
5.5k points

1 Answer

2 votes

Answer:

Rank of the algorithms in terms of how efficiently they use memory is:

  • Best-fit: this create the least amount of extra/waste memory. (3+3+4) = 10MB
  • First-fit: this create (35+3+12) = 50MB worth of memory extra/wastage
  • Worst-fit: this create (35+40+4) = 79MB worth of memory extra/wastage.

Step-by-step explanation:

First-fit algorithm will assigned the first available space that can fit the process to it without considering the amount of space to be wasted.

Best-fit algorithm will assigned the best available space that will fit the process to it while minimizing wastage of space.

Worst-fit algorithm will look for the largest space and assigned it to the process.

Given ten memory partitions of

85MB = M1

45MB = M2

57MB = M3

49MB = M4

82MB = M5

65MB = M6

17MB = M7

53MB = M8

74MB = M9

40MB = M10

Processes of size 50 MB, 42 MB, and 70MB

50MB = P1

42MB = P2

70MB = P3

Using First-fit

P1 will be assigned to M1 as it is the first available memory to contain P1. Then M1 = (85 - 50) = 35MB

P2 will be assigned to M2 as it is the first available memory to contain P2. Then M2 = (45 - 42) = 3MB

P3 will be assigned to M5 as it is the first available memory to contain P3. Then M5 = (82 - 70) = 12MB

Using Best-fit

P1 will be assigned to M8 as it is the best available memory to contain P1. Then M8 = (53 - 50) = 3MB

P2 will be assigned to M2 as it is the best available memory to contain P2. Then M2 = (45 - 42) = 3MB

P3 will be assigned to M9 as it is the best available memory to contain P3. Then M9 = (74 - 70) = 4MB

Using Worst-fit

P1 will be assigned to M1 as it is the largest available memory to contain P1. Then M1 = (85 - 50) = 35MB

P2 will be assigned to M5 as it is the largest available memory to contain P2. Then M5 = (82 - 42) = 40MB

P3 will be assigned to M9 as it is the largest available memory to contain P3. Then M9 = (74 - 70) = 4MB

Best-fit efficiently manage the memory partition, followed by first-fit and then worst-fit.

User Arunmoezhi
by
4.9k points