I ran into this question in class:
Assume a machine that is 64-bit and has 8GB memory. They use a paged virtual memory where the page size is 4KB. You run the following program:
int main() {
int *ptr = malloc(16);
printf("%pn", ptr);
return 0;
}
and get output:
0x555555756260
We’re to find the virtual page number of the address and the offset.
What I’m thinking is that I first convert that to binary, figure out how many bits and which bits represent the address/offset.
But I’m not sure how to figure out the latter. How can I determine which bits in the address correspond to which?
I’d really love some guidance