Program to implement simple paging technique

ALGORITHM:
Step 1: Read all the necessary input from the keyboard.
Step 2: Pages – Logical memory is broken into fixed – sized blocks.
Step 3: Frames – Physical memory is broken into fixed – sized blocks.
Step 4: Calculate the physical address using the following
              Physical address = ( Frame number * Frame size ) + offset
Step 5: Display the physical address.
Step 6: Stop .

				
					#include<stdio.h>
#include<conio.h>
main()
{
int np,ps,i;
int *sa;
clrscr();
printf("enter how many pages\n");
scanf("%d",&np);
printf("enter the page size \n");
scanf("%d",&ps);
sa=(int*)malloc(2*np);
for(i=0;i
{
sa[i]=(int)malloc(ps);
printf("page%d\t address %u\n",i+1,sa[i]);
}
getch();
}
				
			
OUTPUT:
Enter how many pages: 5
Enter the page size: 4

Page1 Address: 1894
Page2 Address: 1902
Page3 Address: 1910
Page4 Address: 1918
Page5 Address: 1926

Leave a Reply