SlideShare a Scribd company logo
17
Most read
20
Most read
21
Most read
3.2 Variable Partitioning
• There are three algorithms for searching the list of free blocks
for a specific amount of memory.
– First Fit
– Best Fit
– Worst Fit
1
first fit
First Fit : Allocate the first free block that is
large enough for the new process.
This is a fast algorithm.
2
first fit
OS
P1 12 KB
<FREE> 10 KB
P2 20 KB
<FREE> 16 KB
P3 6 KB
<FREE> 4 KB
Initial memory
mapping
3
first fit
OS
P1 12 KB
<FREE> 10 KB
P2 20 KB
<FREE> 16 KB
P3 6 KB
<FREE> 4 KB
P4 of 3KB
arrives
4
first fit
OS
P1 12 KB
P4 3 KB
<FREE> 7 KB
P2 20 KB
<FREE> 16 KB
P3 6 KB
<FREE> 4 KB
P4 of 3KB
loaded here by
FIRST FIT
5
first fit
OS
P1 12 KB
P4 3 KB
<FREE> 7 KB
P2 20 KB
<FREE> 16 KB
P3 6 KB
<FREE> 4 KB
P5 of 15KB
arrives
6
first fit
OS
P1 12 KB
P4 3 KB
<FREE> 7 KB
P2 20 KB
P5 15 KB
<FREE> 1 KB
P3 6 KB
<FREE> 4 KB
P5 of 15 KB
loaded here by
FIRST FIT
7
Best fit
Best Fit : Allocate the smallest block among those that are
large enough for the new process.
In this method, the OS has to search the entire list, or it can
keep it sorted and stop when it hits an entry which has a size
larger than the size of new process.
 This algorithm produces the smallest left over block.
However, it requires more time for searching all the list or
sorting it
If sorting is used, merging the area released when a process
terminates to neighboring free blocks, becomes complicated.
8
best fit
OS
P1 12 KB
<FREE> 10 KB
P2 20 KB
<FREE> 16 KB
P3 6 KB
<FREE> 4 KB
Initial memory
mapping
9
best fit
OS
P1 12 KB
<FREE> 10 KB
P2 20 KB
<FREE> 16 KB
P3 6 KB
<FREE> 4 KB
P4 of 3KB
arrives
10
best fit
OS
P1 12 KB
<FREE> 10 KB
P2 20 KB
<FREE> 16 KB
P3 6 KB
P4 3 KB
<FREE> 1 KB
P4 of 3KB
loaded here by
BEST FIT
11
best fit
OS
P1 12 KB
<FREE> 10 KB
P2 20 KB
<FREE> 16 KB
P3 6 KB
P4 3 KB
<FREE> 1 KB
P5 of 15KB
arrives
12
best fit
OS
P1 12 KB
<FREE> 10 KB
P2 20 KB
P5 15 KB
<FREE> 1 KB
P3 6 KB
P4 3 KB
<FREE> 1 KB
P5 of 15 KB
loaded here by
BEST FIT
13
worst fit
Worst Fit : Allocate the largest block among those that are
large enough for the new process.
Again a search of the entire list or sorting it is needed.
This algorithm produces the largest over block.
14
worst fit
OS
P1 12 KB
<FREE> 10 KB
P2 20 KB
<FREE> 16 KB
P3 6 KB
<FREE> 4 KB
Initial memory
mapping
15
worst fit
OS
P1 12 KB
<FREE> 10 KB
P2 20 KB
<FREE> 16 KB
P3 6 KB
<FREE> 4 KB
P4 of 3KB
arrives
16
worst fit
OS
P1 12 KB
<FREE> 10 KB
P2 20 KB
P4 3 KB
<FREE> 13 KB
P3 6 KB
<FREE> 4 KB
P4 of 3KB
Loaded here by
WORST FIT
17
worst fit
OS
P1 12 KB
<FREE> 10 KB
P2 20 KB
P4 3 KB
<FREE> 13 KB
P3 6 KB
<FREE> 4 KB
No place to load
P5 of 15K
18
worst fit
OS
P1 12 KB
<FREE> 10 KB
P2 20 KB
P4 3 KB
<FREE> 13 KB
P3 6 KB
<FREE> 4 KB
No place to load
P5 of 15K
19
• 1. Given five memory partitions of 100Kb, 500Kb, 200Kb, 300Kb, 600Kb (in order), how would the
first-fit, best-fit, and worst-fit algorithms place processes of 212 Kb, 417 Kb, 112 Kb, and 426 Kb (in
order)? Which algorithm makes the most efficient use of memory?
• First-fit:
212K is put in 500K partition
417K is put in 600K partition
112K is put in 288K partition (new partition 288K = 500K - 212K)
426K must wait
• Best-fit:
212K is put in 300K partition
417K is put in 500K partition
112K is put in 200K partition
426K is put in 600K partition
• Worst-fit:
212K is put in 600K partition
417K is put in 500K partition
112K is put in 388K partition
426K must wait
• In this example, best-fit turns out to be the best.
212,417,112,426
100 500 200 300 600

