进程调度之FCFS
FCFS调度算法及先到先执行算法,先对进程按时间长短进行排名。再依次输出即可
#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 ; //进程到达时间
};
void main()
{
int amount; //进程数
int i;
int j;
char n[10];
int a;
int r;
struct JOB f[N];
printf("请输入进程数(2-24)\n");
scanf("%d",&amount);
for(i = 0; i < amount; i++)
{
printf("请输入进程名,线程到达时间,线程运行时间\n");
scanf("%s %d %d",&f[i].name, &f[i].atime, &f[i].runtime);
}
//------------------FCFS调度算法----------------------
printf("\n------------------FCFS调度算法排序前----------------------\n");
printf("进程名\t到达时间\t运行时间\n");
for(i = 0; i < amount; i++)
{
printf("%s\t%d\t\t%d\n", f[i].n