x86 Paging Tutorial / Page faults Updated 2025-07-16
What if Process 1 tries to access 0x00003000, which is not present?
The hardware notifies the software via a Page Fault Exception.
When an exception happens, the CPU jumps to an address that the OS had previously registered as the fault handler. This is usually done at boot time by the OS.
This could happen for example due to a programming error:
int *is = malloc(1);
is[2] = 1;
but there are cases where it is not a bug, for example in Linux when:
  • the program wants to increase its stack.
    It just tries to accesses a certain byte in a given possible range, and if the OS is happy it adds that page to the process address space, otherwise, it sends a signal to the process.
  • the page was swapped to disk.
    The OS will need to do some work behind the processes back to get the page back into RAM.
    The OS can discover that this is the case based on the contents of the rest of the page table entry, since if the present flag is clear, the other entries of the page table entry are completely left for the OS to to what it wants.
    On Linux for example, when present = 0:
    • if all the fields of the page table entry are 0, invalid address.
    • else, the page has been swapped to disk, and the actual values of those fields encode the position of the page on the disk.
In any case, the OS needs to know which address generated the Page Fault to be able to deal with the problem. This is why the nice IA32 developers set the value of cr2 to that address whenever a Page Fault occurs. The exception handler can then just look into cr2 to get the address.
The exact format of table entries is fixed by the hardware.
Each page entry can be seen as a struct with many fields.
The page table is then an array of struct.
On this simplified example, the page table entries contain only two fields:
bits   function
-----  -----------------------------------------
20     physical address of the start of the page
1      present flag
so in this example the hardware designers could have chosen the size of the page table to b 21 instead of 32 as we've used so far.
All real page table entries have other fields, notably fields to set pages to read-only for Copy-on-write. This will be explained elsewhere.
It would be impractical to align things at 21 bits since memory is addressable by bytes and not bits. Therefore, even in only 21 bits are needed in this case, hardware designers would probably choose 32 to make access faster, and just reserve bits the remaining bits for later usage. The actual value on x86 is 32 bits.
Here is a screenshot from the Intel manual image "Formats of CR3 and Paging-Structure Entries with 32-Bit Paging" showing the structure of a page table in all its glory: Figure 1. "x86 page entry format".
Figure 1.
x86 page entry format
.
The fields are explained in the manual just after.
Aufbau principle Updated 2025-07-16
Boring rule that says that less energetic atomic orbitals are filled first.
Much more interesting is actually determining that order, which the Madelung energy ordering rule is a reasonable approximation to.
For each process, the virtual address space looks like this:
------------------ 2^32 - 1
Stack (grows down)
v v v v v v v v v
------------------

(unmapped)

------------------ Maximum stack size.


(unmapped)


-------------------
mmap
-------------------


(unmapped)


-------------------
^^^^^^^^^^^^^^^^^^^
brk (grows up)
-------------------
BSS
-------------------
Data
-------------------
Text
-------------------

------------------- 0
The kernel maintains a list of pages that belong to each process, and synchronizes that with the paging.
If the program accesses memory that does not belong to it, the kernel handles a page-fault, and decides what to do:
  • if it is above the maximum stack size, allocate those pages to the process
  • otherwise, send a SIGSEGV to the process, which usually kills it
When an ELF file is loaded by the kernel to start a program with the exec system call, the kernel automatically registers text, data, BSS and stack for the program.
The brk and mmap areas can be modified by request of the program through the brk and mmap system calls. But the kernel can also deny the program those areas if there is not enough memory.
brk and mmap can be used to implement malloc, or the so called "heap".
mmap is also used to load dynamically loaded libraries into the program's memory so that it can access and run it.
Calculating exact addresses Things are complicated by:
Comedian Updated 2025-07-16
If you can reduce a mathematical problem to the Halting problem of a specific turing machine, as in the case of a few machines of the Busy beaver scale, then using Turing machine deciders could serve as a method of automated theorem proving.
That feels like it could be an elegant proof method, as you reduce your problem to one of the most well studied representations that exists: a Turing machine.
However it also appears that certain problems cannot be reduced to a halting problem... OMG life sucks (or is awesome?): Section "Turing machine that halts if and only if Collatz conjecture is false".
How to teach Updated 2025-07-16
Off-the-shelf techniques to become a teaching superhero.
Customized website idea at: OurBigBook.com.
Industry Updated 2025-07-16
Universal basic income Updated 2025-07-16
Unconditional basic income is Ciro Santilli's ultimate non-transhumanist technological dream: to reach a state of technological advancement and distribution of resources so high that everyone gets money for doing nothing, enough for:
  • basic survival needs: food, housing, clothes, hygiene, etc.
  • two children to keep the world going. Or immortality tech, but is harder and borderline transhumanist :-)
  • high speed computer and Internet
Once a person has that, they can "learn, teach" and create whatever they want. Or play video games all day long if they wish.
Ciro Santilli will not live to see this, and is content with helping it happen faster by increasing the efficiency of the world as. And having at least two well educated kids to carry on the project after he dies :-)
Technologies which would help a lot towards unconditional basic income, and might be strictly required required are:
So in the worst case we can just grow brainless bodies and replace the cavity hole with a computer that controls the body, possibly with high level decisions coming from a remote building-sized genetically engineered biological AGI brain.
Of course, it is all about costs. A human costs about 130k 2010 USD/year. So how cheap can we make the AGI / robot human equivalent / year for a given task?
AGI + humanoid robots likely implies AI takeover though. It would then come down to human loving bots vs human hating bots fighting it out. It will be both terrifying and fun to watch.
AGI alone would be very dangerous, in case it can get control of our nuclear arsenals through software zero days or social engineering. Although some claim that is unlikely.
Humanity's best bet to achieve silicon AGI today is to work on: Ciro's 2D reinforcement learning games.
By Charles Bukowski mentioned e.g. at tatyanany.medium.com/slavery-was-never-abolished-it-was-only-extended-to-include-all-the-colors-6ca21d586e7e:
Slavery was never abolished, it was only extended to include all the colors.
Bibliography:
Video 1.
Easy street by Stan Kenton and June Christy (1945)
Source. TODO exact lyrics for copy paste? There seem to be several variants, and I don't have the patience to transcribe. Close enough: lyricsplayground.com/alpha/songs/e/easystreet.html. Except that with UBI there won't be a:
guy that you can hire to plant trees so you can have shade
because most people will have something better to do. That's where artificial general intelligence comes in!
x86 Paging Tutorial / Segmentation Updated 2025-07-16
In x86 systems, there may actually be 2 address translation steps:
  • first segmentation
  • then paging
