Prev Next

Best-Fit, First-Fit and Worst-Fit Memory Allocation Method for Fixed Partition

The following jobs are loaded into memory using fixed partition following a certain memory allocation method (best-fit, first-fit and worst-fit).
                                              
List of Jobs
Size
Turnaround
Job 1
100k
3
Job 2
10k
1
Job 3
35k
2
Job 4
15k
1
Job 5
23k
2
Job 6
6k
1
Job 7
25k
1
Job 8
55k
2
Job 9
88k
3
Job 10
100k
3
                  Memory Block            Size             
                      Block 1                    50k
                      Block 2                  200k 
                      Block 3                    70k
                      Block 4                  115k
                      Block 5                    15k









 B E S T - F I T

Best-fit memory allocation makes the best use of memory space but slower in making allocation. In the illustration below, on the first processing cycle, jobs 1 to 5 are submitted and be processed first. After the first  cycle, job 2 and 4 located on block 5 and block 3 respectively and both having one turnaround are replace by job 6 and 7 while  job 1, job 3 and job 5 remain on their designated block. In the third cycle, job 1 remain on block 4, while job 8 and job 9 replace job 7 and job 5 respectively (both having 2 turnaround). On the next cycle, job 9 and job 8 remain on their block while job 10 replace job 1 (having 3 turnaround). On the fifth cycle only job 9 and 10 are the remaining jobs to be process and there are 3 free memory blocks  for the incoming jobs. But since there are only 10 jobs, so it will remain free. On the sixth cycle, job 10 is the only remaining job to be process and finally on the seventh cycle, all jobs are successfully process and executed and all the memory blocks are now free.   
 
 
 
F I R S T - F I T
 
First-fit memory allocation is faster in making allocation but leads to memory waste. The illustration below shows that on the first cycle, job 1 to job 4 are submitted first while job 6 occupied block 5 because the remaining memory space is enough to its required memory size to be process. While  job 5 is in waiting queue because the memory size in block 5 is not enough for the job 5 to be process. Then on the next cycle, job 5 replace job 2 on block 1 and job 7 replace job 4 on block 4 after both job 2 and job 4 finish their process. Job 8 is in waiting queue because the remaining block is not enough to accommodate the memory size of job 8. On the third cycle, job 8 replace job 3 and job 9 occupies block 4 after processing job 7.  While Job 1 and job 5 remain on its designated block. After the third cycle block 1 and block 5 are free to serve the incoming jobs but since there are 10 jobs so it will remain free. And job 10 occupies block 2 after job 1 finish its turns. On the other hand, job 8 and job 9 remain on their block. Then on the fifth cycle, only job 9 and job 10 are to be process while there are 3 memory blocks free. In the sixth cycle, job 10 is the only remaining job to be process and lastly in the seventh cycle, all jobs are successfully process and executed and all the memory blocks are now free. 
 
 
 
W O R S T - F I T
 
Worst-fit memory allocation is opposite to best-fit. It allocates free available block to the new job and it is not the best choice for an actual system. In the illustration, on the first cycle, job 5 is in waiting queue while job 1 to job 4 and job 6 are the jobs to be first process. After then,  job 5 occupies the free block replacing job 2. Block 5 is now free to accommodate the next job which is job 8 but since the size in block 5 is not enough for job 8, so job 8 is in waiting queue. Then on the next cycle, block 3 accommodate job 8 while job 1 and job 5 remain on their memory block. In this cycle, there are 2 memory blocks are free. In the fourth cycle, only job 8 on block 3 remains while job 1 and job 5 are respectively replace by job 9 and job 10. Just the same in the previous cycle, there are still two free memory blocks. At fifth cycle, job 8 finish its job while the job 9 and job 10 are still on block 2 and block 4 respectively and there is additional memory block free. The same scenario happen on the sixth cycle. Lastly, on the seventh cycle, both job 9 and job 10 finish its process and in this cycle, all jobs are successfully process and executed. And all the memory blocks are now free.   
 
 

53 Responses so far.

  1. JONA says:

    what about the internal and external fragmentation..????

  2. Anonymous says:

    thanks

  3. Unknown says:

    Nice. I have one question, If I have job 1 size of 210. what will happen to that? if the maximum partition of the memory block is 200.

  4. Can u plz tell me how u added scrolling images to ur blog header...

  5. I have a question. What happens if a job cant find a partition it can enter?..

  6. awesome interface dude ..... like it ot the core...

  7. Unknown says:

    Nice n simple explanation....
    keep it up....

  8. Amit says:

    wow amazing explanation..... dude....

  9. ease of understand...keep it up knowledge sharing

  10. Raj Patel says:

    Nice Explanation...........Thankx

  11. Unknown says:

    really very helpful .. thanks a lot

  12. rahamath says:

    easy to understand me.. Thanxxx

  13. Unknown says:
    This comment has been removed by the author.
  14. this is what i've been looking for
    On point...thanks

  15. Unknown says:

    Given memory partitions as 100k, 500K, 200K, 300K and 600K (in order). How would each of the first fit, best fit and worst fit algorithm place process of 412K, 317K, 112K and 326K

    here turn around time is not given. how to solve??

  16. Unknown says:

    Given memory partitions as 100k, 500K, 200K, 300K and 600K (in order). How would each of the first fit, best fit and worst fit algorithm place process of 412K, 317K, 112K and 326K

    here turn around time is not given. how to solve??

  17. Thanks a lot. But I still dont get it between worst-fit and next-fit. What are the differences between those algorithms?

  18. ONLY GENIUS CAN UNDERSTAND THIS.

  19. Unknown says:

    so helpful for me.............thanks for it.

  20. Unknown says:

    thanks..... very helpful

  21. If u are doing it pictorially, it will be better..

  22. Unknown says:

    Do you have a program with this Memory Partition? In Visual Basic Studio 2010

  23. thanks for these methods! I can recommend you http://skywritingservice.com/blog/worst-and-best-jobs-you-probably-dont-know where you can find information about the best and the worst jobs ever!

  24. This comment has been removed by the author.
  25. Unknown says:

    I just wanted to thank you for such an exclusive post! Also, when you get the chance, you can look through one more in-depth written post available at http://skywritingservice.com/blog/worst-and-best-jobs-you-probably-dont-know

  26. Then you can assume turnaround time equal to 1 for each case.

  27. Unknown says:

    What a nice and intriguing article! I wonder where I could have found such information if it was not posted on this website. I am so grateful to the author for doing a recommendable job. I am looking forward to reading more articles from this site. Find time and check out my article by clicking on Professional Dissertation Essay Experts.

  28. It is a best example for Memory placement types

  29. Windows is the best operating system with user friendly features but I think they should work more on internet security. You can find more discussion on this topic at this Question and Answer Website.

  30. Unknown says:

    Wow, this picture is very god. moderninha wifi.

  31. Unknown says:

    the answer is following explanation with example all the method.

  32. Unknown says:

    Can anyone has code in java.

  33. Unknown says:
    This comment has been removed by the author.
  34. Nice indeed. But we need more explanation

  35. positive candidate experience

    Positive Candidate Experience - JobFlix take the guesswork out in your quest to find the most employers brand and suitability talents, saving you time and resources. Toolkits, Guides and Reports to help you in your Talent Acquisition.



    to get more - https://gojobflix.com/about.html

Leave a Reply