Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Shirpur Education Society’s

R. C. PATEL INSTITUTE OF TECHNOLOGY


Nimzari Naka, Shirpur- 425 405 Dist : Dhule (MS)

Department of Computer Engineering

Laboratory Manual
Subject: - Processor Organization and Architecture (POA)
Class: - s.Y. Semester-IV

Experiment No: - 05

Aim: - To implement First Fit Memory allocation policy.

Software requirement: - Turbo C Compiler

Theory: - Memory allocation:


1. Memory allocation is the decision of where to acquire memory when a process requests it.
2. To do this, the OS must keep track of what memory regions are in use and which are free, and it needs
a policy for determining how free memory regions (or “holes”) are given to processes.
3. These decisions are made by the memory manager component of the OS kernel.
4. Since most programs require many memory allocation/deallocation calls, memory management must
be very fast.
5. A program requests memory when it is first instantiated.
6. The memory manager may use one of several policies to decide what are the best free spots from
which to allocate.

First Fit Memory Allocation Policy


In the first fit approach is to allocate the first free partition or hole large enough which can accommodate
the process. It finishes after finding the first suitable free partition. In this scheme we check the blocks
in a sequential manner which means we pick the first process then compare it’s size with first block size
if it is less than size of block it is allocated otherwise we move to second block and so on. When first
process is allocated we move on to the next process until all processes are allocated.

Advantage
Fastest algorithm because it searches as little as possible.

Disadvantage
The remaining unused memory areas left after allocation become waste if it is too smaller. Thus
request for larger memory requirement cannot be accomplished.
Algorithm :

1. Get no. of Processes and no. of blocks.


2. After that get the size of each block and process requests.
3. Now allocate processes
4. if(block size >= process size)
5. //allocate the process
6. else
7. //move on to next block
8. Display the processes with the blocks that are allocated to a respective process.
9. Stop.

Attach Program Printout:

You might also like