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

📄 main.cpp

📁 在VC环境下编写的操作系统中的模拟虚拟内存操作的算法程序
💻 CPP
字号:
#include <iostream>
#include <string>
#include "pageTable.h"
#include "instruction.h"

void main() { 
	PageTable *pageTable[7];
	Instruction *instruction[5];

	pageTable[0] = new PageTable(0,true,5,11);
	pageTable[1] = new PageTable(1,true,8,12);
	pageTable[2] = new PageTable(2,true,9,13);
	pageTable[3] = new PageTable(3,true,1,21);
	pageTable[4] = new PageTable(4,false,0,22);
	pageTable[5] = new PageTable(5,false,0,23);
	pageTable[6] = new PageTable(6,false,0,121);

	instruction[0] = new Instruction("+",0,70);
	instruction[1] = new Instruction("-",1,50);
	instruction[2] = new Instruction("*",2,15);
	instruction[3] = new Instruction("+",5,23);
	instruction[4] = new Instruction("-",6,40);

	int instructionNum = sizeof(instruction)/4;

	for(int i=0;i<instructionNum;i++) {
	
		int pageNO = instruction[i]->getPageNumber();
		if(pageTable[pageNO]->getFlag()) {
		
			int phisicalAddress = pageTable[pageNO]->getMainMemNumber()*128
								+ instruction[i]->getUnitNumber();

			cout<<"绝对地址为 "<<phisicalAddress<<endl;
		} else {
		
			cout<<"缺页中断: "<<"*"<<instruction[i]->getPageNumber()<<endl;
		}
	}

}

⌨️ 快捷键说明

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