操作系统进程调度子系统的设计与实现课程设计.docx

上传人:b****2 文档编号:16915923 上传时间:2023-04-24 格式:DOCX 页数:35 大小:211.86KB
下载 相关 举报
操作系统进程调度子系统的设计与实现课程设计.docx_第1页
第1页 / 共35页
操作系统进程调度子系统的设计与实现课程设计.docx_第2页
第2页 / 共35页
操作系统进程调度子系统的设计与实现课程设计.docx_第3页
第3页 / 共35页
操作系统进程调度子系统的设计与实现课程设计.docx_第4页
第4页 / 共35页
操作系统进程调度子系统的设计与实现课程设计.docx_第5页
第5页 / 共35页
点击查看更多>>
下载资源
资源描述

操作系统进程调度子系统的设计与实现课程设计.docx

《操作系统进程调度子系统的设计与实现课程设计.docx》由会员分享,可在线阅读,更多相关《操作系统进程调度子系统的设计与实现课程设计.docx(35页珍藏版)》请在冰豆网上搜索。

操作系统进程调度子系统的设计与实现课程设计.docx

操作系统进程调度子系统的设计与实现课程设计

通过编程实现操作系统进程调度子系统的基本功能,其中,必须实现的调度算法有:

先来先服务、时间片轮转、多级反馈轮转法、优先级等,在程序设计过程中,要求要有良好清晰的界面来观测进程调度的执行过程,在每个调度算法展示时,可以看到所有有关的队列结构和其中的内容,如就绪队列、阻塞队列等结构的动态变化的过程

(有些按键功能有待完善,但基本可行,界面挺不错的,嘿嘿,本人用java写的)

以下两个放在文件夹demo里

--------------Demo.java--------------------------------

packagedemo;

importjava.awt.*;

importjava.awt.event.*;

importjava.util.Arrays;

importjavax.swing.*;

importjavax.swing.event.ChangeEvent;

importjavax.swing.event.ChangeListener;

importjavax.swing.table.*;

