资源简介
进程调度的设计与实现(有GUI) java
代码片段和文件信息
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.linkedList;
import java.util.Random;
import java.util.Vector;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.Border;
import javax.swing.border.titledBorder;
public class ButtonPanel extends JPanel {
/**
*
*/
private static final long serialVersionUID = 1L;
public ButtonPanel(final ProcessPanel processPanel) {
pidArray = new int[100];
for (int i = 0; i < pidArray.length; i++) {
pidArray[i] = 0;// 表示该进程号空闲
}
// 创建50个就绪队列,这里是用链表,功能是一样的
myQueueVector = new VectornkedList>();
for (int i = 0; i < 50; i++) {
linkedList pcblinkedList = new linkedList();
myQueueVector.add(pcblinkedList);
}
//进程过程
processsStringBuffer = new StringBuffer(“ >>>>>>----The scheduling process----<<<<<<“+‘\n‘);
Border etched = BorderFactory.createEtchedBorder();
Border titleBorder = BorderFactory.createtitledBorder(etched
“Options“ titledBorder.LEFT (int) LEFT_ALIGNMENT new Font(
“Comic Sans MS“ Font.BOLD 15));
setBorder(titleBorder);
setBounds(10 10 1170 75);
setBackground(Color.yellow);
setLayout(new FlowLayout(FlowLayout.CENTER 20 5));
JLabel label = new JLabel(“初始随机新建进程个数:“);
add(label);
numField = new JTextField(10);
add(numField);
JButton creatButton = new JButton(“创建初始进程“);
creatButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
number = Integer.valueOf(numField.getText()); // 获取到初始要创建的进程数
for (int i = 0; i < number; i++) {
creatProcessToQueue(0);
}
processPanel.showProcessInfo();
}
});
add(creatButton);
JButton startButton = new JButton(“进行进程调度“);
startButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
doProcessManager(processPanel);
}
});
add(startButton);
//暂停调度进程
JButton stopButton = new JButton(“暂停进程调度“);
stopButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
processThread.suspend();
}
});
add(stopButton);
// 动态创建一个进程
JButton newButton = new JButton(“新建一个进程“);
newButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
creatProcessToQueue(1);
}
});
add(newButton);
//恢复进程调度
JButton resumeButton = new JButton(“恢复进程调度“);
resumeButton.addActionListener(new ActionListener() {
@Override
pu
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2013-06-03 19:38 OS1--ProcessScheduling\
文件 301 2013-05-27 23:10 OS1--ProcessScheduling\.classpath
文件 393 2013-05-27 23:10 OS1--ProcessScheduling\.project
目录 0 2013-06-03 19:32 OS1--ProcessScheduling\.settings\
文件 598 2013-05-27 23:10 OS1--ProcessScheduling\.settings\org.eclipse.jdt.core.prefs
目录 0 2013-06-03 19:38 OS1--ProcessScheduling\bin\
文件 1234 2013-06-03 19:31 OS1--ProcessScheduling\bin\ButtonPanel$1.class
文件 742 2013-06-03 19:31 OS1--ProcessScheduling\bin\ButtonPanel$2.class
文件 738 2013-06-03 19:31 OS1--ProcessScheduling\bin\ButtonPanel$3.class
文件 676 2013-06-03 19:31 OS1--ProcessScheduling\bin\ButtonPanel$4.class
文件 742 2013-06-03 19:31 OS1--ProcessScheduling\bin\ButtonPanel$5.class
文件 679 2013-06-03 19:31 OS1--ProcessScheduling\bin\ButtonPanel$6.class
文件 2672 2013-06-03 19:31 OS1--ProcessScheduling\bin\ButtonPanel$7.class
文件 4764 2013-06-03 19:31 OS1--ProcessScheduling\bin\ButtonPanel.class
文件 994 2013-06-02 23:35 OS1--ProcessScheduling\bin\PCB.class
文件 1047 2013-06-02 22:14 OS1--ProcessScheduling\bin\PSfr
文件 3746 2013-06-03 19:31 OS1--ProcessScheduling\bin\ProcessPanel.class
文件 495 2013-06-02 22:14 OS1--ProcessScheduling\bin\ProcessScheduling.class
目录 0 2013-06-03 19:38 OS1--ProcessScheduling\src\
文件 7157 2013-06-03 19:31 OS1--ProcessScheduling\src\ButtonPanel.java
文件 892 2013-05-29 18:40 OS1--ProcessScheduling\src\PCB.java
文件 3088 2013-06-03 19:31 OS1--ProcessScheduling\src\ProcessPanel.java
文件 887 2013-06-02 22:14 OS1--ProcessScheduling\src\ProcessScheduling.java
评论
共有 条评论