首页 请求分页式存储管理的地址转换过程实现

请求分页式存储管理的地址转换过程实现

举报
开通vip

请求分页式存储管理的地址转换过程实现请求分页式存储管理的地址转换过程实现 第2部分、请求分页式存储管理的地址转换过程实现: ?基本要求:在第1部分实验基础上实现进程的分页式内存分配和地址转换过程,并进一步实现请求分页式存储分配和地址转换过程。页面置换算法至少应实现先进先出(FIFO)、最近最久未使用(LRU)等算法。 ?参考学时:16学时 ?实验提示: 1、建立一个位示图,用来模拟内存的分配情况,位示图的位数与设定的物 理块个数相同。程序启动时可利用一组随机0和1填充位示图,表示内 存已被占用情况。 假设内存容量为64K,块大小为1K,则...

请求分页式存储管理的地址转换过程实现
请求分页式存储管理的地址转换过程实现 第2部分、请求分页式存储管理的地址转换过程实现: ?基本要求:在第1部分实验基础上实现进程的分页式内存分配和地址转换过程,并进一步实现请求分页式存储分配和地址转换过程。页面置换算法至少应实现先进先出(FIFO)、最近最久未使用(LRU)等算法。 ?参考学时:16学时 ?实验提示: 1、建立一个位示图,用来模拟内存的分配情况,位示图的位数与设定的物 理块个数相同。程序启动时可利用一组随机0和1填充位示图, 关于同志近三年现实表现材料材料类招标技术评分表图表与交易pdf视力表打印pdf用图表说话 pdf 示内 存已被占用情况。 假设内存容量为64K,块大小为1K,则共有64个块,对应的位示图可能的值如下: 第0字节 第1字节 1 0 1 1 0 0 1 1 0 1 1 0 1 1 0 0 第2字节 第3字节 1 1 1 0 0 1 1 1 1 0 0 0 0 1 1 1 第4字节 0 0 0 1 1 1 1 1 第5字节 0 1 1 1 0 0 1 1 第6字节 1 1 1 1 1 0 0 0 第7字节 0 0 0 0 0 0 0 1 该位示图表示内存的2(0字节第2位)、3(0字节第3位)、6(0字节第6 位)、8(1字节第0位)、9(1字节第1位)、12(1字节第4位)、15(1字 节第7位)„等块没有被占用。 2、创建进程时输入进程大小,并根据程序中设定的物理块大小为进程分配 物理块,同时建立页表。例如,在上图基础上,若要建立一个大小为5000 字节的进程,则: , 计算出该进程共有“向上取整(5000/1024)=5”个页,需要占用5 个内存块; , 建立空的页表,即长度为5的一维整数数组; , 从位示图中找出前5个“0”位在整个位示图中的位置号(即i字节 j位为0,则该位的位置为8*i+j),并将这些号依次填入页表中,同 时把前5个“0”改为“1”,以示对应内存块已经分配。 emotionalBecause of the guerrilla forces in the surrounding area have been withdrawn, activities in the Lake's Cheng Wanjun also refuge in Japanese, Zhu Xi forces became the puppet to attack key targets Eve puppet attacking in Wuzhen, face the problem of the retreat was to meet the enemy, in a debate within the leadership, some believe that the elves, concentrate a superior force, surely do, early transfer is the best way to reduce losses. Deputy Commander Wang Hesong impassioned statement: "Wuzhen hold, is our military's duty!" I have win a series of victories, morale, Wuzhen battle to victory, fight this battle, a Chinese miracle in the history of guerrilla warfare."Commander Zhu Xi did not have much, but the final word. On November 5, we flew over the town for several days, bomb bursts, trembling moan tranquil town in the war. People have the feeling of a catastrophe in the town. 6th reconnaissance around the command personnel brought an urgent intelligence, town-wide panic, in the face of news of the Japanese attack town, to avoid the scourge of war, the majority of people young and old fled to the countryside in the town. Also hard to find a boat in the river. Past the bustling town just seems a deserted and desolate. 7th day in implementing low-level flights over the town, fired. That night, the Elves attack Wuzhen confirmed information. Night, bursts of gunfire coming from the distance, reportedly is Deputy Commander Wang Hesong Xu Miao came Nanxun sniper assault of the Elves. 8th, the situation is more severe in the town. One afternoon, outside East Gate and South Gate there was intense gunfire. Enemy attacks by frustrated independent battalion confronted Chen qi. At this time, the command ... 11th, as Commander of Zhu Xi-Kai Wen Yongzhi, Director of 3、输入当前执行进程所要访问的逻辑地址,并将其转换成相应的物理地址。 4、进程退出时,根据其页表内容向位示图反向回填“1”。 5、扩充页表,将其变成支持请求和置换功能的二维页表(增加存在位等)。 创建进程时可装入固定的前三页(或键盘输入初始装入页数,不同进程 的装入个数可以不同),其余页装入到置换空间内(置换空间大小应为内 存空间大小的1.5倍,对其还需建立独立的位示图)。 6、分别采用FIFO和LRU置换算法对地址转换过程中遇到的缺页现象进行页 面置换,可将多次地址转换过程中所涉及到的页号视为进程的页面访问 序列,从而计算置换次数和缺页率。 import java.util.Vector; import java.io.*; class Process{ Page []PageTable; Vector PageQueue; private int size; private int Pagecount; private String name; double visit; double replacement; public void setPage(Page []PageTable) { this.PageTable=new Page[PageTable.length]; for(int i=0;i ready,blocked; public static Process running; public static BufferedReader br; static int [][]a=new int[8][8]; emotionalBecause of the guerrilla forces in the surrounding area have been withdrawn, activities in the Lake's Cheng Wanjun also refuge in Japanese, Zhu Xi forces became the puppet to attack key targets Eve puppet attacking in Wuzhen, face the problem of the retreat was to meet the enemy, in a debate within the leadership, some believe that the elves, concentrate a superior force, surely do, early transfer is the best way to reduce losses. Deputy Commander Wang Hesong impassioned statement: "Wuzhen hold, is our military's duty!" I have win a series of victories, morale, Wuzhen battle to victory, fight this battle, a Chinese miracle in the history of guerrilla warfare."Commander Zhu Xi did not have much, but the final word. On November 5, we flew over the town for several days, bomb bursts, trembling moan tranquil town in the war. People have the feeling of a catastrophe in the town. 6th reconnaissance around the command personnel brought an urgent intelligence, town-wide panic, in the face of news of the Japanese attack town, to avoid the scourge of war, the majority of people young and old fled to the countryside in the town. Also hard to find a boat in the river. Past the bustling town just seems a deserted and desolate. 7th day in implementing low-level flights over the town, fired. That night, the Elves attack Wuzhen confirmed information. Night, bursts of gunfire coming from the distance, reportedly is Deputy Commander Wang Hesong Xu Miao came Nanxun sniper assault of the Elves. 8th, the situation is more severe in the town. One afternoon, outside East Gate and South Gate there was intense gunfire. Enemy attacks by frustrated independent battalion confronted Chen qi. At this time, the command ... 11th, as Commander of Zhu Xi-Kai Wen Yongzhi, Director of static int[][]d=new int[10][10];//置换空间 static int count=0; public OS2() { ready=new Vector(); blocked=new Vector(); br=new BufferedReader(new InputStreamReader(System.in)); for(int i=0;i"); try{ int i=Integer.parseInt(br.readLine()); switch(i){ case 0: System.exit(0); case 1: createNewProcess(); break; case 2: switchCurrentProcess(); break; case 3: blockCurrentProcess(); break; case 4: wakeupBlockedProcess(); break; case 5: terminateCurrentProcess(); break; case 6: transform(); break; case 7: showPage(); break; case 8: System.out.println("位示图----------------"); print(a); System.out.println("置换空间--------------"); print(d); break; case 9: look(); break; } } catch(Exception e){ System.out.println(e); } System.out.println("执行进程:"+(running==null?"none":running)); emotionalBecause of the guerrilla forces in the surrounding area have been withdrawn, activities in the Lake's Cheng Wanjun also refuge in Japanese, Zhu Xi forces became the puppet to attack key targets Eve puppet attacking in Wuzhen, face the problem of the retreat was to meet the enemy, in a debate within the leadership, some believe that the elves, concentrate a superior force, surely do, early transfer is the best way to reduce losses. Deputy Commander Wang Hesong impassioned statement: "Wuzhen hold, is our military's duty!" I have win a series of victories, morale, Wuzhen battle to victory, fight this battle, a Chinese miracle in the history of guerrilla warfare."Commander Zhu Xi did not have much, but the final word. On November 5, we flew over the town for several days, bomb bursts, trembling moan tranquil town in the war. People have the feeling of a catastrophe in the town. 6th reconnaissance around the command personnel brought an urgent intelligence, town-wide panic, in the face of news of the Japanese attack town, to avoid the scourge of war, the majority of people young and old fled to the countryside in the town. Also hard to find a boat in the river. Past the bustling town just seems a deserted and desolate. 7th day in implementing low-level flights over the town, fired. That night, the Elves attack Wuzhen confirmed information. Night, bursts of gunfire coming from the distance, reportedly is Deputy Commander Wang Hesong Xu Miao came Nanxun sniper assault of the Elves. 8th, the situation is more severe in the town. One afternoon, outside East Gate and South Gate there was intense gunfire. Enemy attacks by frustrated independent battalion confronted Chen qi. At this time, the command ... 11th, as Commander of Zhu Xi-Kai Wen Yongzhi, Director of System.out.print("就绪进程:"); printList(ready); System.out.print("阻塞进程:"); printList(blocked); } } public static void printList(Vector v){ for(int i=0;i(); st: for(int i=0;i0){ running=(Process)ready.elementAt(0); ready.removeElementAt(0); } else running=null; } public static void blockCurrentProcess(){ if(running!=null) { blocked.add(running); } if(ready.size()>0) { running=(Process)ready.elementAt(0); emotionalBecause of the guerrilla forces in the surrounding area have been withdrawn, activities in the Lake's Cheng Wanjun also refuge in Japanese, Zhu Xi forces became the puppet to attack key targets Eve puppet attacking in Wuzhen, face the problem of the retreat was to meet the enemy, in a debate within the leadership, some believe that the elves, concentrate a superior force, surely do, early transfer is the best way to reduce losses. Deputy Commander Wang Hesong impassioned statement: "Wuzhen hold, is our military's duty!" I have win a series of victories, morale, Wuzhen battle to victory, fight this battle, a Chinese miracle in the history of guerrilla warfare."Commander Zhu Xi did not have much, but the final word. On November 5, we flew over the town for several days, bomb bursts, trembling moan tranquil town in the war. People have the feeling of a catastrophe in the town. 6th reconnaissance around the command personnel brought an urgent intelligence, town-wide panic, in the face of news of the Japanese attack town, to avoid the scourge of war, the majority of people young and old fled to the countryside in the town. Also hard to find a boat in the river. Past the bustling town just seems a deserted and desolate. 7th day in implementing low-level flights over the town, fired. That night, the Elves attack Wuzhen confirmed information. Night, bursts of gunfire coming from the distance, reportedly is Deputy Commander Wang Hesong Xu Miao came Nanxun sniper assault of the Elves. 8th, the situation is more severe in the town. One afternoon, outside East Gate and South Gate there was intense gunfire. Enemy attacks by frustrated independent battalion confronted Chen qi. At this time, the command ... 11th, as Commander of Zhu Xi-Kai Wen Yongzhi, Director of ready.removeElementAt(0); } else { running=null; } } public static void wakeupBlockedProcess() { if(blocked.size()>0){ //running=(Process)blocked.elementAt(0); ready.add((Process)blocked.elementAt(0)); blocked.removeElementAt(0); if(running==null) { running=(Process)ready.elementAt(0); ready.removeElementAt(0); } } else { //blocked=null; } } public static void terminateCurrentProcess() { whileExit(); if(running!=null) { running=null; } if(ready.size()>0) { running=(Process)ready.elementAt(0); ready.removeElementAt(0); } else if(blocked.size()>0){ running=(Process)blocked.elementAt(0); blocked.removeElementAt(0); } else { running=null; } } public static void transform() { try { if(running!=null) { System.out.print("输入逻辑地址:"); int LogicAdds=Integer.parseInt(br.readLine()); int PageNumber=LogicAdds/1024; emotionalBecause of the guerrilla forces in the surrounding area have been withdrawn, activities in the Lake's Cheng Wanjun also refuge in Japanese, Zhu Xi forces became the puppet to attack key targets Eve puppet attacking in Wuzhen, face the problem of the retreat was to meet the enemy, in a debate within the leadership, some believe that the elves, concentrate a superior force, surely do, early transfer is the best way to reduce losses. Deputy Commander Wang Hesong impassioned statement: "Wuzhen hold, is our military's duty!" I have win a series of victories, morale, Wuzhen battle to victory, fight this battle, a Chinese miracle in the history of guerrilla warfare."Commander Zhu Xi did not have much, but the final word. On November 5, we flew over the town for several days, bomb bursts, trembling moan tranquil town in the war. People have the feeling of a catastrophe in the town. 6th reconnaissance around the command personnel brought an urgent intelligence, town-wide panic, in the face of news of the Japanese attack town, to avoid the scourge of war, the majority of people young and old fled to the countryside in the town. Also hard to find a boat in the river. Past the bustling town just seems a deserted and desolate. 7th day in implementing low-level flights over the town, fired. That night, the Elves attack Wuzhen confirmed information. Night, bursts of gunfire coming from the distance, reportedly is Deputy Commander Wang Hesong Xu Miao came Nanxun sniper assault of the Elves. 8th, the situation is more severe in the town. One afternoon, outside East Gate and South Gate there was intense gunfire. Enemy attacks by frustrated independent battalion confronted Chen qi. At this time, the command ... 11th, as Commander of Zhu Xi-Kai Wen Yongzhi, Director of if(PageNumber>running.getPagecount()-1) { while(true) { //if(PageNumber>running.getPagecount()-1) { System.out.println("逻辑地址超出范围,请重新 输入:"); LogicAdds=Integer.parseInt(br.readLine()); PageNumber=LogicAdds/1024; if(PageNumber<=running.getPagecount()-1) { break; } //} } } int offset=LogicAdds%1024; int PageBlockNum=running.getPageBlock(PageNumber); ++running.PageTable[PageNumber].accessfield; ++running.visit; if(running.PageTable[PageNumber].getFlag()==0) { ++running.replacement; System.out.println("请选择你所想要置换的算法(提示:1代表 FIFO算法,2代表LRU算法):"); int ch=Integer.parseInt(br.readLine()); if(ch==1) { System.out.println("正在FIFO置换算法,对地址进行转 换"); Fifo(PageNumber); } else { System.out.println("正在LRU置换算法,对地址进行转 换"); Lru(PageNumber); } int PhyAdds=(running.getPageBlock(PageNumber))*1024+offset; System.out.println("物理地址:"+PhyAdds); } else { int PhyAdds=(running.getPageBlock(PageNumber))*1024+offset; System.out.println("物理地址:"+PhyAdds); } } else { System.out.println("no running process"); emotionalBecause of the guerrilla forces in the surrounding area have been withdrawn, activities in the Lake's Cheng Wanjun also refuge in Japanese, Zhu Xi forces became the puppet to attack key targets Eve puppet attacking in Wuzhen, face the problem of the retreat was to meet the enemy, in a debate within the leadership, some believe that the elves, concentrate a superior force, surely do, early transfer is the best way to reduce losses. Deputy Commander Wang Hesong impassioned statement: "Wuzhen hold, is our military's duty!" I have win a series of victories, morale, Wuzhen battle to victory, fight this battle, a Chinese miracle in the history of guerrilla warfare."Commander Zhu Xi did not have much, but the final word. On November 5, we flew over the town for several days, bomb bursts, trembling moan tranquil town in the war. People have the feeling of a catastrophe in the town. 6th reconnaissance around the command personnel brought an urgent intelligence, town-wide panic, in the face of news of the Japanese attack town, to avoid the scourge of war, the majority of people young and old fled to the countryside in the town. Also hard to find a boat in the river. Past the bustling town just seems a deserted and desolate. 7th day in implementing low-level flights over the town, fired. That night, the Elves attack Wuzhen confirmed information. Night, bursts of gunfire coming from the distance, reportedly is Deputy Commander Wang Hesong Xu Miao came Nanxun sniper assault of the Elves. 8th, the situation is more severe in the town. One afternoon, outside East Gate and South Gate there was intense gunfire. Enemy attacks by frustrated independent battalion confronted Chen qi. At this time, the command ... 11th, as Commander of Zhu Xi-Kai Wen Yongzhi, Director of } } catch(Exception e) { System.out.println(e); } } public static void whileExit() { for(int i=0;i0) { d[i][j]=1; ((Page)running.PageQueue.elementAt(0)).flag=0; ((Page)running.PageQueue.elementAt(0)).blockNum=-1; ((Page)running.PageQueue.elementAt(0)).writed=0; ((Page)running.PageQueue.elementAt(0)).accessfield=0; ((Page)running.PageQueue.elementAt(0)).swapsapce_blockno=8*i+j; ((Page)running.PageQueue.elementAt(0)).t=0; running.PageQueue.removeElementAt(0); running.PageQueue.add(running.PageTable[PageNumber]); break st; } } } //sb:for(int m=0;m
本文档为【请求分页式存储管理的地址转换过程实现】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_477730
暂无简介~
格式:doc
大小:94KB
软件:Word
页数:36
分类:生活休闲
上传时间:2017-09-26
浏览量:73