Question: The original program that needs to be modified: #include #include #include #define PAGE_NUMBER 0xFFFFF000 #define OFFSET 0x00000FFF int main(int argc, char *argv[]) { int pageNumber,
The original program that needs to be modified:
#include
#include
#include
#define PAGE_NUMBER 0xFFFFF000
#define OFFSET 0x00000FFF
int main(int argc, char *argv[]) {
int pageNumber, offset;
unsigned int entry;
entry = (unsigned int)atoi(argv[1]);
if (argc != 2) {
fprintf(stderr, "Please enter: ./assign4_1 followed by the virtual address");
return -1;
}
printf("The address %d contains: ", entry);
//Mask the page number
pageNumber = (entry & PAGE_NUMBER) >> 12;
offset = entry & OFFSET;
printf("page number = %d ", pageNumber);
printf("offset = %d ", offset);
return 0;
}
The requirements for the problem:

Change your program, Program-1, such that it takes as input an address-space (eg, v= 32- bit), a page-size (eg, s = 4KB), and an address (eg, a = 19986), and returns the page number and the offset number of the input address (eg, p = 4 and d=3602). Both v and s should be powers of 2, s
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
