I am trying to grok page layouts according to these notes, having just started to learn about operating systems, so it's a bit over my head atm. Specifically it says this:
In linux there are 4 'levels' of page tables. A table consists of an array of entries of type pXX_t, wrapping a pXXval_t:
- Page Global Directory (PGD) -
pgd_t/pgdval_t
.- Page Upper Directory (PUD) -
pud_t/pudval_t
.- Page Middle Directory (PMD) -
pmd_t/pmdval_t
.- Page Table Entry directory (PTE) -
pte_t/pteval_t
.These types are simply typedef'd wrappers around fundamental architecture-dependent types, gathering all the x86-64 types together...
Then they draw this:
6 5 4 3 2 1
4321098765432109876543210987654321098765432109876543210987654321
0000000000000000000000000000000000000000101100010111000000010000
[ RESERVED ][ PGD ][ PUD ][ PMD ][ PTE ][ OFFSET ]
| | | |-PAGE_SHIFT
| | |-----------PMD_SHIFT
| |--------------------PUD_SHIFT
|---------------------------PGDIR_SHIFT
It's still over my head, particularly with all the abbreviations and such.
Could one explain in slightly gentler terms what exactly we have here? I would like to implement virtual memory pagination in a JS operating system, to simulate sort of a realistic operating system. I would like to know what structs are being used and how they actually look in the memory itself (or if done by assembly, whatever is easier to use to explain/teach).
So right at the moment I am trying to figure out how (in JavaScript), to use 1 array to manage all of the memory of multiple processes. No cheating and using other JavaScript arrays or objects or whatever else, only 1 array, and then integers pretty much. I am stuck at trying to figure out how I can create an array (a slice of memory) in memory, without using arrays haha. Then to make it more complicated, I need to make pages in this 1 array, which map to the sections of memory that are allowed per process. I am trying to figure out in detail how to do this, and these notes are the closest I've come to seeing it done realistically, but they are a bit too detailed atm. Wondering if one could help simplify the explanation just a little, and to help paint the picture of how to create the pages/process mappings in a single array. Explaining this Linux system would help to visualize this.