Skip to main content

Types Of Memory Allocation


  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

Popular posts from this blog

Process Scheduling And Types of Process Schedular :-

        ⇰ PROCESS SCHEDULING Process Scheduling  is a task  of Operating System that schedules processes of different states like new, ready, waiting, terminated  and running.This scheduling helps in allocation of CPU time for each process, and Operating System allocates the CPU time for each procss. And the process scheduling plays important role to keep the CPU busy all the time.  ⏩   Followings are some objectives of Process Scheduling :-  i > To increase the amount of users within acceptable response times.  ii > To maintain the balance between response and utilization of system. iii > To decrease the enforce priorities and  give reference to the processes holding the key resources.      ⇰  PROCESS SCHEDULAR A scheduler carries out the pro cess scheduling work. Schedulers are often implemented so they keep all computer resources busy and  allows multiple users to share system resources  to achieve  multiprogramming .  There are  mainy three types of pro

Process & Its state And process control block :-

                ⇰  PROCESS :- A process can be thought of as a program in execution. Means when any program is executed it becomes process. A processwill need certain resources such as CPU time , memory, files and I/O devices to complete its task. These resources are allocated to the process either when it is created or at the time of execution.             A process is the unit of work in most systems. A system consistes of a collection of processes. All these processes may execute concurrently. Traditionally a process contained only a single thread. Most modern operating ststems now supports processes that have multiple threads.         The operating system is responsible for several important works of process management as - the creation and deletion of process, the schrduling of process, communication and deadlock handling of process. Process is broudly divided into two types:-  i> System  Process. ii> User Process. Early computers allowed only one program be ex

Semaphores In Process Synchronization

   ⇰  Semaphores :-   Semaphore is actually a method or tool to prevent race condition. Race condition can cause loss of data or even deadlock situation. For prevention from these conditions, the semaphore is one of the method.  Semaphore was proposed by Dijkstra in 1965. Simaphore    is a very significant technique to manage concurrent processes.  Semaphore is useful tool in the prevention of race condition. But the use of semaphore never means a guarantee that a program is free from these problems.     Semaphore is an integer variable which is used in mutual exclusive manner by various concurrent cooperative processes in order to acheive synchronization. Hence semaphore is one of the way to achieve synchronization.  Semaphore is basically  a variable which is non-negative and shared between threads. This variable is used to solve the critical section problem and to achieve process synchronization in the multiprocessing environment. Semaphore contains some operations as f