Allocation of Frames in OS
The main memory of the operating system is divided into various frames. The process is stored in these frames, and once the process is saved as a frame, the CPU may run it. As a result, the operating system must set aside enough frames for each process. As a result, the operating system uses various algorithms in order to assign the frame.
Demand paging is used to implement virtual memory, an essential operating system feature. It requires the development of a page replacement mechanism and a frame allocation system. If you have multiple processes, the frame allocation techniques are utilized to define how many frames to allot to each one. A number of factors constrain the strategies for allocating frames:
There are mainly five ways of frame allocation algorithms in the OS. These are as follows:
Equal Frame Allocation
In equal frame allocation, the processes are assigned equally among the processes in the OS. For example, if the system has 30 frames and 7 processes, each process will get 4 frames. The 2 frames that are not assigned to any system process may be used as a free-frame buffer pool in the system.
In a system with processes of varying sizes, assigning equal frames to each process makes little sense. Many allotted empty frames will be wasted if many frames are assigned to a small task.
Proportional Frame Allocation
The proportional frame allocation technique assigns frames based on the size needed for execution and the total number of frames in memory.
The allocated frames for a process pi of size si are ai = (si/S)*m, in which S represents the total of all process sizes, and m represents the number of frames in the system.
The only drawback of this algorithm is that it doesn't allocate frames based on priority. Priority frame allocation solves this problem.
Priority Frame Allocation
Priority frame allocation assigns frames based on the number of frame allocations and the processes. Suppose a process has a high priority and requires more frames that many frames will be allocated to it. Following that, lesser priority processes are allocated.
Global Replacement Allocation
When a process requires a page that isn't currently in memory, it may put it in and select a frame from the all frames sets, even if another process is already utilizing that frame. In other words, one process may take a frame from another.
Process performance is not hampered, resulting in higher system throughput.
The process itself may not solely control the page fault ratio of a process. The paging behavior of other processes also influences the number of pages in memory for a process.
Local Replacement Allocation
When a process requires a page that isn't already in memory, it can bring it in and assign it a frame from its set of allocated frames.
The paging behavior of a specific process has an effect on the pages in memory and the page fault ratio.
A low priority process may obstruct a high priority process by refusing to share its frames.
Global Vs. Local Replacement Allocation
The number of frames assigned to a process does not change using a local replacement strategy. On the other hand, using global replacement, a process can choose only frames granted to other processes and enhance the number of frames allocated.
Next TopicCooperating Process in Operating System