欢迎来到天天文库
浏览记录
ID:42854890
大小:47.00 KB
页数:5页
时间:2019-09-22
《请求页式存储管理的模拟实现_参考代码》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、do_init(){inti,j;srand(time(NULL));for(i=0;i2、break;case2:pageTable[i].proType=EXECUTABLE;break;case3:pageTable[i].proType=READABLEIWRITABLE;break;case4:pageTable[i].proType=READABLEIEXECUTABLE;break;case5:pageTable[i].proType=WRITABLEIEXECUTABLE;break;case6:pageTable[i].proType=READABLEIWRITABLEIEXECU3、TABLE;break;default:break;pageTable[i].auxAddr=i*PAGE_SIZE*2;〃逻辑页的外存地址}for(j=0;j4、e0:ptr_memAccReq.reqType=REQUEST_READ;info.Format(_T("产生请求:类型:读取t”));out->SetSel(-l,-1);out->ReplaceSel(info);break;case1:ptr_memAccReq.reqType=REQUEST_WRITE;ptr_memAccReq.value=rand()%OxFFu;info.Format(_T("产生请求:类型:写入t值:%02xt"),ptr_memAccReq.valu5、e);out->SetSel(-l,-1);out->ReplaceSel(info);break;case2:ptr_memAccReq.reqType=REQUEST_EXECUTE;info.Format(_T("产生请求:类型:执行t”));out->SetSel(-l,-1);out->ReplaceSel(info);break;default:break;}}do_response(){Ptr_PageTableItemptr_pageTabIt;unsignedintpageNum^6、offAddr;unsignedintactAddr;CStringinfo;if(ptr_memAccReq.virAddr=VIRTUAL_MEMORY_SIZE){do_error(ERROR_OVER_BOUNDARY);return;}pageNum=ptr_memAccReq.virAddr/PAGE_SIZE;offAddr=ptr_memAccReq.virAddr%PAGE_SIZE;info.Format(_T(u页号:%ut页内偏移:7、%u"),pageNum,offAddr);out->SetSel(-l,-1);out->ReplaceSel(info);ptr_pageTabIt=&pageTable[pageNum];if(!ptr_pageTabIt->effective)do_page_fault(ptr_pageTabIt);else{info.Format(_T(”页面在内存,不用调页”));out->SetSel(-l,-1);out->ReplaceSel(info);}actAddr=ptr_pageTab8、It->blockNum*PAGE_SIZE+offAddr;info.Format(_T(”实地址为:%u"),actAddr);out->SetSel(-l,-1);out->ReplaceSel(info);switch(ptr_memAccReq.reqType){caseREQUEST_READ:ptr_pageTabIt->count++;if(!(ptr_pageTabIt->pr
2、break;case2:pageTable[i].proType=EXECUTABLE;break;case3:pageTable[i].proType=READABLEIWRITABLE;break;case4:pageTable[i].proType=READABLEIEXECUTABLE;break;case5:pageTable[i].proType=WRITABLEIEXECUTABLE;break;case6:pageTable[i].proType=READABLEIWRITABLEIEXECU
3、TABLE;break;default:break;pageTable[i].auxAddr=i*PAGE_SIZE*2;〃逻辑页的外存地址}for(j=0;j4、e0:ptr_memAccReq.reqType=REQUEST_READ;info.Format(_T("产生请求:类型:读取t”));out->SetSel(-l,-1);out->ReplaceSel(info);break;case1:ptr_memAccReq.reqType=REQUEST_WRITE;ptr_memAccReq.value=rand()%OxFFu;info.Format(_T("产生请求:类型:写入t值:%02xt"),ptr_memAccReq.valu5、e);out->SetSel(-l,-1);out->ReplaceSel(info);break;case2:ptr_memAccReq.reqType=REQUEST_EXECUTE;info.Format(_T("产生请求:类型:执行t”));out->SetSel(-l,-1);out->ReplaceSel(info);break;default:break;}}do_response(){Ptr_PageTableItemptr_pageTabIt;unsignedintpageNum^6、offAddr;unsignedintactAddr;CStringinfo;if(ptr_memAccReq.virAddr=VIRTUAL_MEMORY_SIZE){do_error(ERROR_OVER_BOUNDARY);return;}pageNum=ptr_memAccReq.virAddr/PAGE_SIZE;offAddr=ptr_memAccReq.virAddr%PAGE_SIZE;info.Format(_T(u页号:%ut页内偏移:7、%u"),pageNum,offAddr);out->SetSel(-l,-1);out->ReplaceSel(info);ptr_pageTabIt=&pageTable[pageNum];if(!ptr_pageTabIt->effective)do_page_fault(ptr_pageTabIt);else{info.Format(_T(”页面在内存,不用调页”));out->SetSel(-l,-1);out->ReplaceSel(info);}actAddr=ptr_pageTab8、It->blockNum*PAGE_SIZE+offAddr;info.Format(_T(”实地址为:%u"),actAddr);out->SetSel(-l,-1);out->ReplaceSel(info);switch(ptr_memAccReq.reqType){caseREQUEST_READ:ptr_pageTabIt->count++;if(!(ptr_pageTabIt->pr
4、e0:ptr_memAccReq.reqType=REQUEST_READ;info.Format(_T("产生请求:类型:读取t”));out->SetSel(-l,-1);out->ReplaceSel(info);break;case1:ptr_memAccReq.reqType=REQUEST_WRITE;ptr_memAccReq.value=rand()%OxFFu;info.Format(_T("产生请求:类型:写入t值:%02xt"),ptr_memAccReq.valu
5、e);out->SetSel(-l,-1);out->ReplaceSel(info);break;case2:ptr_memAccReq.reqType=REQUEST_EXECUTE;info.Format(_T("产生请求:类型:执行t”));out->SetSel(-l,-1);out->ReplaceSel(info);break;default:break;}}do_response(){Ptr_PageTableItemptr_pageTabIt;unsignedintpageNum^
6、offAddr;unsignedintactAddr;CStringinfo;if(ptr_memAccReq.virAddr=VIRTUAL_MEMORY_SIZE){do_error(ERROR_OVER_BOUNDARY);return;}pageNum=ptr_memAccReq.virAddr/PAGE_SIZE;offAddr=ptr_memAccReq.virAddr%PAGE_SIZE;info.Format(_T(u页号:%ut页内偏移:
7、%u"),pageNum,offAddr);out->SetSel(-l,-1);out->ReplaceSel(info);ptr_pageTabIt=&pageTable[pageNum];if(!ptr_pageTabIt->effective)do_page_fault(ptr_pageTabIt);else{info.Format(_T(”页面在内存,不用调页”));out->SetSel(-l,-1);out->ReplaceSel(info);}actAddr=ptr_pageTab
8、It->blockNum*PAGE_SIZE+offAddr;info.Format(_T(”实地址为:%u"),actAddr);out->SetSel(-l,-1);out->ReplaceSel(info);switch(ptr_memAccReq.reqType){caseREQUEST_READ:ptr_pageTabIt->count++;if(!(ptr_pageTabIt->pr
此文档下载收益归作者所有