This project implements a memory management engine that handles paging and virtual memory. The system simulates a computer's memory management unit, dealing with both main memory and virtual memory, and executes various commands related to process management and memory operations.
- Memory allocation for processes
- Paging system implementation
- Virtual memory management
- Process execution simulation
- Memory swapping (swap-in and swap-out operations)
- Page table management
- LRU (Least Recently Used) replacement algorithm
- Memory Initialization: Sets up main memory and virtual memory based on input parameters.
- Process Management: Handles loading, running, and killing processes.
- Paging System: Implements page tables and manages page allocation.
- Virtual Memory Handling: Manages swapping between main memory and virtual memory.
- Command Interpreter: Processes user commands for system operation.
load <filename1> <filename2> .. <filenameN>
: Load executables into memoryrun <pid>
: Execute a programkill <pid>
: Terminate a programlistpr
: List all processes in memorypte <pid> <file>
: Print page table entries for a processpteall <file>
: Print all page table entriesswapout <pid>
: Move a process to virtual memoryswapin <pid>
: Move a process to main memoryprint <memloc> <length>
: Print values in physical memoryexit
: Terminate the system
- Written in C/C++
- Uses LRU algorithm for page replacement
- Handles both main memory and virtual memory
- Simulates process execution with basic arithmetic operations
Compiling :
g++ -o memoryEngine main.cpp Process.cpp MemoryManager.cpp
Executing :
./memoryEngine -M <main_memory_size> -V <virtual_memory_size> -P <page_size> -i <input_file> -o <output_file>
-
Executable Files:
- Contains programs to be loaded and executed by the memory management system.
- Format:
- First line: Size of the executable in KB
- Subsequent lines: Commands to be executed
- Supported commands in executables:
add x, y, z
: Add contents of addresses x and y, store in zsub x, y, z
: Subtract contents of address y from x, store in zprint x
: Print value at address xload a, y
: Store value 'a' at address y
-
System Command Input File:
- Contains a sequence of system commands to be executed by the memory manager.
- Supported system commands:
load <filename1> <filename2> .. <filenameN>
run <pid>
kill <pid>
listpr
pte <pid> <file>
pteall <file>
swapout <pid>
swapin <pid>
print <memloc> <length>
exit
-
Main Output File:
- Contains the results and messages from executing the system commands.
- Includes:
- Process loading confirmations
- Execution results of programs
- Error messages
- Listings of processes in memory
- Results of memory print commands
-
Page Table Entry Files:
- Generated by
pte
andpteall
commands. - Contains page table information for specified processes.
- Format includes:
- Date and time of the command execution
- Process ID
- Logical page numbers and corresponding physical page numbers
- Generated by