In this tutorial, we are going to learn about the fixed partitioning in the operating system.
Fixed partitioning is one to manage the memory in operating system. It's an old technique. It divides the memory into equal blocks. The size of each block is predefined and can not be changed.
The memory is used for the contiguous processes.
Let's see the sample program that allocates memory based on the process size.
#include<iostream> using namespace std; int main() { int blockNumber = 5, processesNumber = 3; int blockSize[5] = {4, 4, 4, 4, 4}, processSize[3] = {1, 2, 3}; int flags[5], allocation[5]; for(int i = 0; i < 5; i++) { flags[i] = 0; allocation[i] = -1; } // allocating the blocks to processes for(int i = 0; i < processesNumber; i++) { for(int j = 0; j < blockNumber; j++) { if(flags[j] == 0 && blockSize[j] >= processSize[i]) { allocation[j] = i; flags[j] = 1; break; } } } for (int i = 0; i < blockNumber; i++) { if (flags[i] == 1) { cout << "Process " << processSize[allocation[i]] << " is allocated" << endl; } } return 0; }
If you execute the above program, then you will get the following result.
Process 1 is allocated Process 2 is allocated Process 3 is allocated
If you have any queries in the tutorial, mention them in the comment section.