classDemoFrameextendsJFrameimplementsItemListener,ActionListener,ChangeListener{

/**

*@authordouyuan

*/

privatestaticfinallongserialVersionUID=3847275030452768369L;

JPaneluppanel,leftpanel,rightpanel,right;

JPanell1,l2,r1,r2,pg11,pg12,pg21,pg22,pg23,pg24,pg25,pg26,r11,r12;

JPanelpan;

Imagemag=null;

JTabbedPanetp1,tp2;

JTextAreat1,t2;

JTextFieldProcessN,SourceN,TimeN,TimeSlice;

JLabelbackglabel,uplabel1;

JLabelr1label1,r1label2,r1label3,r1label4;

JLabelr2label1,r2label2,r2label3,r2label4;

ButtonGroupbg;

JRadioButtonb1,b2,b3,b4;

JToolBarjtb;

JButtonbutton1,button2,button3,button4,button5;

TableModelmodel1,model2,model3,model4,model5,model6;

JTabletable1,table2,table3,table4,table5;

Timertimer;

JProgressBarprogress1,progress2;

PCB[]pcbs;

intAlgorithmN,second,minute,hour,usedtime,processn,sourcen,timen,times,a,b;

int[]ReadyQueue,WaitQueue;

staticintrq=0;//记录就绪队列

staticintwq=0;//记录等待队列

staticintut2=0;//记录在时间片内完成的时间数*10

intExecuN=0;//0为没有在执行的进程,在执行中的进程序号为ExecuN-1

staticintsn=0;//记录资源的使用

publicDemoFrame(){

//--------------------------窗口设置---------------------------------------------//

this.setTitle("操作系统进程调度子系统的设计与实现");

this.setIconImage(newImageIcon("src/image/2.png").getImage());

this.setBounds(60,50,1200,700);

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

this.setResizable(false);

//--------------------------变量声明--------------------------------------------//

AlgorithmN=1;

second=0;

minute=0;

hour=0;

usedtime=0;

processn=20;

sourcen=10;

timen=100;

times=10;

a=2;

b=1;

StringColumnsN1[]={"内存中序号","进程名","资源数","优先级","创建时间","总时间","类型"};

ObjectRows1[][]={};

StringColumnsN2[]={"内存中序号","进程名","资源数","优先级","创建时间","总时间","就绪序列号","完成进度"};

ObjectRows2[][]={};

StringColumnsN3[]={"内存中序号","进程名","资源数","优先级","创建时间","总时间","就绪序列号","完成进度"};

ObjectRows3[][]={};

StringColumnsN4[]={"内存中序号","进程名","资源数","优先级","创建时间","总时间","从创建到结束","完成进度"};

ObjectRows4[][]={};

StringColumnsN5[]={"内存中序号","进程名","资源数","优先级","创建时间","总时间","从创建到完成","完成进度"};

ObjectRows5[][]={};

//-----------------------table类-------------------------------------------//

model1=newDefaultTableModel(Rows1,ColumnsN1);

RowSortersorter=newTableRowSorter(model1);

table1=newJTable(model1);

table1.setRowSorter(sorter);//表格排序过滤

table1.getTableHeader().setToolTipText("这个是有初始化进程的表格");//为表头指定说明性文字

model2=newDefaultTableModel(Rows2,ColumnsN2);

RowSortersorter2=newTableRowSorter(model2);

table2=newJTable(model2);

table2.setRowSorter(sorter2);

table2.getTableHeader().setToolTipText("这个是有关就绪进程的表格");

model3=newDefaultTableModel(Rows3,ColumnsN3);

RowSortersorter3=newTableRowSorter(model3);

table3=newJTable(model3);

table3.setRowSorter(sorter3);

table3.getTableHeader().setToolTipText("这个是有关阻塞进程的表格");

model4=newDefaultTableModel(Rows4,ColumnsN4);

RowSortersorter4=newTableRowSorter(model4);

table4=newJTable(model4);

table4.setRowSorter(sorter4);

table4.getTableHeader().setToolTipText("这个是有关未完成进程的表格");

model5=newDefaultTableModel(Rows5,ColumnsN5);

RowSortersorter5=newTableRowSorter(model5);

table5=newJTable(model5);

table5.setRowSorter(sorter5);

table5.getTableHeader().setToolTipText("这个是有关已完成进程的表格");

//----------------------timer-------------------------------------------//

timer=newTimer(1000,null);

//----------------------progress-bar-------------------------------------//

progress1=newJProgressBar();

progress1.setMaximum(20);

progress1.setMinimum(0);

progress1.setValue(0);

progress1.setBounds(20,90,400,20);

progress1.setStringPainted(true);

progress2=newJProgressBar();

progress2.setMaximum(20);

progress2.setMinimum(0);

progress2.setValue(0);

progress2.setBounds(500,90,400,20);

progress2.setStringPainted(true);

//----------------------button----------------------------------------//

button1=newJButton(newImageIcon("src/image/start.png"));

button1.setBounds(1131,446,60,60);

button1.setEnabled(false);

button2=newJButton(newImageIcon("src/image/end.png"));

button2.setBounds(1131,525,60,60);

button2.setEnabled(false);

button3=newJButton(newImageIcon("src/image/endall.png"));

button3.setBounds(1131,604,60,60);

button3.setEnabled(false);

button4=newJButton(newImageIcon("src/image/quit.png"));

button4.setBounds(1131,0,60,60);

button4.setToolTipText("退出Quit");

button5=newJButton(newImageIcon("src/image/starp.png"));

button5.setBounds(1131,360,60,60);

bg=newButtonGroup();

b1=newJRadioButton("先来先服务",newImageIcon("src/image/b1.png"));

b2=newJRadioButton("时间片轮转",newImageIcon("src/image/b2.png"));

b3=newJRadioButton("多级反馈轮转法",newImageIcon("src/image/b3.png"));

b4=newJRadioButton("静态优先级调度",newImageIcon("src/image/b4.png"));

//---------------------label---------------------------------------//

backglabel=newJLabel(newImageIcon("src/image/1.jpg"));

backglabel.setBounds(0,0,1200,700);

uplabel1=newJLabel();

uplabel1.setBounds(5,5,200,45);

uplabel1.setFont(newFont("标楷体",Font.BOLD,30));

uplabel1.setText("时间00:

00:

00");

r1label1=newJLabel("总进程数:

");

r1label1.setFont(newFont("微软雅黑",Font.BOLD,30));

r1label1.setBounds(10,10,200,100);

r1label2=newJLabel("总资源数:

");

r1label2.setFont(newFont("微软雅黑",Font.BOLD,30));

r1label2.setBounds(400,10,200,100);

r1label3=newJLabel("总时间数:

");

r1label3.setFont(newFont("微软雅黑",Font.BOLD,30));

r1label3.setBounds(10,10,200,100);

r1label4=newJLabel("CPU时间片:

");

r1label4.setFont(newFont("微软雅黑",Font.BOLD,30));

r1label4.setBounds(380,10,200,100);

r2label1=newJLabel("正在执行");

r2label1.setBounds(20,20,400,30);

r2label1.setFont(newFont("华文彩云",Font.BOLD,26));

r2label2=newJLabel("");

r2label2.setBounds(150,15,400,40);

r2label2.setFont(newFont("微软雅黑",Font.BOLD,26));

r2label3=newJLabel("进程完成的进度");

r2label3.setBounds(20,60,400,20);

r2label3.setFont(newFont("微软雅黑",Font.BOLD,18));

r2label4=newJLabel("在CPU时间片上的完成的进度");

r2label4.setBounds(500,60,400,20);

r2label4.setFont(newFont("微软雅黑",Font.BOLD,18));

//-------------------textfield----------------------------------//

ProcessN=newJTextField("20",10);

ProcessN.setFont(newFont("标楷体",Font.BOLD,30));

ProcessN.setBounds(160,40,100,40);

SourceN=newJTextField("10",10);

SourceN.setFont(newFont("标楷体",Font.BOLD,30));

SourceN.setBounds(560,40,100,40);

TimeN=newJTextField("100",10);

TimeN.setFont(newFont("标楷体",Font.BOLD,30));

TimeN.setBounds(160,40,100,40);

TimeSlice=newJTextField("10",10);

TimeSlice.setFont(newFont("标楷体",Font.BOLD,30));

TimeSlice.setBounds(560,40,100,40);

//----------------------textarea--------------------------------//

t1=newJTextArea(10,10);

t1.setTabSize(10);

t1.setFont(newFont("标楷体",Font.PLAIN,16));

t1.setEditable(false);

t1.setWrapStyleWord(true);

t1.setText("默认算法为先来先服务"+'\n');

t2=newJTextArea();

t2.setFont(newFont("华文彩云",Font.BOLD,30));

t2.setEditable(false);

t2.setText('\n'+"系统将随机生成进程序列"+'\n');

//---------------------------JTabbedPane-------------------------------//

tp1=newJTabbedPane();

tp2=newJTabbedPane();

//-------------------------panel---------------------------------------//

r1=newJPanel(newGridLayout(1,1));

r1.setBounds(0,0,920,526);

r2=newJPanel();

r2.setLayout(null);

r2.setBorder(BorderFactory.createTitledBorder("工作区域"));

r2.setBounds(0,526,920,120);

r11=newJPanel();

r11.setLayout(null);

r11.setBorder(BorderFactory.createTitledBorder("有关进程数及资源数的设置"));

r12=newJPanel();

r12.setLayout(null);

r12.setBorder(BorderFactory.createTitledBorder("有关时间的设置"));

pg11=newJPanel(newGridLayout(4,1));

pg12=newJPanel(newGridLayout(1,1));

pg21=newJPanel(newGridLayout(1,1));

pg22=newJPanel(newGridLayout(1,1));

pg23=newJPanel(newGridLayout(1,1));

pg24=newJPanel(newGridLayout(1,1));

pg25=newJPanel(newGridLayout(1,1));

tp1.setVisible(true);

tp1.setBounds(r1.getBounds());

l1=newJPanel(newGridLayout(4,1));

l1.setBorder(BorderFactory.createTitledBorder("选择算法"));

l2=newJPanel(newGridLayout(1,1));

l2.setBorder(BorderFactory.createTitledBorder("消息"));

rightpanel=newJPanel();

rightpanel.setLayout(null);

rightpanel.setBounds(210,20,920,644);

uppanel=newJPanel();

uppanel.setBounds(5,20,200,50);

uppanel.setLayout(null);

leftpanel=newJPanel(newGridLayout(2,1));

leftpanel.setBounds(5,75,200,590);

right=newJPanel(newGridLayout(4,1));

right.setBounds(1140,20,60,644);

pan=newJPanel();

pan.setLayout(null);

pan.setBorder(BorderFactory.createTitledBorder("主窗口"));

//--------------------------颜色处理-------------------------------------//

progress1.setBackground(newColor(255,246,143));

progress2.setBackground(newColor(255,246,143));

button1.setBackground(new

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 经管营销 > 财务管理

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1