Small C++ console simulator that visualizes paging and heap allocation strategies. It lets you allocate/deallocate memory blocks with first/best/worst fit, map process pages to frames, enqueue requests, and view fragmentation plus basic utilization stats in real time.
- Requires a C++17 compiler (uses
unistd.hfor delays). - From the repo root:
g++ -std=c++17 main.cpp -o imms
- Execute
./imms(orimms.exeon Windows; removeunistd.h/usleepand swap forSleepif needed). - The program redraws the dashboard each tick; ANSI colors are used for clarity.
- Physical Memory Bar: 20 frames (size 5 each) showing which PID owns a frame.
- Page Table: Fixed table for Process 1 (6 entries) mapping pages to frames.
- Stats Panel: Used/free frames, page count, and a simple heatmap of utilization.
- Request Queue: Pending allocation/deallocation requests with FIFO processing.
- Fragmentation Analysis: Total free, block counts, largest block, and ratio.
1Immediate allocate: choose size and strategy (1=First, 2=Best, 3=Worst).2Immediate deallocate by PID.3Allocate N pages for Process 1 (one frame per page).4Fragmentation analysis.5Enqueue allocation request.6Enqueue deallocation request.7Process next queued request.8Run all queued requests automatically (with short delays for visuals).qQuit.
- Memory is a linked list of
memory_blocknodes; splits/merges occur on alloc/free. - Heaps are rebuilt on each request to pick best/worst free blocks quickly.
- Frames are derived from
startoffsets divided byFRAME_SIZE; constants live at the top ofmain.cppfor quick tuning.
| Test Case | Expected Outcome |
|---|---|
| Allocate 10 units using First Fit | first adequate block is selected |
| Allocate using Best Fit on multiple free holes | smallest adequate block is selected |
| Allocate pages for process1 | Frame allocation and page table update |
| Request size larger than any free block | display no suitable block |
| Page Table Overflow | display page table full |
| Deallocate invalid/terminated process | display invalid PID |
| Difference in Best/Worst fit in highly fragmented memory | Best Fit should trigger less of page faults |