More Related Content

PPTX
Cache memory
PPTX
Bus aribration
PPTX
Job sequencing with Deadlines
PDF
OS file systems
PPT
SEARCHING AND SORTING ALGORITHMS
PPTX
0/1 DYNAMIC PROGRAMMING KNAPSACK PROBLEM
PPT
Counting Sort and Radix Sort Algorithms
PPTX
blackboard architecture.pptx
Cache memory
Bus aribration
Job sequencing with Deadlines
OS file systems
SEARCHING AND SORTING ALGORITHMS
0/1 DYNAMIC PROGRAMMING KNAPSACK PROBLEM
Counting Sort and Radix Sort Algorithms
blackboard architecture.pptx

What's hot (20)

PPTX
DAA-Floyd Warshall Algorithm.pptx
PPT
Binary Search
PPTX
Linear search-and-binary-search
PPTX
File access method
PPTX
Quick sort-Data Structure
PPTX
Priority Scheduling
PPT
Assembly Language Basics
PPTX
Universal turing coastus
PPT
Sum of subsets problem by backtracking 
PPTX
B and B+ tree
PPTX
deque and it applications
PPTX
Virtual memory management in Operating System
PPT
Backtracking
PPTX
Shortest job first Scheduling (SJF)
PPTX
Knapsack Problem (DP & GREEDY)
PPTX
Binary Search Tree
PPTX
DOCX
8086 pin diagram description
PPTX
Computer registers
PDF
Data mining
DAA-Floyd Warshall Algorithm.pptx
Binary Search
Linear search-and-binary-search
File access method
Quick sort-Data Structure
Priority Scheduling
Assembly Language Basics
Universal turing coastus
Sum of subsets problem by backtracking 
B and B+ tree
deque and it applications
Virtual memory management in Operating System
Backtracking
Shortest job first Scheduling (SJF)
Knapsack Problem (DP & GREEDY)
Binary Search Tree
8086 pin diagram description
Computer registers
Data mining
Ad

Similar to First Best and Worst Fit.pptx (20)

PPT
memory mgmt.ppt
PDF
Tuning Solr and its Pipeline for Logs: Presented by Rafał Kuć & Radu Gheorghe...
PDF
Tuning Solr & Pipeline for Logs
PDF
[NetApp] Managing Big Workspaces with Storage Magic
PPT
35. multiplepartitionallocation
PDF
Some analysis of BlueStore and RocksDB
ODP
Using ТРСС to study Firebird performance
PDF
3.INTEL.Optane_on_ceph_v2.pdf
PDF
Ceph Day Beijing - Optimizing Ceph Performance by Leveraging Intel Optane and...
PDF
Ceph Day Beijing - Optimizing Ceph performance by leveraging Intel Optane and...
PPTX
OS_Lecture_07_Memory-Management_pro.pptx
PPTX
Raidz on-disk format vs. small blocks
PPTX
RAIDZ on-disk format vs. small blocks
PDF
MyRocks Deep Dive
PDF
Understanding the impact of Linux scheduler on your application
PPTX
Improving Kafka at-least-once performance at Uber
PDF
Testing Persistent Storage Performance in Kubernetes with Sherlock
PDF
Linux 4.x Tracing Tools: Using BPF Superpowers
PDF
Accelerating HBase with NVMe and Bucket Cache
PDF
Shipping python project by docker
memory mgmt.ppt
Tuning Solr and its Pipeline for Logs: Presented by Rafał Kuć & Radu Gheorghe...
Tuning Solr & Pipeline for Logs
[NetApp] Managing Big Workspaces with Storage Magic
35. multiplepartitionallocation
Some analysis of BlueStore and RocksDB
Using ТРСС to study Firebird performance
3.INTEL.Optane_on_ceph_v2.pdf
Ceph Day Beijing - Optimizing Ceph Performance by Leveraging Intel Optane and...
Ceph Day Beijing - Optimizing Ceph performance by leveraging Intel Optane and...
OS_Lecture_07_Memory-Management_pro.pptx
Raidz on-disk format vs. small blocks
RAIDZ on-disk format vs. small blocks
MyRocks Deep Dive
Understanding the impact of Linux scheduler on your application
Improving Kafka at-least-once performance at Uber
Testing Persistent Storage Performance in Kubernetes with Sherlock
Linux 4.x Tracing Tools: Using BPF Superpowers
Accelerating HBase with NVMe and Bucket Cache
Shipping python project by docker
Ad

