要求:
- 设计一个完整的进程调度系统,至少包含三种常用的算法(FCFS、SPF、静态优先权、响应比、时间片轮转),系统中至少包含5个进程,并且能够体现进程的动态申请;
- 定义PCB;
- 结果要能够显示出进程的调度序列及进入系统的时间、运行时间、完成时间、周转时间、带权周转时间、优先权等必要信息;
- 设计的输入数据要能体现算法的思想
Code:
PCB:
package pms_os.entity;
public class PCB {
private String Name;
private boolean has_serviced;
private int arrive_Time;
private int service_Time;
private int serviced_Time;
private int start_Time;
private int end_Time;
private double around_Time;
private double around_Right_Time;
@Override
public String toString() {
return "进程名称:" + Name +
", 到达时间:" + arrive_Time +
", 服务时间:" + service_Time +
", 开始执行时间:" + start_Time +
", 完成时间:" + end_Time +
", 周转时间:" + around_Time +
", 带权周转时间:" + around_Right_Time;
}
public String getName() {
return Name;
}
public void setName(String name) {
Name = name;
}
public boolean ishas_serviced() {
return has_serviced;
}
public void sethas_serviced(boolean has_serviced) {
this.has_serviced = has_serviced;
}
public int getArrive_Time() {
return arrive_Time;
}
public void setArrive_Time(int arrive_Time) {
this.arrive_Time = arrive_Time;
}
public int getService_Time() {
return service_Time;
}
public void setService_Time(int service_Time) {
this.service_Time = service_Time;
}
public int getServiced_Time() {
return serviced_Time;
}
public void setServiced_Time(int serviced_Time) {
this.serviced_Time = serviced_Time;
}
public int getStart_Time() {
return start_Time;
}
public void setStart_Time(int start_Time) {
this.start_Time = start_Time;
}
public int getEnd_Time() {
return end_Time;
}
public void setEnd_Time(int end_Time) {
this.end_Time = end_Time;
}
public double getAround_Time() {
return around_Time;
}
public void setAround_Time(double around_Time) {
this.around_Time = around_Time;
}
public double getAround_Right_Time() {
return around_Right_Time;
}
public void setAround_Right_Time(double around_Right_Time) {
this.around_Right_Time = around_Right_Time;
}
}
Main:
package pms_os;
import pms_os.entity.PCB;
import pms_os.service.*;
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
static ArrayList<PCB> p_list = new ArrayList<PCB>();
static Scanner input = new Scanner(System.in);
public static void main(String[] args) {
Main os_main = new Main();
System.out.println("欢迎使用进程管理系统,请按照提示输入进程信息。");
boolean is_exit = false;
boolean is_firsr = true;
boolean is_restar = false;
while (true) {
if (is_firsr || is_restar) {
p_list.clear();
os_main.Input();
}
while (true) {
is_firsr = false;
is_restar = false;
os_main.show();
int choose = Integer.parseInt(input.nextLine());
ArrayList<PCB> list1 <