Now we are ready to read about various types of memory allocation. One of the simplest methods for allocating memory is to divide memory into several Fixed-Sized partitions. Each partition may contain exactly one process. In this multiple partition method, when a partition is free, a process is selected from the input queue and is loaded into the free partition. When the process terminates, the partition becomes available for another process. But this method is no longer in use.
In the Variable-Partition scheme, the operating system keeps a table indicating which parts of memory are available and which are occupied. All the memory is available for user processes and is considered one large block of available memory, called hole. Eventually memory contains a set of holes of various sizes. As processes enter the system, they are put into an input queue. And when a process is allocated space, it is loaded into memory and it canthen compete for CPU time. When a process terminates, it releases its memory, which the operating system may then fill with another process.
In general, as mentioned, the memory blocks available comprise a set of holes of various sizes scattered throughout memory. When a process arrives and needs memory, the system searches the set for a hole that is large enough for this process. If the hole is too large, it is split into two parts. One part is allocated to the arriving process and the other one is returned to the set of holes. 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 other holes, these adjacent holes are merged to form one larger hole.
This procedure is a particular instance of the general dynamic storage
allocation problem. There are many solutions to selecting a free hole from the set of available holes as follows :-
i> First Fit :- It allocates first hole that is big enough. The searching can start from begining of the list.
ii> Best Fit :- It allocate the first smallest sufficient hole or partition.We must search the entire list, unless list is ordered by size. It produces smallest leftover space.
iii> Worst Fit :- It allocate the hole or partition which is the largest. It produces the largest leftover space.
iv> Next Fit :- It is similar to the first fit but it will search for the first sufficient partition from the last allocation point.
Although best fit minimizes the wastage space, it consumes a lot of processor time for searching the block which is close to the required size. Also, Best fit may perform poorer than other algorithms in some cases. SO we can not say best fit is actually best as its name. Neither first fit nor best fit is clearly better than the other in terms of storage utilization, but first fit is generally faster.
click here for contigeous memory allocation.
Share, Follow and please comment if you find anything incorrect or to share more information about the topic discussed above.
Comments
Post a Comment
Please comment.