//调度算法的模拟
//1.SJF 短作业优先算法
#include<stdio.h>
#include <malloc.h>
#include <string>
#include <string.h>
#include <iostream>
using namespace std;
#define N 5 //假设5个进程
struct PCB{
string name;//进程name
int reachTime;//标志进程到达时间
int needTime;//进程所需的时间
bool state;
/*进程的状态,false表示挂起,true表示激活*/
int alltime;//总共所用的时间,即周转时间
bool over; //进程的状态,true表示结束
bool isrunning;
}P[5]; //声明5个进程
void init();
void processSchedule();
void printPCB(PCB P);
int arr[10]; //队列存放可以运行但是没有被调度的进程
int Size = 0; //队列的长度
int RunningP = -1; //当前运行进程编号
void Sort(int a[],int Size);
int main(){
init(); //初始化这五个进程
processSchedule();//进程调度
cout<<"*-----------------------输出部分------------------------*"<<endl;
cout<<"进程名称"<<"\t"<<"到达时间"<<"\t"<<"所需时间"<<"\t"<<"周转时间"<<endl;
计算机操作系统调度算法——短作业优先算法简单实现
最新推荐文章于 2025-04-17 18:03:29 发布