A simulated memory allocation program written in C++ (using the BF algorithm), NUAA 2018 OS mini-job
The program should run on Unix, Windows compatibility is uncertain
Compile using cmake in the project root directory:
cmake .
Make target:
make
./malloc_simulator
If not, try first:
chmod 777 ./malloc_simulator
Based on the idea of cli, it is equivalent to a dedicated small terminal, you can operate it directly in it:
welcome to malloc-simulator(best-fit), enter 'help' to get some help!
malloc-simulator$
For example, this is your user interface, here is a list of all the instructions:
// 设置总内存大小 [内存大小]
setMemSize [memSize]
// 显示当前内存使用情况
showMemInfo
// 显示当前进程信息
showProcess
// 新建进程 [进程名] [分配内存大小]
newProcess [processName] [processMemSize]
// 删除进程 [进程编号pid]
deleteProcess [pid]
// 寻求帮助
help
// 关于
about
// 重置当前内存
reset
Preferentially match the memory blocks that are most suitable for the current thread and use them to avoid waste, but the BF algorithm is not the optimal algorithm
Use three linked lists, one is the allocated memory linked list, one is the free memory linked list, and the other is the process table