More from Senthil Vit (20)

PPTX
Jenkins and Maven in cloud data Engineering
PPTX
Introduction to Jenkins Pipeline in data engg
PPTX
Logical Design Architecture in Internet of Things
PDF
Wireless sensor networks in Internet of Things
PPTX
Classification Algorithm in Machine Learning
PPTX
Decision Trees Learning in Machine Learning
PPTX
Operating system Virtualization_NEW.pptx
PPTX
Synchronization Peterson’s Solution.pptx
PPT
Control structures in Python programming
PPT
Data and Expressions in Python programming
PPTX
Python programming Introduction about Python
PDF
Switching Problems.pdf
PPT
Big Oh.ppt
PPT
AsymptoticNotations.ppt
PPT
snort.ppt
PPTX
File Implementation Problem.pptx
PPT
Design Issues of an OS.ppt
PPTX
Operating Systems – Structuring Methods.pptx
PPT
deadlock.ppt
PPTX
Virtualization.pptx
Jenkins and Maven in cloud data Engineering
Introduction to Jenkins Pipeline in data engg
Logical Design Architecture in Internet of Things
Wireless sensor networks in Internet of Things
Classification Algorithm in Machine Learning
Decision Trees Learning in Machine Learning
Operating system Virtualization_NEW.pptx
Synchronization Peterson’s Solution.pptx
Control structures in Python programming
Data and Expressions in Python programming
Python programming Introduction about Python
Switching Problems.pdf
Big Oh.ppt
AsymptoticNotations.ppt
snort.ppt
File Implementation Problem.pptx
Design Issues of an OS.ppt
Operating Systems – Structuring Methods.pptx
deadlock.ppt
Virtualization.pptx

Recently uploaded (20)

PPTX
introduction to high performance computing
PDF
PPT on Performance Review to get promotions
PPTX
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
PPTX
Fundamentals of safety and accident prevention -final (1).pptx
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PDF
Categorization of Factors Affecting Classification Algorithms Selection
PPT
INTRODUCTION -Data Warehousing and Mining-M.Tech- VTU.ppt
PDF
737-MAX_SRG.pdf student reference guides
PDF
Soil Improvement Techniques Note - Rabbi
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PPTX
Safety Seminar civil to be ensured for safe working.
PPTX
Current and future trends in Computer Vision.pptx
PDF
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
PDF
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
PDF
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
PDF
Visual Aids for Exploratory Data Analysis.pdf
PDF
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
PPTX
Nature of X-rays, X- Ray Equipment, Fluoroscopy
PPTX
Information Storage and Retrieval Techniques Unit III
introduction to high performance computing
PPT on Performance Review to get promotions
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
Fundamentals of safety and accident prevention -final (1).pptx
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
Categorization of Factors Affecting Classification Algorithms Selection
INTRODUCTION -Data Warehousing and Mining-M.Tech- VTU.ppt
737-MAX_SRG.pdf student reference guides
Soil Improvement Techniques Note - Rabbi
R24 SURVEYING LAB MANUAL for civil enggi
Safety Seminar civil to be ensured for safe working.
Current and future trends in Computer Vision.pptx
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
Visual Aids for Exploratory Data Analysis.pdf
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
Nature of X-rays, X- Ray Equipment, Fluoroscopy
Information Storage and Retrieval Techniques Unit III

