First fit , Best fit, Worst fit

66,729 views 17 slides Feb 09, 2018
Slide 1
Slide 1 of 17
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17

About This Presentation

What is first,best and worst fit? Algorithems of these fits with animations.
Download for animations in slides.


Slide Content

Presentation Operating Systems Prepared By: M Shahzeb, M Aamir Ghaffar, Abdullah Ahmad Submitted To: Sir Azeem Ullah Rehan Roll No.’s: 067, 044, 065

First Fit (FF) A resource allocation scheme (usually for memory). First Fit fits data into memory by scanning from the beginning of available memory to the end, until the first free space which is at least big enough to accept the data is found. This space is then allocated to the data. Any left over becomes a smaller, separate free space. If the data to be allocated is bigger than the biggest free space, the request cannot be met, and an error is generated.

Flow Chart for First fit Start Initialize memory block Initialize memory waste If job <= memory block Allocate job to first fitted partition Job completed Get another job from queue End No Wait for input Yes

Algorithm Variable Partitioning FF 50 150 300 350 600 300 25 125 5 50 P1 125 P2 P3 P1 P2 P3 P4 P4

Advantages (FF) Disadvantages Simple Tends to produce larger free blocks toward the end of the address space External fragmentation

Best Fit (BF) The best fit deals with allocating the smallest free partition which meets the requirement of the requesting process. This algorithm first searches the entire list of free partitions and considers the smallest hole that is adequate. It then tries to find a hole which is close to actual process size needed.

Flow chart for best fit Start Initialize memory block Initialize memory waste If job <= memory block Allocate job to smallest partition Job completed Get another job from queue End No Wait for input Yes

Algorithm Variable Partitioning b F 50 150 300 350 600 300 25 125 5 50 25 P1 P2 P3 P4 P1 P3 P4 25 This will cause a Error. Will Explain In Words. P2 P1 P2

Advantages (BF) Disadvantages External fragmentation Slow allocation Slow deallocation Tends to produce many useless tiny fragments (not really great ) Works well when most allocations are of small size Relatively simple

Worst Fit (WF) The algorithm searches for free-space in memory in which it can store the desired information. The algorithm selects the largest possible free space that the information can be stored on (i.e. that is bigger than the information needing to be stored) and stores it there. This is directly opposed to the best fit algorithm which searches the memory in much the same way as before.

Flowchart for worst fit: Start Initialize memory block Initialize memory waste If job <= memory block Allocate job to largest partition Job completed Get another job from queue End No Wait for input Yes

Algorithm Variable partitioning WF 50 150 300 350 600 125 50 P1 300 P2 P3 P4 25 125 5

Algorithm Variable partitioning WF 50 150 300 350 600 125 50 P1 300 P2 P3 P4 25 125 5

50 150 300 350 600 125 50 P1 300 P2 P3 P4 25 125 5 Algorithm Variable partitioning WF

50 150 300 350 600 125 50 P1 300 P2 P3 P4 25 125 5 Algorithm Variable partitioning WF

Advantages ( W F) Disadvantages External fragmentation Tends to break large free blocks such that large partitions cannot be allocated Works best if allocations are of medium sizes

Thanks For Your Time Allah Hafiz… The End…