您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 薪酬管理 > 操作系统实验 进程调度和内存管理 java语言版本
源代码:第一个类:divDTOpublicclassdivDTO{privateintdivBase;privateintlength;privateintdivFlag;publicdivDTO(intdivBase,intlength,intdivFlag){this.divBase=divBase;this.divFlag=divFlag;this.length=length;}publicdivDTO(){}publicvoidsetDivBase(intbase){this.divBase=base;}publicintgetDivBase(){returnthis.divBase;}publicvoidsetLength(intlength){this.length=length;}publicintgetLength(){returnthis.length;}publicvoidsetDivFlag(intflag){this.divFlag=flag;}publicintgetDivFalg(){returnthis.divFlag;}}2.第二个类:PcbDTOpublicclassPcbDTO{staticfinalintRunning=1;staticfinalintReady=2;staticfinalintWaiting=3;privateStringprocessName;privateintrunTime;privateintprority;privateintprocessState;privateintbase;privateintlimit;privateintpcbFlag;publicPcbDTO(Stringname,inttime,intpro,intbase,intlimit){this.processName=name;this.runTime=time;this.prority=pro;this.processState=0;this.limit=limit;this.base=base;}publicPcbDTO(){this.pcbFlag=0;}publicvoidsetProcessName(Stringname){this.processName=name;}publicStringgetProcessName(){returnprocessName;}publicvoidsetRunTime(inttime){this.runTime=time;}publicintgetRunTime(){returnthis.runTime;}publicvoidsetPrority(intprority){this.prority=prority;}publicintgetPrority(){returnthis.prority;}publicvoidsetProcessState(intstate){this.processState=state;}publicStringgetProcessState(){Strings=newString();if(this.processState==1){s=running;}elseif(this.processState==2){s=ready;}elseif(this.processState==3){s=waiting;}returns;}publicintgetBase(){returnthis.base;}publicvoidsetBase(intbase){this.base=base;}publicvoidsetLimit(intlimit){this.limit=limit;}publicintgetLimit(){returnthis.limit;}}第三个类:主类importjavax.swing.*;importjava.util.*;importjava.awt.*;importjava.awt.event.*;importjavax.swing.event.*;publicclassMainFrame{privateJListreadyList;privateJListwaitingList;privateJListjobList;privateJButtonsusButton;privateJButtonrelaxButton;privateJButtonstartButton;privateJButtonnewButton;privateJLabelnameLabel;privateJLabelprorityLabel;privateJLabeltimeLabel;privateJLabeljobLabel;privateJLabelreadyLabel;privateJLabelwaitingLabel;privateJLabelrunningLabel;privateJLabelspaceLabel;privateJLabeldivLabel;privateJLabelallocLabel;privateJTablereadyTable;privateJTablerunningTable;privateJTabledivTable;privateJTableallocTable;privateJTextFieldnameText;privateJTextFieldtimeText;privateJTextFieldspaceText;privateJComboBoxprorityCom;privateJPanelnewPanel;privateJPanelwaitingPanel;privateJPanelreadyPanel;VectorjobVectorName;VectorjobDtoVector;VectorwaitingVectorName;VectorwaitingDtoVector;PcbDTO[]readyDtoArray;PcbDTO[]newDtoArray;divDTO[]divDtoArray;PcbDTO[]newSort;Object[][]readydata;Object[][]runningdata;Object[][]divdata;Object[][]allocdata;intfirst;intend;intpoint;PcbDTOa;publicMainFrame(){a=newPcbDTO();first=0;end=0;point=0;JFramejf=newJFrame(进程调度-ws);Containerc=jf.getContentPane();c.setLayout(null);//c.setBackground(Color.pink);newPanel=newJPanel();newPanel.setLayout(null);waitingPanel=newJPanel();waitingPanel.setLayout(null);//waitingPanel.setBackground(Color.pink);readyPanel=newJPanel();readyPanel.setLayout(null);susButton=newJButton(挂起);relaxButton=newJButton(释放);startButton=newJButton(开始);newButton=newJButton(新建进程);nameLabel=newJLabel(进程名);prorityLabel=newJLabel(优先级);timeLabel=newJLabel(运行时间);jobLabel=newJLabel(后备队列);readyLabel=newJLabel(就绪队列);waitingLabel=newJLabel(等待队列);runningLabel=newJLabel(运行进程);spaceLabel=newJLabel(需要空间);divLabel=newJLabel(未分分区表);allocLabel=newJLabel(内存分配表);nameText=newJTextField();timeText=newJTextField();spaceText=newJTextField();prorityCom=newJComboBox();prorityCom.setToolTipText(优先级);readyDtoArray=newPcbDTO[6];newSort=newPcbDTO[6];for(inti=0;i6;i++){newSort[i]=newPcbDTO();}newDtoArray=newPcbDTO[100];jobDtoVector=newVector();jobVectorName=newVector();waitingDtoVector=newVector();waitingVectorName=newVector();divDtoArray=newdivDTO[20];for(inti=0;i20;i++){divDtoArray[i]=newdivDTO();divDtoArray[i].setDivFlag(0);}divDtoArray[0].setDivFlag(1);divDtoArray[0].setDivBase(20);divDtoArray[0].setLength(180);readydata=newObject[6][4];runningdata=newObject[2][3];divdata=newObject[20][3];allocdata=newObject[20][3];String[]col1={进程,时间,优先级,状态};String[]col2={进程,时间,优先级};String[]col3={起址,长度,状态};String[]col4={起址,长度,占用进程};readyTable=newJTable(readydata,col1);//readyTable.setEnabled(false);runningTable=newJTable(runningdata,col2);runningTable.setRowHeight(22);runningTable.setEnabled(false);allocTable=newJTable(allocdata,col4);allocTable.setEnabled(false);divTable=newJTable(divdata,col3);divTable.setEnabled(false);divTable.setValueAt(String.valueOf(20),0,0);divTable.setValueAt(String.valueOf(180),0,1);divTable.setValueAt(String.valueOf(1),0,2);JScrollPanerunningSP=newJScrollPane();JScrollPanereadySP2=newJScrollPane();JScrollPanedivSP=newJScrollPane();JScrollPaneallocSP=newJScrollPane();runningSP.getViewport().add(runningTable);readySP2.getViewport().add(readyTable);divSP.getViewport().add(divTable);allocSP.getViewport().add(allocTable);//int[]prorityArray=newint[10];for(inti=0;i10;i++){prorityCom.addItem(i);//prorit
本文标题:操作系统实验 进程调度和内存管理 java语言版本
链接地址:https://www.777doc.com/doc-3874774 .html