HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

Determine page number and offsets for address references

Submitted by: @import:stackexchange-cs··
0
Viewed 0 times
numberaddressoffsetspagedetermineforandreferences

Problem

I'm working on learning operating systems and I've come across a strange question that I don't know how to answer.

The question is:


Assuming a 1-KB page size, what are the page numbers and offsets for
the following address references (provided as decimal numbers)?


21205

The notes and slides I have are very confusing and I can't find anything quite like this from my searches. I understand that a 1KB page size means that it's 2^10 but what do I do after that exactly? Most descriptions I see involve splitting that in half and using the first half as your offset and the other half as the page number but then I see others saying not to do this and my notes, as I mentioned, are useless. I'm sure this is extremely easy but I feel like I've been given only 1/3 of the knowledge needed.

Any help would be greatly appreciated!

Addendum

I took a step back for a little while and I think I realized where my confusion was coming from.

I determined that 21,205 is within the range of 2^15, so it's a fifteen bit number. If I subtract the size of the page (10) from the size of the number (15) then that should, in theory, give me a page number of 10 and an offset of 5.

The next bit is pure speculation on my part but I'm assuming that I then take the decimal form of 21,205, which is 101001011010101, and segment it accordingly. The first ten bits (1010010110) equals 662 and the last five bits (10101) equals 21.
So my tentative answer is

Page Number = 662 & Offset = 21.

Is this at all reasonable or do I do it completely wrong?

Solution

You got it a little mix up and wrong

Page number = logical address / page size in this case is $\frac{21205}{1024} = 20$

Offset = logical address mod page size in this case is $21205 \mod 1024 = 725$

Sources:

http://www.yorku.ca/pkashiya/cse1520/Paged%20memory%20technique.htm
http://www2.cs.uregina.ca/~hamilton/courses/330/notes/memory/paging.html

Context

StackExchange Computer Science Q#124826, answer score: 2

Revisions (0)

No revisions yet.