OS & Hardware
What generally happens when a program accesses an address the OS has not allocated?
- AThe CPU automatically adds new physical memory for that address
- BThe access is ignored, and the program continues to the next instruction as if nothing happened
- CA page fault occurs, and the OS judges it an illegal access and stops the program
Show answer and explanation
Answer: C. A page fault occurs, and the OS judges it an illegal access and stops the program
Accessing an unallocated address finds no valid page-table entry, so a page fault occurs. The OS checks whether the address lies in a region the process is allowed to use, and if it is allocated nowhere, it signals an error and stops the program (a so-called segmentation fault). This keeps stray pointers from corrupting other processes or the OS. Physical memory is not added automatically, and the access is not silently ignored.
- A. Physical memory is never added automatically.
- B. Silently ignoring it would hide the bug.
- C. Correct. On the page fault, the OS stops the program for an illegal access.