进程调度之SPF
SPF算法,即短进程优先执行算法。
每次在进程队列中找到已到达的最短进程,并执行该进程(执行完标记该进程)
#include <stdio.h>
#include <string.h>
#define N 24
struct JOB{
char name[10] ; //进程名
int atime ; //到达时间
int runtime ; //运行时间
int ftime ; //结束时间
int total ; //周转时间
float welght ; //周转系数
int arun ; //进程到达时间
int flag; //进程结束标志
};
struct JOB f[N];
int Total = 0;
float Welght = 0;
int Runtime = 0;
void print(int i);
void main()
{
int amount; //进程数
int i;
int j;
int minindex = -1; //记录最短进程下标
int mintime = 0x7fffffff; //记录最短进程时间
char n[10];
int a;
int r;
printf("请输入进程数(2-24)\n");
scanf("%d",&amount);
for(i = 0; i < amount; i++)
{
printf("请输入进程名,进程到达时间,进程运行时间\n");
scanf("%s %d %d",&f[i].name, &