时间片长度设置
//时间片长度
#define TIME_SLICE 50
进程
//任务的结构体
struct process
{
ll id;
char name[50];
ll runtime;
int priority;
ll intput_time; //输入等待队列的时间
int has_done; //已完成时间
};
输出的时间片信息
//时间片数据
struct TimeSlice {
ll pro_id;
char pro_name[50];
int priority;
int last_time;
};
输入队列
struct WaitList {
//输入队列
int has_done = 0; //已完成任务数
int has_input = 0; //已经输入任务书
int maxnum; //所有任务数
process waitlist[10000];
int find_next(int start, int last) {
//找到当前等待队列中优先级最高的任务,运行
if (start >= last) {
return -1;
}
int next = start;
for (int i = start; i < last; i++) {
if (waitlist[next].<