欢迎来到天天文库
浏览记录
ID:57333027
大小:41.50 KB
页数:7页
时间:2020-08-12
《操作系统实验报告三存储器管理实验.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、课程名:操作系统地点:姓名:班级:学号:成绩项目: 存储器管理实验目的要求一.理解内存页面调度的机理二.掌握几种理论页面置换算法的实现方法三.了解HASH表数据结构的使用四.通过实验比较各种调度算法的优劣一.Page.h文件#ifndef_PAGE_H#define_PAGE_Hclasscpage{public:intm_nPageNumber,m_nPageFaceNumber,m_nCounter,m_nTime;};#endif二.Memory.h文件#ifndef_MEMORY_H#define_MEMORY_HclassCMemory{public:CMemory();v
2、oidinitialize(constintnTotal_pf);voidFIFO(constintnTotal_pf);voidLRU(constintnTotal_pf);voidNUR(constintnTotal_pf);voidOPT(constintnTotal_pf);private:vector_vDiscPages;vector_vMemoryPages;CPageControl*_pFreepf_head,*_pBusypf_head,*_pBusypf_tail;vector_vMain,_vPage,_vOf
3、fset;int_nDiseffect;};CMemory::CMemory():_vDiscPages(TOTAL_VP),_vMemoryPages(TOTAL_VP),_vMain(TOTAL_INSTRUCTION),_vPage(TOTAL_INSTRUCTION),_vOffset(TOTAL_INSTRUCTION){intS,i,nRand;srand(getpid()*10);nRand=rand()%32767;S=(float)319*nRand/32767+1;for(i=0;i4、in[i+1]=_vMain[i]+1;nRand=rand()%32767;_vMain[i+2]=(float)_vMain[i]*nRand/32767;_vMain[i+3]=_vMain[i+2]+1;nRand=rand()%32767;S=(float)nRand*(318-_vMain[i+2])/32767+_vMain[i+2]+2;}for(i=0;i5、lize(constintnTotal_pf){intix;_nDiseffect=0;for(ix=0;ix<_vDiscPages.size();ix++){_vDiscPages[ix].m_nPageNumber=ix;_vDiscPages[ix].m_nPageFaceNumber=INVALID;_vDiscPages[ix].m_nCounter=0;_vDiscPages[ix].m_nTime=-1;}for(ix=1;ix6、yPages[ix-1].m_nPageFaceNumber=ix-1;}_vMemoryPages[nTotal_pf-1].m_pNext=NULL;_vMemoryPages[nTotal_pf-1].m_nPageFaceNumber=nTotal_pf-1;_pFreepf_head=&_vMemoryPages[0];}voidCMemory::FIFO(constintnTotal_pf){inti;CPageControl*p;initialize(nTotal_pf);_pBusypf_head=_pBusypf_tail=NULL;for(i=0;i7、INSTRUCTION;i++){if(_vDiscPages[_vPage[i]].m_nPageFaceNumber==INVALID){_nDiseffect+=1;if(_pFreepf_head==NULL)//noemptypages{p=_pBusypf_head->m_pNext;_vDiscPages[_pBusypf_head->m_nPageNumber].m_nPageFaceNumber=INVALID;_pFreepf_head
4、in[i+1]=_vMain[i]+1;nRand=rand()%32767;_vMain[i+2]=(float)_vMain[i]*nRand/32767;_vMain[i+3]=_vMain[i+2]+1;nRand=rand()%32767;S=(float)nRand*(318-_vMain[i+2])/32767+_vMain[i+2]+2;}for(i=0;i5、lize(constintnTotal_pf){intix;_nDiseffect=0;for(ix=0;ix<_vDiscPages.size();ix++){_vDiscPages[ix].m_nPageNumber=ix;_vDiscPages[ix].m_nPageFaceNumber=INVALID;_vDiscPages[ix].m_nCounter=0;_vDiscPages[ix].m_nTime=-1;}for(ix=1;ix6、yPages[ix-1].m_nPageFaceNumber=ix-1;}_vMemoryPages[nTotal_pf-1].m_pNext=NULL;_vMemoryPages[nTotal_pf-1].m_nPageFaceNumber=nTotal_pf-1;_pFreepf_head=&_vMemoryPages[0];}voidCMemory::FIFO(constintnTotal_pf){inti;CPageControl*p;initialize(nTotal_pf);_pBusypf_head=_pBusypf_tail=NULL;for(i=0;i7、INSTRUCTION;i++){if(_vDiscPages[_vPage[i]].m_nPageFaceNumber==INVALID){_nDiseffect+=1;if(_pFreepf_head==NULL)//noemptypages{p=_pBusypf_head->m_pNext;_vDiscPages[_pBusypf_head->m_nPageNumber].m_nPageFaceNumber=INVALID;_pFreepf_head
5、lize(constintnTotal_pf){intix;_nDiseffect=0;for(ix=0;ix<_vDiscPages.size();ix++){_vDiscPages[ix].m_nPageNumber=ix;_vDiscPages[ix].m_nPageFaceNumber=INVALID;_vDiscPages[ix].m_nCounter=0;_vDiscPages[ix].m_nTime=-1;}for(ix=1;ix6、yPages[ix-1].m_nPageFaceNumber=ix-1;}_vMemoryPages[nTotal_pf-1].m_pNext=NULL;_vMemoryPages[nTotal_pf-1].m_nPageFaceNumber=nTotal_pf-1;_pFreepf_head=&_vMemoryPages[0];}voidCMemory::FIFO(constintnTotal_pf){inti;CPageControl*p;initialize(nTotal_pf);_pBusypf_head=_pBusypf_tail=NULL;for(i=0;i7、INSTRUCTION;i++){if(_vDiscPages[_vPage[i]].m_nPageFaceNumber==INVALID){_nDiseffect+=1;if(_pFreepf_head==NULL)//noemptypages{p=_pBusypf_head->m_pNext;_vDiscPages[_pBusypf_head->m_nPageNumber].m_nPageFaceNumber=INVALID;_pFreepf_head
6、yPages[ix-1].m_nPageFaceNumber=ix-1;}_vMemoryPages[nTotal_pf-1].m_pNext=NULL;_vMemoryPages[nTotal_pf-1].m_nPageFaceNumber=nTotal_pf-1;_pFreepf_head=&_vMemoryPages[0];}voidCMemory::FIFO(constintnTotal_pf){inti;CPageControl*p;initialize(nTotal_pf);_pBusypf_head=_pBusypf_tail=NULL;for(i=0;i7、INSTRUCTION;i++){if(_vDiscPages[_vPage[i]].m_nPageFaceNumber==INVALID){_nDiseffect+=1;if(_pFreepf_head==NULL)//noemptypages{p=_pBusypf_head->m_pNext;_vDiscPages[_pBusypf_head->m_nPageNumber].m_nPageFaceNumber=INVALID;_pFreepf_head
7、INSTRUCTION;i++){if(_vDiscPages[_vPage[i]].m_nPageFaceNumber==INVALID){_nDiseffect+=1;if(_pFreepf_head==NULL)//noemptypages{p=_pBusypf_head->m_pNext;_vDiscPages[_pBusypf_head->m_nPageNumber].m_nPageFaceNumber=INVALID;_pFreepf_head
此文档下载收益归作者所有