⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 memory.cpp

📁 模拟64M的内存的动态管理,包括分配.回收.操作系统实验课程设计题目
💻 CPP
字号:
// Memory.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include "MyMemory.h"



int main(int argc, _TCHAR* argv[])
{
	
	CMyMemory memory;
	char cmd[256];
	int  pos;
	int  size;
	
	while(1)
	{
		printf("#>");
		cin>>cmd;
		if(!strcmp(cmd,"showdetail"))
		{
			memory.ShowDetail();
		}
		else if(!strcmp(cmd,"allocation"))
		{
			cout<<"size:";
			cin>>size;
			memory.Allocation(size);
			memory.ShowDetail();
		}
		else if(!strcmp(cmd,"release"))
		{
			
			cout<<"Block No:";
			cin>>pos;
			if(pos>=0 && pos<memory.EmptyList.ListSize())
			{
				memory.Release(pos);
				memory.Merge();
			}
		} 
		/*else if(!strcmp(cmd,"merge"))
		{
			memory.Merge();
			memory.ShowDetail();
		}*/
		else if(!strcmp(cmd,"exit"))
		{
			return 0;
		}
		else//(!strcmp(cmd,"help"))
		{
			system("cls");
			cout<<"command error!"<<endl;
			cout<<"[HELP]"<<endl;
			cout<<"allocation\tallocation a block"<<endl;
			cout<<"release\t\trelease a block"<<endl;
			cout<<"merge\t\tmerge blank block"<<endl;
			cout<<"exit\t\texit program"<<endl;
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -