




已閱讀5頁(yè),還剩2頁(yè)未讀, 繼續(xù)免費(fèi)閱讀
版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
packagecom.gaojingdian.arithmetic;importjava.io.IOException;importjava.util.ArrayList;importjava.util.LinkedList;importjava.util.List;importcom.gaojingdian.DataFrame.PCB;importcom.gaojingdian.DataFrame.Subarea;importcom.gaojingdian.MainMemorySubarea.MainMemorySubarea;importcom.gaojingdian.MainMemorySubarea.RevokeMemory;/*最佳適應(yīng)算法*/publicclassBestFitextendsFCFSprivateListreadyList=newArrayList();/就緒隊(duì)列privateListallocationList=newLinkedList();/已分分配分區(qū)隊(duì)列privatestaticMainMemorySubareamms=null;privatePCBlastPCB=null;privateSubarearevokeSubarea=null;/當(dāng)前要釋放的分區(qū)privateListemptySubarea=null;/空閑隊(duì)列privateListlist=null;/中間容器staticmms=newMainMemorySubarea();/用FCFS調(diào)度算法從后備隊(duì)列中往內(nèi)存中調(diào)入滿足條件的作業(yè),并用最佳適應(yīng)算法為作業(yè)分配內(nèi)存空間privatevoidenterReadyList()throwsIOExceptionmms.initFreeList();if(emptySubarea=null)emptySubarea=mms.getSubareaList();for(inti=0;ilist.size();i+)intj=0;j=this.getIndex(list.get(i);if(j!=-1)readyList.add(list.get(i);if(emptySubarea.get(j).getSize()-list.get(i).getProcessSize()=Subarea.unalteredSize)Subarearsb=newSubarea();rsb.setSize(emptySubarea.get(j).getSize();rsb.setBeginAddress(emptySubarea.get(j).getBeginAddress();rsb.setPcbId(list.get(i).getId();allocationList.add(rsb);emptySubarea.remove(emptySubarea.get(j);elseSubareasa=emptySubarea.get(j);Subarearsb=newSubarea();rsb.setSize(list.get(i).getProcessSize();rsb.setBeginAddress(sa.getBeginAddress();rsb.setPcbId(list.get(i).getId();allocationList.add(rsb);sa.setBeginAddress(sa.getBeginAddress()+list.get(i).getProcessSize();sa.setSize(sa.getSize()-list.get(i).getProcessSize();list.get(i).setLogo2(1);break;if(j=-1)list.get(i).setLogo1(1);/執(zhí)行進(jìn)程,并回收內(nèi)存空間publicvoidbestFit()throwsIOExceptionPCBpcb=null;inttemp=10000;intindex=0;while(true)list=super.selectProcess(readyList,lastPCB);this.enterReadyList();temp=10000;if(readyList.size()!=0)if(this.getCount()!=readyList.size()for(inti=0;ireadyList.size();i+)if(readyList.get(i).getArriveTime()temp&readyList.get(i).getLogo()=0&readyList.get(i).getLogo2()=1&readyList.get(i).getLogo1()=0)temp=readyList.get(i).getArriveTime();index=i;pcb=readyList.get(index);if(lastPCB=null)pcb.setBeginTime(pcb.getArriveTime();elsepcb.setBeginTime(lastPCB.getEndTime();pcb.setEndTime(pcb.getBeginTime()+pcb.getRunTime();pcb.setLogo(1);lastPCB=pcb;revokeSubarea=RevokeMemory.selectRevoke(allocationList,pcb);RevokeMemory.revokeMemory(emptySubarea,revokeSubarea);elsebreak;/判斷就緒隊(duì)列中還有沒(méi)有為被執(zhí)行的進(jìn)程privateintgetCount()intcount=0;for(inti=0;ireadyList.size();i+)if(readyList.get(i).getLogo()=1)count+;returncount;/返回空閑分區(qū)中大小最合適的分區(qū)的下標(biāo)privateintgetIndex(PCBpcb)inttemp=10000;intindex=-1;for(inti=0;iemptySubarea.size();i+)if(pcb.getProcessSize()=emptySubarea.get(i).getSize()&(emptySubarea.get(i).getSize()-pcb.getProcessSize()temp)temp=emptySubarea.get(i).getSize()-pcb.getProcessSize();index=i;returnindex;publicListgetAllocationList()returnallocationList;publicvoidsetAllocationList(ListallocationList)this.allocationList=allocationList;publicListgetEmptySubarea()returnemptySubarea;publicvoidsetEmptySubarea(ListemptySubarea)this.emptySubarea=emptySubarea;publicListgetReadyList()returnreadyList;publicvoidsetReadyList(ListreadyList)this.readyList=readyList;packagecom.gaojingdian.arithmetic;importjava.io.IOException;importjava.util.ArrayList;importjava.util.LinkedList;importjava.util.List;importcom.gaojingdian.DataFrame.PCB;importcom.gaojingdian.DataFrame.Subarea;importcom.gaojingdian.MainMemorySubarea.MainMemorySubarea;importcom.gaojingdian.MainMemorySubarea.RevokeMemory;importcom.gaojingdian.Test.Test;importcom.gaojingdian.WorkList.WorkLists;/*首次適應(yīng)算法*authorgaojingdian*/publicclassFirstFitextendsFCFSprivateListreadyList=newArrayList();/就緒隊(duì)列privateListallocationList=newLinkedList();/已分分配分區(qū)隊(duì)列privatestaticMainMemorySubareamms=null;privatePCBlastPCB=null;privateSubarearevokeSubarea=null;/當(dāng)前要釋放的分區(qū)privateListemptySubarea=null;/空閑隊(duì)列privateListlist=null;/中間容器staticmms=newMainMemorySubarea();/用FCFS調(diào)度算法從后備隊(duì)列中往內(nèi)存中調(diào)入滿足條件的作業(yè),并用首次適應(yīng)算法為作業(yè)分配內(nèi)存空間privatevoidenterReadyList()throwsIOExceptionmms.initFreeList();if(emptySubarea=null)emptySubarea=mms.getSubareaList();for(inti=0;ilist.size();i+)intj=0;for(;jemptySubarea.size();j+)if(list.get(i).getProcessSize()=emptySubarea.get(j).getSize()readyList.add(list.get(i);if(emptySubarea.get(j).getSize()-list.get(i).getProcessSize()=Subarea.unalteredSize)Subarearsb=newSubarea();rsb.setSize(emptySubarea.get(j).getSize();rsb.setBeginAddress(emptySubarea.get(j).getBeginAddress();rsb.setPcbId(list.get(i).getId();allocationList.add(rsb);emptySubarea.remove(emptySubarea.get(j);elseSubareasa=emptySubarea.get(j);Subarearsb=newSubarea();rsb.setSize(list.get(i).getProcessSize();rsb.setBeginAddress(sa.getBeginAddress();rsb.setPcbId(list.get(i).getId();allocationList.add(rsb);sa.setBeginAddress(sa.getBeginAddress()+list.get(i).getProcessSize();sa.setSize(sa.getSize()-list.get(i).getProcessSize();list.get(i).setLogo2(1);break;if(j=emptySubarea.size()list.get(i).setLogo1(1);/執(zhí)行進(jìn)程,并回收內(nèi)存空間publicvoidfirstFit()throwsIOExceptionPCBpcb=null;inttemp=10000;intindex=0;while(true)list=super.selectProcess(readyList,lastPCB);this.enterReadyList();temp=10000;if(readyList.size()!=0)if(this.getCount()!=readyList.size()for(inti=0;ireadyList.size();i+)if(readyList.get(i).getArriveTime()temp&readyList.get(i).getLogo()=0&readyList.get(i).getLogo2()=1&readyList.get(i).getLogo1()=0)temp=readyList.get(i).getArriveTime();index=i;pcb=readyList.get(index);if(lastPCB=null)pcb.setBeginTime(pcb.getArriveTime();elsepcb.setBeginTime(lastPCB.getEndTime();pcb.setEndTime(pcb.getBeginTime()+pcb.getRunTime();pcb.set
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 代理經(jīng)銷(xiāo)合同代銷(xiāo)合同和經(jīng)銷(xiāo)合同
- 材料設(shè)備采購(gòu)合同
- 高端酒店預(yù)訂服務(wù)協(xié)議
- 人工費(fèi)承包合同(12篇)
- 承包荒山荒地協(xié)議書(shū)
- 砂石采購(gòu)的合同
- 旅游出行行業(yè)意外傷害保險(xiǎn)免責(zé)協(xié)議
- 企業(yè)績(jī)效評(píng)估與改進(jìn)方案
- 房地產(chǎn)項(xiàng)目投資合作合同
- 房地產(chǎn)居間合同正式
- 2025年中國(guó)國(guó)投高新產(chǎn)業(yè)投資集團(tuán)招聘筆試參考題庫(kù)含答案解析
- 部編(統(tǒng)編)版語(yǔ)文+四下第四單元教材解讀課件
- 年產(chǎn)10噸功能益生菌凍干粉的工廠設(shè)計(jì)改
- GA/T 1133-2014基于視頻圖像的車(chē)輛行駛速度技術(shù)鑒定
- 《數(shù)學(xué)趣味活動(dòng)》PPT課件.ppt
- 銅冶煉渣選銅尾礦還原焙燒—磁選回收鐵工藝研究
- 交接班制度.ppt
- 北師大版五年級(jí)數(shù)學(xué)下冊(cè)導(dǎo)學(xué)案全冊(cè)
- 成都嘉祥外國(guó)語(yǔ)學(xué)校獎(jiǎng)學(xué)金考試數(shù)學(xué)試卷
- 臺(tái)球俱樂(lè)部助教制度及待遇
- 醫(yī)師聘用證明.doc
評(píng)論
0/150
提交評(píng)論