like this:
(logical) ------------------> (linear) ------------> (physical)
             segmentation                 paging
The major difference between paging and segmentation is that:
  • paging splits RAM into equal sized chunks called pages
  • segmentation splits memory into chunks of arbitrary sizes
Paging came after segmentation historically, and largely replaced it for the implementation of virtual memory in modern OSs.
Paging has become so much more popular that support for segmentation was dropped in x86-64 in 64-bit mode, the main mode of operation for new software, where it only exists in compatibility mode, which emulates IA-32.
Figure 1.
Tower of Babel by Pieter Bruegel the Elder (1563)
Source.
Even the Bible writers already know that multiple languages suck as seen from the Tower of Babel parable
Isn't it incredibly fitting that the building of the European Parliament looks like the Tower of Babel?
The fact that in poor countries a huge number of people do not speak the economically dominating language of the world, the lingua franca, English as of 2020, is a major obstacle to the development of those countries.
Despite us being in the information age, the people in those countries cannot fully benefit from it at all!
Teaching its people English should be the number one priority of any country. Without that, there can be no technological development. Everything else is secondary and can be learnt off the Internet once you know English.
And the most efficient way to do that, is that every country should create amazing free open source English learning material for their own language.
European countries are perhaps the most perfect example of how many languages destroy once powerful countries: Section "European Tower of Babel"
The Sapir–Whorf hypothesis is bullshit outside of poetry, and the ending of Arrival (2016) makes one want to puke, where learning a language changes not only your brain, but also Ciro's precious "laws" of Physics!
Much more likely are To Serve Man/A Small Talent for War events which we have already seen countless times!
Remember that those ideas come from a person who speaks 3.5 languages in 2019, and sees absolutely no practical difference between them.
Of course, like all non-constructed languages, English is not fully optimal in terms of regularity and information density. It could be argued that other languages are better in those aspects.
For example, Ciro does believe that spoken Chinese is a better language than English overall from a purely "ease of learning from scratch point of view" as mentioned at: github.com/cirosantilli/china-dictatorship/tree/6fdeb5aa3826c69f7c058de4e6f652a6924bc08a#does-ciro-santilli-speak-chinese. Chinese writing is completely insane of course, completely out of the question.
However, Ciro just doesn't think that the difference is that great to justify replacing English which is already dominant. How much more efficient can a perfect constructed language be than English? 1.01? 1.001? Such margins don't matter. Once you have learnt it young, it's done, for good.
English-based a posteriori constructed languages that regularize English further are perhaps the only reasonable alternative, like how C++ evolved from C by creating a low cost upgrade path. Although in practice they will never take off unless a dictatorship rules the world:
One interesting anecdote is that Ciro met his wife in French, and talking to her primarily in English feels really weird, so language does matter in love.
Different languages might also good at producing interesting diverse touristic locations, with different diverse and interesting foods. Because that's what tourism is all about. The exotic. The unique. And therefore, also necessarily the inefficient.
People with similar ideas:
Video 1.
English spelling - a bit mad, but perhaps the best system around by Lindybeige (2015)
Source. To be taken as a semi-joke, but he does mention the interesting point that English insane spelling helps disambiguate reading, like an intermediate between Chinese characters and more regular spelled languages.
The bullying of young Ciro Santilli Updated 2025-07-16
When Ciro Santilli was very young, about 6, he was a fatty, and other evil boys picked on him.
Ciro was even more stupid than as of 2020, and continued to try and hang out with those evil kids to show them he was cool too or that he was strong, and so continued to get hurt.
Advice to his children: stay away from evil people.
The bullied sometimes feels an almost masochistic desire to overcome the bullies' contempt, and to try and either become friends with the bullies, or to overpower them.
You must never give into those thoughts.
If you come across evil people, smile a fake smile to them, and walk away, but never give your back to them, and always be ready to fight.
If they laugh at you, know that you are shit like everyone else, pretend to laugh with them, take their post and repost it on your public profile, and silently stay away from those idiots.
Never show any weakness.
If a fight is likely, always be ready, always have your friends nearby, be as well armed as the enemy, and never be outnumbered.
On the Internet, never care about e-bully posts, either block them immediately, and anyone that likes their posts, or follow Ciro's reply policy.
Call parents or other authorities as soon as there is risk of physical harm. Better a living free pussy than dead or in youth detention for murder. Similar advice applies if you are going to jail I guess.
The Sikh knife, the Kirpan, which Sikhs must carry at all times as a religious obligation, also comes to mind. The Sikh must have been bullied out of the their minds at some point in history, Ciro understands.
Non-violence only works when you have bodies to spare from your followers.
Perhaps it was good to learn those lessons early, before the stakes were too high. Adults fake it much better, and therefore it is harder to learn those lessons from them, but they are still just as evil on the inside.

There are unlisted articles, also show them or only show them.