1. Consider a swapping system in which memory consists of the holes as shown in
ID: 3722808 • Letter: 1
Question
1. Consider a swapping system in which memory consists of the holes as shown in Fig. 1. Note that A to I represent processes in memory, and Hi to Hs are eight holes. Process Pl, P2, and P3 are generated sequentially. Which hole is taken for the process P1, P2, and P3, respectively, when the first fit algorithm is used? Put your answer in Table 2. (i) P requests 13 KB (ii) P: requests 10KB. (iii) P, requests 9KB. (iv) P4 requests 5KB. Now repeat the question for best fit, worst fit, and next fit algorithm. 4KB 5KB 16KB 8KB 9KB 15KB 13KB Fig. 1 Table 2: Ha He H7 Hs First fit Best fit Worst fit Next fitExplanation / Answer
Four memory allocation strategies are
First Fit- Allocate the first free partition which can accommodate the process.
Best Fit- Allocate the smallest free partition that can accommodate the process.
Worst Fit- Allocate the largest free partition that can accommodate the process
Next Fit- It is a modified version of first fit. Allocation begins as first fit to find a free partition. When called next time, it starts from where it left off, not from the beginning.
Here processes P1, P2, P3 and P4 are allotted memory holes based on 4 strategies.
H1
H2
H3
H4
H5
H6
H7
H8
First Fit
P2
P4
P1
P3
Best Fit
P2
P4
P3
P1
Worst Fit
P4
P1
P2
P3
Next Fit
P4
P1
P2
P3
First Fit:
P1 request 13KB. In case of first fit start searching for a free partition from the beginning. The first free hole which can accommodate P1 is H4 (16KB). Hence P1 is allocated to H4.
P2 requests 10 KB. Start searching for a free partition from the beginning. The first free hole which can accommodate P2 is H2 (10KB). Hence P2 is allocated to H2.
P3 requests 9 KB. Start searching for a free partition from the beginning. The first free hole which can accommodate P3 is H6 (9 KB). Hence P3 is allocated to H6.
P4 requests 5 KB. Start searching for a free partition from the beginning. The first free hole which can accommodate P4 is H3 (5KB). Hence P4 is allocated to H3.
Best Fit:
P1 request 13KB. In case of best fit start searching for a free partition from the beginning. Then find a free hole that is smallest enough to accommodate this process. The smallest free hole which can accommodate P1 is H8 (13KB). Hence P1 is allocated to H8.
P2 requests 10 KB. Start searching for a smallest free partition from the beginning. The smallest free hole which can accommodate P2 is H2 (10KB). Hence P2 is allocated to H2.
P3 requests 9 KB. Start searching for a smallest free partition from the beginning. The smallest free hole which can accommodate P3 is H6 (9 KB). Hence P3 is allocated to H6.
P4 requests 5 KB. Start searching for a smallest free partition from the beginning. The smallest free hole which can accommodate P4 is H3 (5KB). Hence P4 is allocated to H3.
Worst Fit:
P1 request 13KB. In case of best fit start searching for a free partition from the beginning. Then find a free hole that is largest enough to accommodate this process. The largest free hole which can accommodate P1 is H4 (16KB). Hence P1 is allocated to H4.
P2 requests 10 KB. Start searching for largest free partition from the beginning. The largest free hole which can accommodate P2 is H7 (15KB). Hence P2 is allocated to H7.
P3 requests 9 KB. Start searching for a largest free partition from the beginning. The largest free hole which can accommodate P3 is H8 (13 KB). Hence P3 is allocated to H8.
P4 requests 5 KB. Start searching for a largest free partition from the beginning. The largest free hole which can accommodate P4 is H2 (10KB). Hence P4 is allocated to H2.
Next Fit:
P1 request 13KB. In case of next fit start searching for a free partition from the beginning. Then find a free hole that is enough to accommodate this process. The first free hole which can accommodate P1 is H4 (16KB). Hence P1 is allocated to H4.
P2 requests 10 KB. In case of next fit, when called next time, it starts from where it left off, not from the beginning. Start searching for a free partition from the hole H4. The first free hole which can accommodate P2 is H7 (15KB). Hence P2 is allocated to H7.
P3 requests 9 KB. In case of next fit, when called next time, it starts from where it left off, not from the beginning. Start searching for a free partition from the hole H7. The first free hole which can accommodate P3 is H8 (13 KB). Hence P3 is allocated to H8.
P4 requests 5 KB. In case of next fit, when called next time, it starts from where it left off, not from the beginning. Start searching for a free partition from the hole H8. The first free hole which can accommodate P4 is H2 (10KB). Hence P4 is allocated to H2.
H1
H2
H3
H4
H5
H6
H7
H8
First Fit
P2
P4
P1
P3
Best Fit
P2
P4
P3
P1
Worst Fit
P4
P1
P2
P3
Next Fit
P4
P1
P2
P3
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.