What Is Dynamic Storage Problem?
Hello Friends, In this blog post(Dynamic Storage Problem) we are going to discuss the Dynamic storage problem in Operating systems. Here we will see a few problems occur when the memory is allocated to a process dynamically.
Generally, a set of holes of various sizes is scattered throughout memory at any given time. When a process arrives and needs memory, the system searches this set for a hole that is large enough for this process. |(Dynamic Storage Problem)
If the hole is too large, it is split into two one part is allocated to the arriving process and the other is returned to the set of holes. |(Dynamic Storage Problem)
When a process terminates, it releases its block of memory, which is then placed back in the set of holes. If the new hole is adjacent to the other holes, these adjacent holes are merged to form a larger hole| Dynamic Storage Problem
This process of merging adjacent holes to form a single larger hole is called coalescing.
At this point, the system may need to check whether processes are waiting for memory and whether this…
…newly freed and recombined memory can satisfy the demands of any of these waiting processes.
The procedure is a particular instance of the general dynamic storage allocation problem.
which is how to satisfy a request of size n from a list of free holes. There are many solutions to this problem.
The set of holes is searched to determine which hole is best to allocate.
These first fit, best fit, and worst fit strategies are used to select a free hole from the set of available holes.
First Fit:
Allocate the first hole that is big enough.
In this scheme, searching is started at the beginning of the set of holes or where the previous first-fit search ended.
Searching is stopped as soon as a free hole that is large enough is found.
Best Fit:
Allocate the smallest hole that is big enough.
In this scheme, the entire list is searched until the list is kept ordered by size. this strategy produces the smallest leftover hole.
Worst Fit:
Allocate the largest hole. In this scheme, the entire list is searched unless it is sorted by size.
This strategy produces the largest leftover hole.
Quick Q&A:
What are the best fit worst fit and first fit?
Now we make you understand this best fit, best fit, and worst fit with the help of an example.
Let’s assume we have a memory block of 15kb.
Now in the case of the first fit, we look for the first big enough memory block to fulfill our process and when we get such a block then we assign this memory to our process.
So here in the first fit, we will assign a process of 13 kb to our memory block of 15kb which we have got first while traversing.
The best fit is the case when either we get the same memory block that our process requires or maybe a little more.
Let’s assume that we have a process of 12kb and we get a memory block of either 12 kb or 13kb. Then this would be the best fit.
In the worst fit, we assign a low memory process to a larger memory block. Like we assign a 5kb process to a 15kb memory block or more than that.
Then this would be the case of the worst fit.
What are the disadvantages of the best-fit partitioning algorithm?
As we look for the best suitable memory block in case of the best fit, so we need to look into the whole memory for the perfect block available for the process.
So this process takes time and thus we can say that the best fit is good from a memory management point of view but it is slow.
Which is better first fit or best fit?
look both strategies have their importance and if we look from a space or memory point of view then…
…the best fit is better than the first fit as it optimizes the maximum space in the memory block.
But we look for the speed and time consumption of the process then we can consider the first fit better than the best fit as it may take very little time to find such a block.
Which fit is faster?
The first fit could be much faster depending upon the searching but it can also lead to memory wastage.
If we get a large memory block in the very beginning and assign it to our process having very little memory to execute.
Then there can be a waste of remaining memory.
You can also go through a few more amazing blog links below related to operating systems:
disk scheduling क्या होती है…
FAT32 Advantages and Disadvantages…
Overlay advantages and disadvantages in programs…
What is the use of Cache Memory…
What is Linker? Why is it required?…
types Of File Operations…
What are the file Organisation and its types…
Dijkstra: Bankers Algorithm For Deadlock Avoidance…
What is a thread in the operating system with an example…
Cache Memory In Hindi…
Linker In Hindi…
What Are Multithreading Models in Hindi…
Dynamic Storage Problem In OS In Hindi…
Process states in the Operating system in Hindi…
FAT32 Advantages And Disadvantages In Hindi…
Critical Section Problem With a Simple Example…
Critical Section Problem In OS In Hindi…
Dijkstra Algorithm In Hindi|Banker’s Algorithm In Hindi…
What Is Dynamic Storage Problem…
What are the Fork and Exec system calls…
Multithreaded Process: Benefits & Models…
The Process States In Operating System…
Conclusion:
So friends, in this blog post(Dynamic Storage Problem) we have seen the dynamic storage problem in OS. Here the memory holes are allocated dynamically and this creates unused memory holes which can be assigned to a process if they are combined. We have also seen some memory allocation strategies like First Fit, Best Fit, and Worst Fit to allocate the holes in a process.
In the case of any queries, you can write to us at a5theorys@gmail.com we will get back to you ASAP.
Hope! you would have enjoyed this post about Dynamic Storage problems.
Please feel free to give your important feedback in the comment section below.
Have a great time!