




已閱讀5頁,還剩2頁未讀, 繼續(xù)免費(fèi)閱讀
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
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ì)列中還有沒有為被執(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. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 網(wǎng)調(diào)試題及答案
- 2025年醫(yī)養(yǎng)結(jié)合機(jī)構(gòu)餐飲服務(wù)協(xié)議
- 2025年焊工服務(wù)協(xié)議范本
- 2025年策劃合作伙伴銷售渠道優(yōu)化升級(jí)協(xié)議
- 2025年互幫互助協(xié)議書
- 2025年屠宰場牛肉交易合作協(xié)議
- 人防工程中的結(jié)構(gòu)設(shè)計(jì)與施工難點(diǎn)
- 事業(yè)單位房屋管理經(jīng)濟(jì)效益和社會(huì)效益
- 教師職業(yè)發(fā)展的持續(xù)動(dòng)力機(jī)制
- 糧食資源循環(huán)利用與儲(chǔ)備技術(shù)革新
- 2025年蘇州市中考英語二模模擬試題(六)(含解析)
- 第六單元不規(guī)則或組合圖形的周長“拓展型”專項(xiàng)練習(xí)-五年級(jí)數(shù)學(xué)下冊(cè)典型例題(原卷版)蘇教版
- 2025年中考物理答題技巧與模式專題08壓強(qiáng)與浮力的??茧y點(diǎn)綜合計(jì)算(學(xué)生版+解析)
- 2025年中考化學(xué)模擬考試試卷附帶答案
- 水電使用合同協(xié)議書
- 考古發(fā)掘考試試題及答案
- 血液透析機(jī)試題及答案
- 中國獸藥典三部 2020年版
- NB/T 11646-2024井工煤礦采空區(qū)自然發(fā)火監(jiān)測(cè)預(yù)警技術(shù)規(guī)范
- 農(nóng)藥植保和農(nóng)藥知識(shí)課件
- 2025年橡膠復(fù)合物市場分析報(bào)告
評(píng)論
0/150
提交評(píng)論