A C program designed to generate and demonstrate pagefaults intentionally. This project serves as an educational tool to help understand how operating systems manage virtual memory, handle page faults, and swap pages between RAM and disk.
This project was created to provide a practical insight into the memory management mechanisms of an operating system. By deliberately generating pagefaults, it allows students and developers to visualize and understand the concepts of virtual memory, demand paging, and kernel intervention.
The program works by:
- Accessing a large array that exceeds the available physical memory (RAM).
- Forcing the OS to continuously swap pages in and out from the disk (swap area).
- Generating a high rate of pagefaults, which can be observed using tools like
top
,htop
, orvmstat
.
- A GCC compiler (e.g.,
build-essential
on Ubuntu) - A Linux-based operating system (for specific OS features)
Compile the source code using GCC:
gcc -o pagefault_gen pagefault.c