Assuming main memory is divided into partitions of sizes 900K, 400K, 600K, 300K (in order) and pointers are pointing at memory area 400K, indicate that processes have sizes 700K, 400K, 300K and how will 200K (in order) be allocated memory, if using:
- First Fit
- Next Fit
- Worst Fit
- Best Fit
Answer:
First Fit: (Browse from the beginning. See if there is enough free memory to allocate to Process, then grant it)
- 700K allocated to 900K . memory area
- 400K allocated to 400K . memory area
- 300K allocated to 600K . memory area
- 200K is allocated to 200k memory area (remaining memory area of 900K – 700K = 200K)
Next Fit: (Similar to First Fit but starting point is from the cursor)
- 700K have to wait because there is no free memory that meets the requirements
- 400K allocated to 400K . memory area
- 300K allocated to 600K . memory area
- 200K allocated to 300K memory area (remaining memory area of 600K – 300K = 300K)
Worst Fit: (Also browse from the beginning BUT level it in a giant way – see which empty area has the largest size at the moment, then use it to grant it to Process)
- 700K allocated to 900K . memory area
- 400K allocated to 600K . memory area
- 300K allocated to 400K . memory area
- 200K is allocated to 200k memory area (remaining memory area of 900K – 700K = 200K)
Best Fit: (Allocate the smallest free memory large enough)
- 700K allocated to 900K . memory area
- 400K allocated to 400K . memory area
- 300K allocated to 300K . memory area
- 200K is allocated to 200k memory area (remaining memory area of 900K – 700K = 200K)
