The CPU and the operating system 17 We'll cover the first one here and the second in the next section. How does the CPU prevent us from accessing memory we're not supposed to access? As I mentioned, modern CPU architectures define some basic concepts by design. Some examples of this are as follows: Virtual memory Page table Page fault Exceptions Privilege level Exactly how this works will differ depending on the specific CPU, so we'll treat them in general terms here. Most modern CPUs have a memory management unit (MMU ). This part of the CPU is often etched on the same dye, even. The MMU's job is to translate the virtual address we use in our programs to a physical address. When the OS starts a process (such as our program), it sets up a page table for our process and makes sure a special register on the CPU points to this page table. Now, when we try to dereference t_ptr in the preceding code, the address is at some point sent for translation to the MMU, which looks it up in the page table to translate it to a physical address in the memory where it can fetch the data. In the first case, it will point to a memory address on our stack that holds the value 100. When we pass in 99999999999999 and ask it to fetch what's stored at that address (which is what dereferencing does), it looks for the translation in the page table but can't find it. The CPU then treats this as a page fault. At boot, the OS provided the CPU with an interrupt descriptor table. This table has a predefined format where the OS provides handlers for the predefined conditions the CPU can encounter. Since the OS provided a pointer to a function that handles page fault, the CPU jumps to that function when we try to dereference 99999999999999 and thereby hands over control to the operating system. The OS then prints a nice message for us, letting us know that we encountered what it calls a segmentation fault. This message will therefore vary depending on the OS you run the code on.