AIM:
To write a C program to implement paging concept for memory management.
ALGORIHTM:
Step 1: Start the program.
Step 2: Enter the logical memory address.
Step 3: Enter the page table which has offset and page frame.
Step 4: The corresponding physical address can be calculate by,
PA = [ pageframe* No. of page size ] + Page offset.
Step 5: Print the physical address for the corresponding logical address.
Step 6: Terminate the program.
PROGRAM:
#include
int main()
{
int lpage[10], pagetab[10], pframe[2][2], I,j;
int size, msize, cnt, t,k,pos,logadd,m=0;
int frameno;
long int l;
int i;
printf("\nEnter the memory size:");
scanf("%d", &msize);
printf("Enter the pase size:");
scanf("%d", &size);
cnt=(msize/size);
printf("\nEnter the logical page: ");
for(j=0;j
{
scanf("%d", &lpage[j]);
}
t=0;
k=0;
for(j=0;j
{
printf("\n");
if(t
{
printf("%d value is %d\n", t,lpage[j]);
t++;
}
else
{
t=0;
printf("%d value is %d\n", t,lpage[j]);
t++;
}
}
printf("\nEnter the page table value: ");
for(i=0;i
{
scanf("%d", &pagetab[i]);
}
printf("\nEnter the logical address: ");
scanf("%d", &logadd);
for(k=0;k
{
if(logadd==lpage[k])
{
pos=(k/size);
m=k%size;
break;
}
else
continue;
}
printf("\nPage number : %d", pos);
frameno=pagetab[pos];
printf("\nThe frame number is %d\n", frameno);
printf("\nThe corresponding physical address is %d", (frameno*size)+m);
}
SAMPLE OUTPUT:
[it65@AntiViruS ~]$ cc paging.c
[it65@AntiViruS ~]$ ./a.out
Enter the memory size:4
Enter the page size:2
Enter the logical page: 2
3
4
5
0 value is 2
1 value is 3
0 value is 4
1 value is 5
Enter the page table value: 101
102
Enter the logical address: 5
Page number : 1
The frame number is 102
The corresponding physical address is 205
RESULT:
Thus C program for implementing paging concept for memory management has been executed successfully.
2 comments:
sucks actually because for(j=0;j.... then what ? this is partial program.
what fuck dude do you really programming or playing around to fool people coz all your for loops and headers are partially written are u playing fill in the blanks with us.
Post a Comment