0% found this document useful (0 votes)
50 views2 pages

Program: ABES Engineering College

This document contains the source code for a C program that simulates the mapping of virtual to physical addresses using a page table. The program takes the size of a process in KB as input, calculates the number of pages needed, then takes a relative address as input. It uses the relative address to determine the page number and offset. The page number is used to index into a sample page table to retrieve the corresponding frame number. The frame number and offset are then printed as the equivalent physical address.

Uploaded by

jhalak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views2 pages

Program: ABES Engineering College

This document contains the source code for a C program that simulates the mapping of virtual to physical addresses using a page table. The program takes the size of a process in KB as input, calculates the number of pages needed, then takes a relative address as input. It uses the relative address to determine the page number and offset. The page number is used to index into a sample page table to retrieve the corresponding frame number. The frame number and offset are then printed as the equivalent physical address.

Uploaded by

jhalak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Roll No.

:
Date: ..... Page No.: ..

Practical Name: ......


. Practical No.: .

PROGRAM
#include<stdio.h>
#include<math.h>
main()
{
int size,m,n,pgno,pagetable[3]={5,6,7},i,j,frameno;
double m1;
int ra=0,ofs;
clrscr();
printf(Enter process size (in KB of max 12KB):);/*reading
memeory size*/
scanf(%d,&size);
m1=size/4;
n=ceil(m1);
printf(Total No. of pages: %d,n);
printf(\nEnter relative address (in hexadecimal
notation eg.0XRA) \n);
//printf(The length of relative Address is : 16 bits \n\n The size
of offset is :12 bits\n);
scanf(%d,&ra);
pgno=ra/1000; /*calculating physical address*/
ofs=ra%1000;
printf(page no=%d\n,pgno);
printf(page table);
for(i=0;i<n;i++)
printf(\n %d [%d],i,pagetable[i]);
frameno=pagetable[pgno];
printf(\n Equivalent physical address : %d%d,frameno,ofs);
}

ABES Engineering College


Sign of Faculty with date
Roll No.:
Date: ..... Page No.: ..

Practical Name: ......


. Practical No.: .

OUTPUT

ABES Engineering College


Sign of Faculty with date

You might also like