FOR FREE YEAR SOLVED

Allocation of frames 

 

To increase the degree of multi-programming we try to use memory in a more efficient way and allocated more processes into it.

As we know main memory is divided into frames and frames will be allocated for pages of different processes.

 

Now, how do we allocate the number of frames among the ready process? 

 

Our strategy for the allocation of frames is in various ways and it depends on various factors.

 

But we must allocate a minimum number of frames because to initiate a process at least code, data, stack section is needed. 

 

However, we do not exactly know that how many frames are needed for a process because the minimum number of frames is defined by the computer architecture.

 

Frame Allocation Algorithms:

1. Equal allocation.

2. Proportional allocation.

3. Global and Local allocation.

 

1. Equal allocation:

This is the simplest way where m frames allocated among n processes with equal share i.e. m/n frames (ignoring frames needed by the operating system). 

 

Example: Let there are 80 frames and 7 processes, each process will get 11 frames and 3 frames are free.

 

Another disadvantage is an equal share of frames to each process is unfair because the size of every process is not the same and also the number of pages is different.

 

Let, 

p1 process = 55 pages

p2 process = 10 pages

p3 process = 20 pages

p4 process = 5 pages

 

So, this process is not efficient because practically all process does not have the same number of pages. 

 

2. Proportional allocation

To solve the problem of equal sharing of frames, we can use proportional allocation, in which we allocate available frames to each process according to its size.

Let the number of pages of the process pi be si.

 

 

Then if the total number of available frames in m, we allocated ai frames to process p, where ai is approximate.   

                            

 

Of course, we must adjust each ai to be an integer that is greater than the minimum number required by the process, with a sum not exceeding m.

 

Example:

Total 65 frames and we have 2 processes.

Process p1 = 15 pages

Process p2 = 125 pages

 

 

3. Global and Local 

Another kind of allocation of frames based on process priority. Ac,tually we can classify page-replacement algorithms into two categories

 

1. Global replacement

2. Local replacement

 

1. In global replacement methods, a process can allocate frame from the set of all frames, even if that frame is currently allocated to other processes which has lower priority. So, here one process with higher priority can take frames from another which has lower priority.

 

2. But in the case of local replacement, a process select frames only from its own set of allocated frames. Here one process never allocated frames from another process.