![模擬操作系統(tǒng)的請求分頁存儲管理java代碼_第1頁](http://file1.renrendoc.com/fileroot_temp2/2020-10/4/e32d3ea4-8859-4fed-b19c-1cafa9154559/e32d3ea4-8859-4fed-b19c-1cafa91545591.gif)
![模擬操作系統(tǒng)的請求分頁存儲管理java代碼_第2頁](http://file1.renrendoc.com/fileroot_temp2/2020-10/4/e32d3ea4-8859-4fed-b19c-1cafa9154559/e32d3ea4-8859-4fed-b19c-1cafa91545592.gif)
![模擬操作系統(tǒng)的請求分頁存儲管理java代碼_第3頁](http://file1.renrendoc.com/fileroot_temp2/2020-10/4/e32d3ea4-8859-4fed-b19c-1cafa9154559/e32d3ea4-8859-4fed-b19c-1cafa91545593.gif)
![模擬操作系統(tǒng)的請求分頁存儲管理java代碼_第4頁](http://file1.renrendoc.com/fileroot_temp2/2020-10/4/e32d3ea4-8859-4fed-b19c-1cafa9154559/e32d3ea4-8859-4fed-b19c-1cafa91545594.gif)
![模擬操作系統(tǒng)的請求分頁存儲管理java代碼_第5頁](http://file1.renrendoc.com/fileroot_temp2/2020-10/4/e32d3ea4-8859-4fed-b19c-1cafa9154559/e32d3ea4-8859-4fed-b19c-1cafa91545595.gif)
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、請求分頁存儲管理的實現(xiàn)寫出方案實現(xiàn)代碼(1)page類package homework;public class Page private int pagenumb;/頁號private int physicsnumb;/物理塊號private boolean state;/狀態(tài)位private int visitcount;/訪問字段private boolean change;/修改位private int CRTaddress;/外存地址public Page() this.pagenumb=-1;this.physicsnumb=-1;this.state=false;this.vis
2、itcount=0;this.change=false;this.CRTaddress=-1;public Page(int pagenumb,int physicsnumb,boolean state,int visitcount,boolean change,int CRTaddress) this.pagenumb=pagenumb;this.physicsnumb=physicsnumb;this.state=state;this.visitcount=visitcount;this.change=change;this.CRTaddress=CRTaddress;public voi
3、d setPagenumb(int pagenumb)this.pagenumb=pagenumb;public void setPhysicsnumb(int physicsnumb)this.physicsnumb=physicsnumb;public void setState(boolean state)this.state=state;public void setVisitcount(int visitcount)this.visitcount=visitcount;public void setChange(boolean change)this.change=change;pu
4、blic void setCRTaddress(int CRTaddress)this.CRTaddress=CRTaddress;public int getPagenumb()return this.pagenumb;public int getPhysicsnumb()return this.physicsnumb;public boolean getState()return this.state;public int getVisitcount()return this.visitcount;public boolean getChange()return this.change;p
5、ublic int getCRTaddress()return this.CRTaddress; (2)Shell類:頁表package homework;import java.util.Scanner;public class Shell Page shell;private int current;private int length;public Shell() ;public Shell(int length)this.length=length;this.current=0;shell=new Pagelength;for(int i=0;ilength;i+)this.shell
6、i=new Page();public void setCurrent(int current)this.current=current;public int getCurrent()return this.current;public int searchpage(int pagenumb)int i=0;if(this.current=0)return -2;elsewhile(i=this.length)return 1;else return 0;public int MinVisitcount()int i,t=0;for(i=1;ithis.current;i+)if(this.s
7、helli.getVisitcount()this.shellt.getVisitcount()t=i;return t;public int Ischange(int number)if(this.shellnumber.getChange()=true)return 1;else return 0;public void printPageShell()System.out.println(頁表:);System.out.println(索引t+頁號t+物理塊號t+狀態(tài)t+訪問次數(shù)t+修改t+外存地址t);for(int i=0;ithis.length;i+)System.out.pri
8、ntln(i+t+this.shelli.getPagenumb()+t+this.shelli.getPhysicsnumb()+t+this.shelli.getState()+t+this.shelli.getVisitcount()+t+this.shelli.getChange()+t+this.shelli.getCRTaddress();public void programFunction()System.out.println(*請求分頁存儲系統(tǒng)*);System.out.println(功能:);System.out.println(t 1.查看頁表);System.out
9、.println(t 2.查看快表);System.out.println(t 3.查看外存);System.out.println(t 4.在內(nèi)存修改數(shù)據(jù)); System.out.println(t 5.繼續(xù)訪問頁面); System.out.println(t 6.退出程序);public void Dealfunction(int i,KShell TLB,Source s,int b)if(i=1)this.printPageShell();else if(i=2)TLB.printKShell();else if(i=3)System.out.println(外存:);System
10、.out.println(外存地址t+頁號t+數(shù)據(jù)n);for(int k=0;k20;k+)sk.printSource(k);else if(i=4)String ch=yes;int pageNumb;Scanner a=new Scanner(System.in);System.out.print(請輸入一個頁號:);pageNumb=a.nextInt();int numb=this.searchpage(pageNumb);if(numb0)System.out.println(內(nèi)存中沒有此頁號);elsethis.Inchange(b, ch,numb);else if(i=6)
11、System.out.println(結(jié)束程序);System.exit(0);public static void main(String args)Scanner a=new Scanner(System.in);int i,number=-10,k1,k2,result;int k3=0;/當(dāng)前存儲的內(nèi)存地址int t;/頁表中訪問次數(shù)最小的索引int b=new int10;/內(nèi)存中存儲的數(shù)據(jù)String ch;int slength,plength,Tlength,data;System.out.print(請輸入外存大小:);slength=a.nextInt();System.o
12、ut.print(請輸入頁表大小:);plength=a.nextInt();System.out.print(請輸入快表大?。?;Tlength=a.nextInt();/定義頁表,快表,外存Shell pageshell=new Shell(plength);/頁表Source s=new Sourceslength;/外存KShell TLB=new KShell(Tlength);/快表System.out.println(產(chǎn)生一個隨機(jī)序列作為外存數(shù)據(jù)!);/錄入外存地址和數(shù)據(jù)for(i=0;i=20|k10)number=TLB.searchpage(k1);if(number!=-
13、1&number!=-2)result=bTLB.shellnumber.getPhysicsnumb();System.out.println(在快表中找到,結(jié)果為:+result);/找出該頁號在頁表中的位置并修改訪問字段number=TLB.shellnumber.getIndex();pageshell.shellnumber.setVisitcount(pageshell.shellnumber.getVisitcount()+1);if(TLB.getCurrent()0)number=pageshell.searchpage(k1);/頁號k1所在的下標(biāo)if(number!=-1
14、&number!=-2)result=bpageshell.shellnumber.getPhysicsnumb();System.out.println(在頁表中找到,結(jié)果為:+result);/修改訪問字段和狀態(tài)位pageshell.shellnumber.setVisitcount(pageshell.shellnumber.getVisitcount()+1);/修改快表TLB.changeKShell(pageshell, number);if(pageshell.current=0|number=-1)System.out.println(在內(nèi)存中找不到!);System.out.
15、println(從外存中調(diào)入內(nèi)存:);/在頁表找不到,去外存區(qū)找for(i=0;islength;i+)if(k1=si.getPagenumb()/在外存找到了缺頁k2=pageshell.Isover();if(k2=1)/內(nèi)存已滿t=pageshell.MinVisitcount();System.out.println(內(nèi)存已滿!即將調(diào)出頁號+pageshell.shellt.getPagenumb();elset=pageshell.current;pageshell.setCurrent(pageshell.getCurrent()+1);/判斷是否修改了內(nèi)存的數(shù)據(jù)if(pages
16、hell.Ischange(t)=1)spageshell.shellt.getCRTaddress().setSts(bpageshell.shellt.getPhysicsnumb();/調(diào)入內(nèi)存pageshell.shellt.setPagenumb(k1);if(k2=1)bpageshell.shellt.getPhysicsnumb()=si.getSts();elsepageshell.shellt.setPhysicsnumb(k3);/未滿則設(shè)置物理塊號,滿了只改變其他5個字段bk3=si.getSts();k3+;/物理塊號pageshell.shellt.setState
17、(true);pageshell.shellt.setVisitcount(1);pageshell.shellt.setChange(false);pageshell.shellt.setCRTaddress(i);System.out.println(調(diào)入內(nèi)存成功!);/修改快表TLB.changeKShell(pageshell,t);System.out.println(修改快表成功!);System.out.println(結(jié)果為:+bk3-1);break;gramFunction();System.out.print(請輸入一個整數(shù)(1-6):);i
18、=a.nextInt();while(i6)System.out.println(輸入有誤,請重新輸入(1-6):);i=a.nextInt();pageshell.Dealfunction(i,TLB,s,b);while(i!=5);/*System.out.println(是否繼續(xù)請求訪問頁面(1 or 0):);i=a.nextInt();while(i!=1&i!=0)System.out.println(輸入有誤,請重新輸入(1 or 0):);i=a.nextInt();*/while(i=5);System.out.println(退出程序!);(4)KShell類:快表pac
19、kage homework;public class KShell KPage shell;private int current;private int length;private int changenumb;/修改快表的次數(shù)public KShell() ;public KShell(int length)this.length=length;this.current=0;this.changenumb=0;shell=new KPagelength;for(int i=0;ilength;i+)this.shelli=new KPage();public void setCurren
20、t(int current)this.current=current;public void setChangenumb(int changenumb)this.changenumb=changenumb;public int getCurrent() return current;public int getChangenumb()return changenumb;public int getLength() return length;public int searchpage(int pagenumb)int i=0;if(this.changenumb=0&this.current=
21、0)return -2;else if(this.changenumbthis.length)while(ithis.current)if(this.shelli.getPagenumb()=pagenumb)return i;i+;return -1;elsewhile(i=this.getLength()if(this.getCurrent()=this.getLength()this.setCurrent(0);System.out.println(快表已滿,快表中即將調(diào)出頁號+this.shellthis.current.getPagenumb();if(this.getCurrent
22、()this.getLength()this.shellthis.getCurrent().setIndex(number);this.shellthis.getCurrent().setPagenumb(pageshell.shellnumber.getPagenumb();this.shellthis.getCurrent().setPhysicsnumb(pageshell.shellnumber.getPhysicsnumb();this.setCurrent(this.getCurrent()+1);this.setChangenumb(this.getChangenumb()+1);public void printKShell()System.out.pri
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- GB/T 29292-2024鞋類鞋類和鞋類部件中重點化學(xué)物質(zhì)管控指南
- Pemigatinib-d6-INCB054828-d-sub-6-sub-生命科學(xué)試劑-MCE-9553
- L-Pyroglutamic-acid-7-amido-4-methylcoumarin-生命科學(xué)試劑-MCE-3725
- Boc-Ala-Me-H117-生命科學(xué)試劑-MCE-9672
- 4-Fluoro-α-pyrrolidinopropiophenone-hydrochloride-生命科學(xué)試劑-MCE-5894
- 二零二五年度租賃期滿續(xù)租養(yǎng)老機(jī)構(gòu)居住協(xié)議合同
- 2025年度商鋪租賃協(xié)議終止及租賃場地使用權(quán)回購協(xié)議
- 二零二五年度茶餐廳股份合作經(jīng)營協(xié)議
- 2025年度智慧能源管理系統(tǒng)股東合作協(xié)議書
- 二零二五年度校園食堂檔口租賃合同與食品安全管理協(xié)議
- 時政述評培訓(xùn)課件
- 2022屆高三體育特長生家長會
- 不對外供貨協(xié)議
- 2024屆高考作文主題訓(xùn)練:時評類(含解析)
- 260噸汽車吊地基承載力驗算
- 公司新員工三級安全教育培訓(xùn)(車間級)
- 北師大版高三數(shù)學(xué)選修4-6初等數(shù)論初步全冊課件【完整版】
- 老子道德經(jīng)全文講解學(xué)習(xí)課件
- 企業(yè)更名通知函
- 經(jīng)大量臨床實驗證明,空氣負(fù)離子能有效治療心腦血管疾病
- GB/T 12618-1990開口型扁圓頭抽芯鉚釘
評論
0/150
提交評論