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
<=
mem
ory
block
Allocate job to
first fitted
partition
Job
comple
ted
Get another job
from queue
End
No
Wait
for
input
Yes
ALGORITHM VARIABLE
PARTITIONING FF
50 150 300 350 600
300 25 125 50
50
P1
125
P
2
P3
P
1
P2 P
3
P
4
P
4
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
<=
mem
ory
block
Allocate job to
smallest
partition
Job
comple
ted
Get another job
from queue
End
No
Wait
for
input
Yes
ALGORITHM VARIABLE
PARTITIONING BF
50 150 300 350 600
300 25 125 50
5025
P
1
P2 P
3
P
4
P1 P3
P
4
25
This will cause a Error. Will Explain In Words.
P
2
P1
P
2
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
<=
mem
ory
block
Allocate job to
largest
partition
Job
compl
eted
Get another
job from
queue
End
No
Wait
for
input
Yes
ALGORITHM VARIABLE
PARTITIONING WF
50 150 300 350 600
125
50
P1
300
P
2
P3
P
4
25 125 50
ALGORITHM VARIABLE
PARTITIONING WF
50 150 300 350 600
125
50
P1
300
P
2
P3
P
4
25 125 50
50 150 300 350 600
125
50
P1
300
P
2
P3
P
4
25 125 50ALGORITHM VARIABLE
PARTITIONING WF
50 150 300 350 600
125
50
P1
300
P
2
P3
P
4
25 125 50ALGORITHM VARIABLE
PARTITIONING WF
ADVANTAGES (WF)
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…

First fit , Best fit, Worst fit

  • 1.
    PRESENTATION OPERATING SYSTEMS Prepared By: MShahzeb, M Aamir Ghaffar, Abdullah Ahmad Submitted To: Sir Azeem Ullah Rehan Roll No.’s: 067, 044, 065
  • 2.
    FIRST FIT (FF) Aresource 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.
  • 3.
    FLOW CHART FORFIRST FIT Start Initialize memory block Initialize memory waste If job <= mem ory block Allocate job to first fitted partition Job comple ted Get another job from queue End No Wait for input Yes
  • 4.
    ALGORITHM VARIABLE PARTITIONING FF 50150 300 350 600 300 25 125 50 50 P1 125 P 2 P3 P 1 P2 P 3 P 4 P 4
  • 5.
    ADVANTAGES (FF) DISADVANTAGES Simple Tends toproduce larger free blocks toward the end of the address space External fragmentation
  • 6.
    BEST FIT (BF) Thebest 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.
  • 7.
    FLOW CHART FORBEST FIT Start Initialize memory block Initialize memory waste If job <= mem ory block Allocate job to smallest partition Job comple ted Get another job from queue End No Wait for input Yes
  • 8.
    ALGORITHM VARIABLE PARTITIONING BF 50150 300 350 600 300 25 125 50 5025 P 1 P2 P 3 P 4 P1 P3 P 4 25 This will cause a Error. Will Explain In Words. P 2 P1 P 2
  • 9.
    ADVANTAGES (BF) DISADVANTAGES External fragmentation Slowallocation Slow deallocation Tends to produce many useless tiny fragments (not really great) Works well when most allocations are of small size Relatively simple
  • 10.
    WORST FIT (WF) Thealgorithm 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.
  • 11.
    FLOWCHART FOR WORST FIT:Start Initialize memory block Initialize memory waste If job <= mem ory block Allocate job to largest partition Job compl eted Get another job from queue End No Wait for input Yes
  • 12.
    ALGORITHM VARIABLE PARTITIONING WF 50150 300 350 600 125 50 P1 300 P 2 P3 P 4 25 125 50
  • 13.
    ALGORITHM VARIABLE PARTITIONING WF 50150 300 350 600 125 50 P1 300 P 2 P3 P 4 25 125 50
  • 14.
    50 150 300350 600 125 50 P1 300 P 2 P3 P 4 25 125 50ALGORITHM VARIABLE PARTITIONING WF
  • 15.
    50 150 300350 600 125 50 P1 300 P 2 P3 P 4 25 125 50ALGORITHM VARIABLE PARTITIONING WF
  • 16.
    ADVANTAGES (WF) DISADVANTAGES External fragmentation Tendsto break large free blocks such that large partitions cannot be allocated Works best if allocations are of medium sizes
  • 17.
    THANKS FOR YOUR TIMEAllah Hafiz… The End…