Operating Systems Lab Manual / OS Memory Management Scheme Worst Fit C Program

Program Name Write a C Program for OS Memory Management Scheme Worst Fit
Theory
The operating system manages memory allocation. The operating system 
divides the memory into several fixed-sized partitions and each partition
may contain exactly one process. 

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.

Operating system keeps a table indicating which parts of memory are 
available and which are occupied.

Finally, when a process arrives and needs memory, a memory section 
large enough for this process is provided. When it is time to load 
or swap a process into main memory, and if there is more than one 
free block of memory of sufficient size, then the operating system 
must decide which free block to allocate. 

Worst-Fit chooses the largest available block.
Program
Input
	Memory Management Scheme - Worst Fit
Enter number of blocks:3
Enter number of files:2

Enter size of the blocks:
Block 1:5
Block 2:2
Block 3:7

Enter size of the files :
File 1:1
File 2:4
Output
 File No:	 File size :	Block No:	 Block size:	 Fragment
1		1		3		7		6
2		4		1		5		1


Home     Back