First Best and Worst Fit.pptx

  • 1. 3.2 Variable Partitioning • There are three algorithms for searching the list of free blocks for a specific amount of memory. – First Fit – Best Fit – Worst Fit 1
  • 2. first fit First Fit : Allocate the first free block that is large enough for the new process. This is a fast algorithm. 2
  • 3. first fit OS P1 12 KB <FREE> 10 KB P2 20 KB <FREE> 16 KB P3 6 KB <FREE> 4 KB Initial memory mapping 3
  • 4. first fit OS P1 12 KB <FREE> 10 KB P2 20 KB <FREE> 16 KB P3 6 KB <FREE> 4 KB P4 of 3KB arrives 4
  • 5. first fit OS P1 12 KB P4 3 KB <FREE> 7 KB P2 20 KB <FREE> 16 KB P3 6 KB <FREE> 4 KB P4 of 3KB loaded here by FIRST FIT 5
  • 6. first fit OS P1 12 KB P4 3 KB <FREE> 7 KB P2 20 KB <FREE> 16 KB P3 6 KB <FREE> 4 KB P5 of 15KB arrives 6
  • 7. first fit OS P1 12 KB P4 3 KB <FREE> 7 KB P2 20 KB P5 15 KB <FREE> 1 KB P3 6 KB <FREE> 4 KB P5 of 15 KB loaded here by FIRST FIT 7
  • 8. Best fit Best Fit : Allocate the smallest block among those that are large enough for the new process. In this method, the OS has to search the entire list, or it can keep it sorted and stop when it hits an entry which has a size larger than the size of new process.  This algorithm produces the smallest left over block. However, it requires more time for searching all the list or sorting it If sorting is used, merging the area released when a process terminates to neighboring free blocks, becomes complicated. 8
  • 9. best fit OS P1 12 KB <FREE> 10 KB P2 20 KB <FREE> 16 KB P3 6 KB <FREE> 4 KB Initial memory mapping 9
  • 10. best fit OS P1 12 KB <FREE> 10 KB P2 20 KB <FREE> 16 KB P3 6 KB <FREE> 4 KB P4 of 3KB arrives 10
  • 11. best fit OS P1 12 KB <FREE> 10 KB P2 20 KB <FREE> 16 KB P3 6 KB P4 3 KB <FREE> 1 KB P4 of 3KB loaded here by BEST FIT 11
  • 12. best fit OS P1 12 KB <FREE> 10 KB P2 20 KB <FREE> 16 KB P3 6 KB P4 3 KB <FREE> 1 KB P5 of 15KB arrives 12
  • 13. best fit OS P1 12 KB <FREE> 10 KB P2 20 KB P5 15 KB <FREE> 1 KB P3 6 KB P4 3 KB <FREE> 1 KB P5 of 15 KB loaded here by BEST FIT 13
  • 14. worst fit Worst Fit : Allocate the largest block among those that are large enough for the new process. Again a search of the entire list or sorting it is needed. This algorithm produces the largest over block. 14
  • 15. worst fit OS P1 12 KB <FREE> 10 KB P2 20 KB <FREE> 16 KB P3 6 KB <FREE> 4 KB Initial memory mapping 15
  • 16. worst fit OS P1 12 KB <FREE> 10 KB P2 20 KB <FREE> 16 KB P3 6 KB <FREE> 4 KB P4 of 3KB arrives 16
  • 17. worst fit OS P1 12 KB <FREE> 10 KB P2 20 KB P4 3 KB <FREE> 13 KB P3 6 KB <FREE> 4 KB P4 of 3KB Loaded here by WORST FIT 17
  • 18. worst fit OS P1 12 KB <FREE> 10 KB P2 20 KB P4 3 KB <FREE> 13 KB P3 6 KB <FREE> 4 KB No place to load P5 of 15K 18
  • 19. worst fit OS P1 12 KB <FREE> 10 KB P2 20 KB P4 3 KB <FREE> 13 KB P3 6 KB <FREE> 4 KB No place to load P5 of 15K 19
  • 20. • 1. Given five memory partitions of 100Kb, 500Kb, 200Kb, 300Kb, 600Kb (in order), how would the first-fit, best-fit, and worst-fit algorithms place processes of 212 Kb, 417 Kb, 112 Kb, and 426 Kb (in order)? Which algorithm makes the most efficient use of memory? • First-fit: 212K is put in 500K partition 417K is put in 600K partition 112K is put in 288K partition (new partition 288K = 500K - 212K) 426K must wait • Best-fit: 212K is put in 300K partition 417K is put in 500K partition 112K is put in 200K partition 426K is put in 600K partition • Worst-fit: 212K is put in 600K partition 417K is put in 500K partition 112K is put in 388K partition 426K must wait • In this example, best-fit turns out to be the best.