欢迎来到人人文库网! | 帮助中心 人人文库renrendoc.com美如初恋!
人人文库网
首页 人人文库网 > 资源分类 > DOC文档下载

操作系统动态内存分配.doc

  • 资源大小:38.00KB        全文页数:7页
  • 资源格式: DOC        下载权限:游客/注册会员/VIP会员    下载费用:6
游客快捷下载 游客一键下载
会员登录下载
下载资源需要6

邮箱/手机号:
您支付成功后,系统会自动为您创建此邮箱/手机号的账号,密码跟您输入的邮箱/手机号一致,以方便您下次登录下载和查看订单。注:支付完成后需要自己下载文件,并不会自动发送文件哦!

支付方式: 微信支付    支付宝   
验证码:   换一换

友情提示
2、本站资源不支持迅雷下载,请使用浏览器直接下载(不支持QQ浏览器)
3、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰   

操作系统动态内存分配.doc

PACKAGECOMGAOJINGDIANARITHMETIC;IMPORTJAVAIOIOEXCEPTION;IMPORTJAVAUTILARRAYLIST;IMPORTJAVAUTILLINKEDLIST;IMPORTJAVAUTILLIST;IMPORTCOMGAOJINGDIANDATAFRAMEPCB;IMPORTCOMGAOJINGDIANDATAFRAMESUBAREA;IMPORTCOMGAOJINGDIANMAINMEMORYSUBAREAMAINMEMORYSUBAREA;IMPORTCOMGAOJINGDIANMAINMEMORYSUBAREAREVOKEMEMORY;/最佳适应算法/PUBLICCLASSBESTFITEXTENDSFCFS{PRIVATELISTPCBREADYLISTNEWARRAYLISTPCB;//就绪队列PRIVATELISTSUBAREAALLOCATIONLISTNEWLINKEDLISTSUBAREA;//已分分配分区队列PRIVATESTATICMAINMEMORYSUBAREAMMSNULL;PRIVATEPCBLASTPCBNULL;PRIVATESUBAREAREVOKESUBAREANULL;//当前要释放的分区PRIVATELISTSUBAREAEMPTYSUBAREANULL;//空闲队列PRIVATELISTPCBLISTNULL;//中间容器STATIC{MMSNEWMAINMEMORYSUBAREA;}//用FCFS调度算法从后备队列中往内存中调入满足条件的作业,并用最佳适应算法为作业分配内存空间PRIVATEVOIDENTERREADYLISTTHROWSIOEXCEPTION{MMSINITFREELIST;IFEMPTYSUBAREANULLEMPTYSUBAREAMMSGETSUBAREALIST;FORINTI0;ILISTSIZE;I{INTJ0;JTHISGETINDEXLISTGETI;IFJ1{READYLISTADDLISTGETI;IFEMPTYSUBAREAGETJGETSIZELISTGETIGETPROCESSSIZESUBAREAUNALTEREDSIZE{SUBAREARSBNEWSUBAREA;RSBSETSIZEEMPTYSUBAREAGETJGETSIZE;RSBSETBEGINADDRESSEMPTYSUBAREAGETJGETBEGINADDRESS;RSBSETPCBIDLISTGETIGETID;ALLOCATIONLISTADDRSB;EMPTYSUBAREAREMOVEEMPTYSUBAREAGETJ;}ELSE{SUBAREASAEMPTYSUBAREAGETJ;SUBAREARSBNEWSUBAREA;RSBSETSIZELISTGETIGETPROCESSSIZE;RSBSETBEGINADDRESSSAGETBEGINADDRESS;RSBSETPCBIDLISTGETIGETID;ALLOCATIONLISTADDRSB;SASETBEGINADDRESSSAGETBEGINADDRESSLISTGETIGETPROCESSSIZE;SASETSIZESAGETSIZELISTGETIGETPROCESSSIZE;}LISTGETISETLOGO21;BREAK;}IFJ1LISTGETISETLOGO11;}}//执行进程,并回收内存空间PUBLICVOIDBESTFITTHROWSIOEXCEPTION{PCBPCBNULL;INTTEMP10000;INTINDEX0;WHILETRUE{LISTSUPERSELECTPROCESSREADYLIST,LASTPCB;THISENTERREADYLIST;TEMP10000;IFREADYLISTSIZE0{IFTHISGETCOUNTREADYLISTSIZE{FORINTI0;IREADYLISTSIZE;I{IFREADYLISTGETIGETARRIVETIMETEMPREADYLISTGETIGETLOGO0READYLISTGETIGETLOGO21READYLISTGETIGETLOGO10{TEMPREADYLISTGETIGETARRIVETIME;INDEXI;}}PCBREADYLISTGETINDEX;IFLASTPCBNULLPCBSETBEGINTIMEPCBGETARRIVETIME;ELSEPCBSETBEGINTIMELASTPCBGETENDTIME;PCBSETENDTIMEPCBGETBEGINTIMEPCBGETRUNTIME;PCBSETLOGO1;LASTPCBPCB;REVOKESUBAREAREVOKEMEMORYSELECTREVOKEALLOCATIONLIST,PCB;REVOKEMEMORYREVOKEMEMORYEMPTYSUBAREA,REVOKESUBAREA;}ELSE{BREAK;}}}}//判断就绪队列中还有没有为被执行的进程PRIVATEINTGETCOUNT{INTCOUNT0;FORINTI0;IREADYLISTSIZE;IIFREADYLISTGETIGETLOGO1COUNT;RETURNCOUNT;}//返回空闲分区中大小最合适的分区的下标PRIVATEINTGETINDEXPCBPCB{INTTEMP10000;INTINDEX1;FORINTI0;IEMPTYSUBAREASIZE;IIFPCBGETPROCESSSIZEEMPTYSUBAREAGETIGETSIZEEMPTYSUBAREAGETIGETSIZEPCBGETPROCESSSIZETEMP{TEMPEMPTYSUBAREAGETIGETSIZEPCBGETPROCESSSIZE;INDEXI;}RETURNINDEX;}PUBLICLISTSUBAREAGETALLOCATIONLIST{RETURNALLOCATIONLIST;}PUBLICVOIDSETALLOCATIONLISTLISTSUBAREAALLOCATIONLIST{THISALLOCATIONLISTALLOCATIONLIST;}PUBLICLISTSUBAREAGETEMPTYSUBAREA{RETURNEMPTYSUBAREA;}PUBLICVOIDSETEMPTYSUBAREALISTSUBAREAEMPTYSUBAREA{THISEMPTYSUBAREAEMPTYSUBAREA;}PUBLICLISTPCBGETREADYLIST{RETURNREADYLIST;}PUBLICVOIDSETREADYLISTLISTPCBREADYLIST{THISREADYLISTREADYLIST;}}PACKAGECOMGAOJINGDIANARITHMETIC;IMPORTJAVAIOIOEXCEPTION;IMPORTJAVAUTILARRAYLIST;IMPORTJAVAUTILLINKEDLIST;IMPORTJAVAUTILLIST;IMPORTCOMGAOJINGDIANDATAFRAMEPCB;IMPORTCOMGAOJINGDIANDATAFRAMESUBAREA;IMPORTCOMGAOJINGDIANMAINMEMORYSUBAREAMAINMEMORYSUBAREA;IMPORTCOMGAOJINGDIANMAINMEMORYSUBAREAREVOKEMEMORY;IMPORTCOMGAOJINGDIANTESTTEST;IMPORTCOMGAOJINGDIANWORKLISTWORKLISTS;/首次适应算法AUTHORGAOJINGDIAN/PUBLICCLASSFIRSTFITEXTENDSFCFS{PRIVATELISTPCBREADYLISTNEWARRAYLISTPCB;//就绪队列PRIVATELISTSUBAREAALLOCATIONLISTNEWLINKEDLISTSUBAREA;//已分分配分区队列PRIVATESTATICMAINMEMORYSUBAREAMMSNULL;PRIVATEPCBLASTPCBNULL;PRIVATESUBAREAREVOKESUBAREANULL;//当前要释放的分区PRIVATELISTSUBAREAEMPTYSUBAREANULL;//空闲队列PRIVATELISTPCBLISTNULL;//中间容器STATIC{MMSNEWMAINMEMORYSUBAREA;}//用FCFS调度算法从后备队列中往内存中调入满足条件的作业,并用首次适应算法为作业分配内存空间PRIVATEVOIDENTERREADYLISTTHROWSIOEXCEPTION{MMSINITFREELIST;IFEMPTYSUBAREANULLEMPTYSUBAREAMMSGETSUBAREALIST;FORINTI0;ILISTSIZE;I{INTJ0;FOR;JEMPTYSUBAREASIZE;J{IFLISTGETIGETPROCESSSIZEEMPTYSUBAREAGETJGETSIZE{READYLISTADDLISTGETI;IFEMPTYSUBAREAGETJGETSIZELISTGETIGETPROCESSSIZESUBAREAUNALTEREDSIZE{SUBAREARSBNEWSUBAREA;RSBSETSIZEEMPTYSUBAREAGETJGETSIZE;RSBSETBEGINADDRESSEMPTYSUBAREAGETJGETBEGINADDRESS;RSBSETPCBIDLISTGETIGETID;ALLOCATIONLISTADDRSB;EMPTYSUBAREAREMOVEEMPTYSUBAREAGETJ;}ELSE{SUBAREASAEMPTYSUBAREAGETJ;SUBAREARSBNEWSUBAREA;RSBSETSIZELISTGETIGETPROCESSSIZE;RSBSETBEGINADDRESSSAGETBEGINADDRESS;RSBSETPCBIDLISTGETIGETID;ALLOCATIONLISTADDRSB;SASETBEGINADDRESSSAGETBEGINADDRESSLISTGETIGETPROCESSSIZE;SASETSIZESAGETSIZELISTGETIGETPROCESSSIZE;}LISTGETISETLOGO21;BREAK;}}IFJEMPTYSUBAREASIZELISTGETISETLOGO11;}}//执行进程,并回收内存空间PUBLICVOIDFIRSTFITTHROWSIOEXCEPTION{PCBPCBNULL;INTTEMP10000;INTINDEX0;WHILETRUE{LISTSUPERSELECTPROCESSREADYLIST,LASTPCB;THISENTERREADYLIST;TEMP10000;IFREADYLISTSIZE0{IFTHISGETCOUNTREADYLISTSIZE{FORINTI0;IREADYLISTSIZE;I{IFREADYLISTGETIGETARRIVETIMETEMPREADYLISTGETIGETLOGO0READYLISTGETIGETLOGO21READYLISTGETIGETLOGO10{TEMPREADYLISTGETIGETARRIVETIME;INDEXI;}}PCBREADYLISTGETINDEX;IFLASTPCBNULLPCBSETBEGINTIMEPCBGETARRIVETIME;ELSEPCBSETBEGINTIMELASTPCBGETENDTIME;PCBSETENDTIMEPCBGETBEGINTIMEPCBGETRUNTIME;PCBSETLOGO1;LASTPCBPCB;REVOKESUBAREAREVOKEMEMORYSELECTREVOKEALLOCATIONLIST,PCB;REVOKEMEMORYREVOKEMEMORYEMPTYSUBAREA,REVOKESUBAREA;}ELSE{BREAK;}}}}PRIVATEINTGETCOUNT{INTCOUNT0;FORINTI0;IREADYLISTSIZE;IIFREADYLISTGETIGETLOGO1COUNT;RETURNCOUNT;}PUBLICLISTSUBAREAGETALLOCATIONLIST{RETURNALLOCATIONLIST;}PUBLICVOIDSETALLOCATIONLISTLISTSUBAREAALLOCATIONLIST{THISALLOCATIONLISTALLOCATIONLIST;}PUBLICLISTSUBAREAGETEMPTYSUBAREA{RETURNEMPTYSUBAREA;}PUBLICVOIDSETEMPTYSUBAREALISTSUBAREAEMPTYSUBAREA{THISEMPTYSUBAREAEMPTYSUBAREA;}PUBLICLISTPCBGETREADYLIST{RETURNREADYLIST;}PUBLICVOIDSETREADYLISTLISTPCBREADYLIST{THISREADYLISTREADYLIST;}}

注意事项

本文(操作系统动态内存分配.doc)为本站会员(liyun)主动上传,人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知人人文库网(发送邮件至[email protected]或直接QQ联系客服),我们立即给予删除!

温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。

关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服客服 - 联系我们

网站客服QQ:2846424093    人人文库上传用户QQ群:460291265   

[email protected] 2016-2018  renrendoc.com 网站版权所有   南天在线技术支持

经营许可证编号:苏ICP备12009002号-5