Page organization of memory

There were difficulties in understanding the representation of memory.

Task: Let's say you have an architecture with a 32-bit logical address space (i.e., a logical address is a 32-bit number). The architecture uses a 2-level page table, i.e. the logical address is divided into three sections: two indexes in the page table and an offset (exactly as it was in the example on the slides).

And in the tables at each level of the table of pages exactly 1024 records (respectively, the index in each table takes 10 bits), and you use pages with a size of 4096 bytes (i.e., the offset is a 12-bit number, it is easy to see that together we get 32 bits = 10 + 10 + 12).

Attention question (you do not need to answer it specifically): if the process uses only two sections of the logical address space: 4MB, starting from the logical address 0x0, and 2MB, starting from the address 0xbfe00000, then how many records in the root table will be point to next-level tables? enter a description of the image here

My understanding of this task is (please specify and correct the errors):

1) Lvl1 and Lvl0 index occupy 10 bits each, Offset 12.

2) Each table designated Level Num contains 1024 entries of something and indexes of 10 bits (in the scheme, only 10 bits are specified in the size of each cell. It is assumed that there are still + n bits). This means that the indexes occupy 1024*10/8 bytes, which is equal to 1280 bytes. The total table size is 4096 bytes, so some other data of the size of 2816 bytes is stored in the table.

3)At this point, a stupor. I don't understand how to link these 4MB and logical addresses with the information above.

Please explain the principle of memory operation and give an explanation for the solution of the task. Specifically, I ask you not to write the solution of the task, because my goal is to understand, and then give the answer myself.

Author: AlexIdest, 2018-12-08

1 answers

Since we have only two tables by the task condition, we need to find out how many records pointing to the Lvl 0 table are required in the root table (aka Lvl 1).

How much does the Lvl 0 table describe ? Each table has 1024 entries, each entry describes a single page of 4096 bytes. 1024*4096 = 4 MB.

We need to describe 6 Mb by the condition of the problem. If one Lvl 0 table can describe 4Mb, then we need at least 2 such tables. So, you need two records from root table Lvl 1.

Thank you Mike for explaining in the comments about my interpretation of the problem and its solution:

By the way, the tables themselves do not take up 4096 bytes. For example in x86 processors in 32-bit mode, one table occupies 32Kb, 1024 entries of 32 bits each. But this has nothing to do with your task, since the pages themselves are in physical memory. And the need to describe the memory itself in the tables tables, to access it, the OS is clearly outside the scope of the task, because the issues of creating the tables themselves are not covered in the task. If they had to be taken into account, then the problem would say what size one of them is. table entry lvl0

 0
Author: AlexIdest, 2018-12-08 08:41:38