通过对进程调度算法的模拟,进一步理解进程的基本概念,加深对进程运行状态和进程调度过程、调度算法的理解。
github下载地址:
https://github.com/musuixin/Operating-system-process-simulation
流程图:
/**
* 功能描述:PCB的父类,包含PCB的主要信息,以及方法。
* @date 2018.11.5
* @version 2.0
*/
class PCB {
int id;
String pname;
int daodatime;
int fuwutime;
int runtime=0;
String state="w";
int priority=0;
int startblock;
int blocktime;
PCB(){
}
/**
* 功能描述:用于非优先权进程调度的PCB构造函数,不包含优先权的构造,默认其为0
*/
PCB(int id,String pname, int daodatime, int fuwutime,int startblock,int blocktime) {
this.id=id;
this.pname = pname;
this.daodatime = daodatime;
this.fuwutime = fuwutime;
this.startblock=startblock;
this.blocktime=blocktime;
}
/**
* 功能描述:用于优先权调度的构造函数。
*/
PCB(int id,String pname, int daodatime, int fuwutime,int priority,int startblock,int blocktime) {
this.id=id;
this.pname = pname;
this.daodatime = daodatime;
this.startblock=startblock;
this.blocktime=blocktime;
this.fuwutime = fuwutime;
this.priority = priority;
}
/**
* @return PCB原始信息
*/
String information(){
return id+" "+pname+" "+daodatime+" "+priority+" "+fuwutime+" "+startblock+" "+blocktime;
}
/**
* @return PCB当前信息
*/
String messages(){
return id+" "+pname+" "+runtime+" "+priority+" "+state;
}
}
import java.util.LinkedList;
import java.util.Scanner;
/***
* 功能描述:继承父类PCB,实现接口Comparable,先来先服务PCB
* @date 2018.11.05
* @version 2.0
*/
class FcFcPCB extends PCB implements Comparable