操作系统进程调度仿真程序源码(5)

2019-08-31 15:10

static int id=0;

int times=0; //打印运行结果次数 boolean active=true; //运行与暂停标志 int king=-1; //定时进程到时标志 boolean Unstop=false; //king is running ! boolean kill=false; //阻止监视线程的运行 JFrame frame;

JLabel jl1,jl2,jl3,jl4,jl5,jl6,jl7,jl8,jl9,jl10,jl11; JScrollPane jsp0,jsp1,jsp2,jsp3,jsp4,jsp5; JTextField now,tm,start;

JComboBox mode,priorityBox;

JButton createprocess,controll,save,exit;

MTable runprocess,ready1,ready2,ready3,interrupted,finish;

public MainProgramme(){

frame=new JFrame(\进程调度仿真——3118310_池毓兴&&1928105_王慧娟\ frame.setSize(800,700);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container c=frame.getContentPane(); c.setLayout(null); c.setBounds(0,0,800,650);

jl1=new JLabel(\当前时间:\ jl1.setForeground(Color.red); jl1.setBounds(10,10,70,20); c.add(jl1);

now=new JTextField(5);

Thread thread0=new Thread(new Runnable(){ public void run(){ try{

while(true)

{

Date time=new Date();

String nowtime=String.format(\ now.setText(nowtime); Thread.sleep(1000); }

}catch(InterruptedException e) { e.printStackTrace(); } } });

thread0.start();

now.setEditable(false);

now.setBackground(Color.black); now.setForeground(Color.green); now.setBounds(80,10,60,20); c.add(now);

jl2=new JLabel(\调度模式:\ jl2.setForeground(Color.red); c.add(jl2);

jl2.setBounds(280,10,70,20);

String items[]={\静态时间片轮转法\动态时间片轮转法\多级反馈调度算法\ mode=new JComboBox(items); mode.setSelectedIndex(0);

mode.addItemListener(new ModeChoice()); mode.setEditable(false);

mode.setSize(2,18);

c.add(mode); //调度模式设置 mode.setBounds(350,10,150,20);

jl4=new JLabel(\优先级选择:\ jl4.setForeground(Color.red); jl4.setBounds(10,35,90,20); c.add(jl4);

Object itm[]={1,2,3,4,5,6,7,8,9,10}; priorityBox=new JComboBox(itm); priorityBox.setSelectedIndex(4);

priorityBox.addItemListener(new ItemListener(){ public void itemStateChanged(ItemEvent e){ String stri=e.getItem().toString(); pri=Integer.parseInt(stri); }

});

priorityBox.setEditable(false);

priorityBox.setBounds(100,35,50,20);

c.add(priorityBox); //优先级输入

jl3=new JLabel(\运行耗时:\ jl3.setForeground(Color.red); jl3.setBounds(200,35,70,20); c.add(jl3);

tm=new JTextField(5);

tm.setBounds(270,35,80,20);

c.add(tm); //运行耗时输入

jl11=new JLabel(\开始时间:\ jl11.setForeground(Color.red); jl11.setBounds(400,35,70,20); c.add(jl11);

start=new JTextField(5);

start.setBounds(470,35,120,20);

c.add(start); //运行耗时输入

createprocess=new JButton(\创建进程\

createprocess.setBounds(650,35,100,25); c.add(createprocess);

createprocess.addActionListener(this); //监听器

controll=new JButton(); //进程控制 if(active)

controll.setText(\暂停运行\ else

controll.setText(\开始运行\ controll.setBounds(650,5,100,25);

c.add(controll);

controll.addActionListener(this); //监听器

jl8=new JLabel(\当前进程:\ jl8.setForeground(Color.red);

jl8.setBounds(50,60,150,20); c.add(jl8);

//-----------------------------运行进程JTable

String[] name1={\进程ID\优先级\提交时间\运行耗时\开始时间\运行计时\时间片\

nm1=new Vector();

for(int column=0;column

runprocess=new MTable(runData,nm1);

// runprocess.setPreferredScrollableViewportSize(new Dimension(500,50)); // runprocess.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

runprocess.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); runprocess.setSelectionBackground(Color.yellow); runprocess.setSelectionForeground(Color.red); // runprocess.setRowHeight(30); jsp0=new JScrollPane();

jsp0.setViewportView(runprocess); jsp0.setBounds(50,85,700,37);

c.add(jsp0);

jl5=new JLabel(\高优先级就绪队列:\ jl5.setForeground(Color.red); jl5.setBounds(50,140,120,20);

c.add(jl5);

//---------------------------高优先级就绪队列JTable

String name2[]={\进程ID\优先级\提交时间\运行耗时\定时启动\ nm2=new Vector(); for(int column=0;column

ready1=new MTable(readyData1,nm2);

// DefaultTableModel model2 = new DefaultTableModel(); // ready1.setmodel(model2);

// ready1.setPreferredScrollableViewportSize(new Dimension(500,100)); // ready1.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

ready1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); ready1.setSelectionBackground(Color.yellow); ready1.setSelectionForeground(Color.red); // ready1.setRowHeight(30); jsp1=new JScrollPane();

jsp1.setViewportView(ready1); jsp1.setBounds(50,165,700,100); c.add(jsp1);

jl9=new JLabel(\中优先级就绪队列:\ jl9.setForeground(Color.red); jl9.setBounds(50,280,120,20);

c.add(jl9);

//---------------------------中优先级就绪队列JTable

String name[]={\进程ID\优先级\提交时间\运行耗时\开始时间\ nm=new Vector(); for(int column=0;column

ready2=new MTable(readyData2,nm);

// DefaultTableModel model2 = new DefaultTableModel(); // ready2.setmodel(model2);

// ready2.setPreferredScrollableViewportSize(new Dimension(500,100)); // ready2.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

ready2.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

ready2.setSelectionBackground(Color.yellow); ready2.setSelectionForeground(Color.red); // ready2.setRowHeight(30); jsp4=new JScrollPane();

jsp4.setViewportView(ready2); jsp4.setBounds(50,305,340,80); c.add(jsp4);

jl10=new JLabel(\低优先级就绪队列:\ jl10.setForeground(Color.red);

jl10.setBounds(410,280,120,20); c.add(jl10);

//---------------------------低优先级就绪队列JTable ready3=new MTable(readyData3,nm);

// DefaultTableModel model2 = new DefaultTableModel(); // ready3.setmodel(model2);

// ready3.setPreferredScrollableViewportSize(new Dimension(500,100)); // ready3.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

ready3.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); ready3.setSelectionBackground(Color.yellow); ready3.setSelectionForeground(Color.red); // ready.setRowHeight(30); jsp5=new JScrollPane();

jsp5.setViewportView(ready3); jsp5.setBounds(410,305,340,80); c.add(jsp5);

jl6=new JLabel(\阻塞队列:\ jl6.setForeground(Color.red);

jl6.setBounds(50,400,70,20); c.add(jl6);

//------------------------------------阻塞队列JTable

String name3[]={\进程ID\优先级\提交时间\运行耗时\定时启动\ nm3=new Vector();

for(int column=0;column

}

interrupted=new MTable(waitData,nm3);

// interrupted.setPreferredScrollableViewportSize(new Dimension(440,80)); // interrupted.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

interrupted.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); interrupted.setSelectionBackground(Color.yellow); interrupted.setSelectionForeground(Color.red);


操作系统进程调度仿真程序源码(5).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:古代散文名篇英译1

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: