您好,欢迎访问三七文档
当前位置:首页 > 临时分类 > 中南大学操作系统实验报告-(2)
中南大学《操作系统》实验报告姓名:专业班级:学号:指导教师:完成日期:实验1、实验目的(1)多道系统中,当就绪进程数大于处理机数时,须按照某种策略决定哪些进程优先占用处理机。本实验模拟实现处理机调度,以加深了解处理机调度的工作。(2)从不同的侧面了解Windows2000/XP的虚拟内存机制。2、实验内容(1)选择一个调度算法,实现处理机调度。编写一段程序,实现快速排序。(2)使用Win32APIAPI函数,编写一个包含两个线程的进程,一个线程用于模拟内存分配活动,一个线程用于跟踪第一个线程的内存行为。模拟内存活动的线程可以从一个文件中读出要进行的内存操作。每个内存操作包含如下内容:(3)时间:开始执行的时间;(4)块数:分配内存的粒度;(5)操作:包括保留一个区域、提交一个区域、释放一个区域、回收一个区域以及锁与解锁一个区域;可以将这些操作编号,存放于文件中。(6)大小:指块的大小;(7)访问权限:共五种PAGE_READONLY、PAGE_READWRITE、PAGE_EXCUTE、PAGE_EXECUTE_READ和PAGE_EXECUTE_READWRITE。可以将这些权限编号,存放于文件中。跟踪线程将页面大小、已使用的地址范围、物理内存总量以及虚拟内存总量等信息显示出来。3、实验要求(1)写出源程序,并编译运行(2)详细记录程序调试及运行结果源程序代码:packageOperatingSystem;publicclassPCB{privateStringname;privateintID;privateintra;privateintntime;privateintctime;privateStringstatus;privateintpriority;privateintraLimit;publicPCB(intid,intntime,intpriority,Stringstatus,intra,intraLimit){this.ID=id;this.ra=ra;this.ntime=ntime;this.status=status;this.priority=priority;this.raLimit=raLimit;}publicvoidsetID(intID){this.ID=ID;}publicintgetID(){returnthis.ID;}publicvoidsetRa(intra){this.ra=ra;}publicintgetRa(){returnthis.ra;}publicvoidsetRaLimit(intralimit){this.raLimit=raLimit;}publicintgetRaLimit(){returnthis.raLimit;}publicvoidsetPriority(intpriority){this.priority=priority;}publicintgetPriority(){returnthis.priority;}publicvoidsetNtime(intntime){this.ntime=ntime;}publicintgetNtime(){returnthis.ntime;}publicvoidsetCtime(intctime){this.ctime=ctime;}publicintgetCtime(){returnthis.ctime;}publicvoidsetName(Stringname){this.name=name;}publicStringgetName(){returnthis.name;}publicvoidsetStates(Stringstatus){this.status=status;}publicStringgetStatus(){returnthis.status;}publicbooleanequals(intid){if(this.ID==id)returntrue;elsereturnfalse;}publicStringtoString(){returnthis.ID+_+this.name+_+this.priority+_+this.ra+_+this.ntime+_+this.status+\n;}publicvoidrun(){this.ntime=this.ntime-1;this.ctime=this.ctime+1;if(this.ctime%2==0)this.priority=this.priority-1;}}packageOperatingSystem;importjava.util.ArrayList;importjava.util.Iterator;publicclassPCBlistimplementsIterablePCB{privateArrayListPCBPCBItems;publicPCBlist(){this.PCBItems=newArrayListPCB();}publicArrayListPCBgetPCBItem(){returnthis.PCBItems;}publicIteratorPCBiterator(){returnthis.PCBItems.iterator();}publicvoidaddItem(PCBpcb){this.PCBItems.add(pcb);}publicvoidremoveItem(PCBpcb){this.PCBItems.remove(pcb);}publicPCBgetItem(PCBpcb){for(PCBa:this.PCBItems){if(a.equals(pcb.getID()))returna;}returnnull;}publicPCBgetItem(intid){for(PCBa:this.PCBItems){if(a.equals(id))returna;}returnnull;}publicintgetNumberOfItems(){returnthis.PCBItems.size();}publicString[]getItemsState(){StringitemsStates[]=newString[this.getNumberOfItems()];inti=0;for(Iteratoriterator1=PCBItems.iterator();iterator1.hasNext();){PCBItem=(PCB)iterator1.next();itemsStates[i++]=Item.toString();}returnitemsStates;}}packageOperatingSystem;publicclassResource{privateintra=0;privateintraLimit=0;privateintavailableRa;publicResource(intra,intraLimit){this.ra=ra;this.raLimit=raLimit;}publicvoidsetRa(intra){this.ra=ra;}publicintgetRa(){returnthis.ra;}publicvoidsetRaLimit(intraLimit){this.raLimit=raLimit;}publicintgetRaLimit(){returnthis.raLimit;}publicvoidsetAvailableRa(intavailableRa){this.availableRa=availableRa;}publicintgetAvailableRa(){returnthis.availableRa;}publicStringtoString(){returnthis.ra+_+this.raLimit+_+this.availableRa+\n;}}packageOperatingSystem;importjava.util.ArrayList;importjava.util.Iterator;publicclassResourceRecordsimplementsIterableResource{privateArrayListResourceresoureRecods;publicResourceRecords(){this.resoureRecods=newArrayListResource();}publicIteratorResourceiterator(){returnthis.resoureRecods.iterator();}publicArrayListResourcegetResourceRecods(){returnthis.resoureRecods;}publicvoidaddItem(Resourcere){this.resoureRecods.add(re);}publicvoidremoveItem(Resourcere){this.resoureRecods.remove(re);}publicResourcegetResource(Resourcere){for(Resourcea:this.resoureRecods){if(a.equals(re))returna;}returnnull;}publicResourcegetResource(intre){for(Resourcea:this.resoureRecods){if(a.getRa()==re)returna;}returnnull;}publicintgetNumberOfItems(){returnthis.resoureRecods.size();}publicString[]getItemsState(){StringitemsStates[]=newString[this.getNumberOfItems()];inti=0;for(Iteratoriterator1=this.resoureRecods.iterator();iterator1.hasNext();){ResourceItem=(Resource)iterator1.next();itemsStates[i++]=Item.toString();}returnitemsStates;}}packageOperatingSystem;importjava.util.*;importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;importjavax.swing.event.*;importOperatingSystem.PCB;importOperatingSystem.PCBlist;importOperatingSystem.Resource;importOperatingSystem.ResourceRecords;importOperatingSystem.CPUSchedulingGUI.AddToBAKListener;importOperatingSystem.CPUSchedulingGUI.AddToReadyListener;importOperatingSystem.CPUSchedulingGUI.RemoveListener;importOperatingSystem.CPUSchedulingGUI.ResetListener;importOperatingSystem.CPUSchedulingGUI.ResetSystemListener;importOperatingSystem.CPUSchedulingGUI.StartSystemListener;importOperatingSystem.CPUSchedulingGUI.
本文标题:中南大学操作系统实验报告-(2)
链接地址:https://www.777doc.com/doc-7259395 .html