This repository contains a C-based paging simulator designed to implement and demonstrate the paging memory management technique. The simulator dynamically adapts to various configurations of logical and physical memory, page sizes, and degrees of multiprogramming.
- Simulates paging in memory management for configurable physical and logical memory sizes.
- Supports dynamic page sizes and degrees of multiprogramming.
- Parses binary files to load process code and data segments.
- Implements page table management for each process.
- Handles memory allocation, fragmentation, and free frame management.
- Provides detailed output, including memory dumps, free frame lists, and internal fragmentation.
Before running the simulator, ensure the following dependencies are installed:
- GCC compiler: To compile the simulator and utilities.
- Make: For building the project using the Makefile.
Start by cloning the repository to your local machine:
git clone https://github.com/samiyaalizaidi/Paging-Simulator.git
cd Paging-Simulator
To compile the simulator, use the provided Makefile
:
make
The simulator accepts the following command-line arguments:
./paging <physical memory size in B> <logical address size in bits> <page size in B> <path to process 1 file> <path to process 2 file> ... <path to process n file>
Example:
./paging 1048576 12 1024 "p1.proc" "./processes/p2.proc" "p3.proc"
This example runs the simulator with:
- 1 MB of physical memory.
- 12-bit logical address size.
- 1 KB page size.
- Processes loaded from
p1.proc
,./processes/p2.proc
, andp3.proc
.
.
├── README.md
├── LICENSE
├── Makefile
├── paging.c
└── process_generator.c
Process files should follow this binary structure:
- Process ID (1 byte)
- Code Segment Size (2 bytes)
- Code Segment (variable size based on the code segment size)
- Data Segment Size (2 bytes following the code segment)
- Data Segment (variable size based on the data segment size)
- End of Process (1 byte,
0xFF
)
You can use the process_generator.c
file in this repository to generate valid process files conforming to the specified format.
Compile the process generator:
gcc -o process_generator process_generator.c
Run it to create a process file:
./process_generator
- Memory Dump: Displays the mapping of logical pages to physical frames for each process.
- Free Frame List: Shows available frames in memory.
- Internal Fragmentation: Reports total unused space in memory allocations.
- Ensures binary files conform to the specified format.
- Gracefully handles malformed inputs or missing end-of-process markers (
0xFF
).
All code in this repository was written by Samiya Ali Zaidi.