Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Assume a system has 32-bit virtual memory address with a 4-KB page size. Write a

ID: 3712832 • Letter: A

Question

Assume a system has 32-bit virtual memory address with a 4-KB page size. Write a program that is passed a virtual address (in decimal) and outputs the page number and offset for the given address. The output would look like: The address 19986 contains: Page number = 4 Offset = 3602 Your driver should pass the program three numbers: 19986, 347892, and 5978. Note the program will require using the appropriate data type to store 32 bits. Using an unsigned data type would be a good idea. Worth 5 points. Due by noon the day following the final exam (April 26, 2018). e-mail your program, observations file, and output file to me. The observations should be in a separate attached word or data file. The output should be in a separate attached data file.
Assume a system has 32-bit virtual memory address with a 4-KB page size. Write a program that is passed a virtual address (in decimal) and outputs the page number and offset for the given address. The output would look like: The address 19986 contains: Page number = 4 Offset = 3602 Your driver should pass the program three numbers: 19986, 347892, and 5978. Note the program will require using the appropriate data type to store 32 bits. Using an unsigned data type would be a good idea. Worth 5 points. Due by noon the day following the final exam (April 26, 2018). e-mail your program, observations file, and output file to me. The observations should be in a separate attached word or data file. The output should be in a separate attached data file.
Assume a system has 32-bit virtual memory address with a 4-KB page size. Write a program that is passed a virtual address (in decimal) and outputs the page number and offset for the given address. The output would look like: The address 19986 contains: Page number = 4 Offset = 3602 Your driver should pass the program three numbers: 19986, 347892, and 5978. Note the program will require using the appropriate data type to store 32 bits. Using an unsigned data type would be a good idea. Worth 5 points. Due by noon the day following the final exam (April 26, 2018). e-mail your program, observations file, and output file to me. The observations should be in a separate attached word or data file. The output should be in a separate attached data file.

Explanation / Answer

#include <stdio.h>

int main(int argc, char *argv[])

{

unsigned long page;

unsigned long offset;

unsigned long address;

address= atoll(argv[1]);

/* Page Number = quotient of address / 4KB and offset = remainder*/

/*Below is the faster method of calculating the same*/

page = address >> 12; /* Since page size is 4KB => 12 bits holding the virtual address*/

offset = address & 0xfff;

printf("The address %lu contains: ", address);

printf("page number = %lu ",page);

printf("offset = %lu ", offset);

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote