CSRU 3595 Operating Systems Dept. of Computer & Info Sciences
Fall 2008 C. Schweikert
Lab Assignment #5 (Memory Assignment)
Due: Friday, November 21
Chapter 8: Main Memory
Programming Problem 8.28
Assume that a system has a 32-bit virtual address with a 4-KB page size. Write a C program that is passed a virtual address (in decimal) on the command line and have it output the page number and offset for the given address. As an example, your program would run as follows:
./a.out 19986
Your program would output:
The address 19986 contains:
page number = 4
offset = 3602Writing this program will require using the appropriate data type to store 32 bits, for example: long unsigned int.
Hints for program.
- You will utilize command line arguments, which you did in Lab #1. Remember to include an error statement if the user does not input an address.
- How many bytes are in a 4-KB page? (1 KB in this case is 210 bytes)