原题:实验二 作业调度---阅读调试实验
1.阅读下面源代码,完善程序空白处内容。
2.阅读代码,写出源程序采用什么调度算法、算法流程图和程序功能。
3.解释作业控制块构JCB的定义和作用。
4.为main()写出每行的注释。
5.调试并运行代码,写出结果。
本文先解读代码,再在代码之后给出算法流程图。
逐段代码解析:
头文件、全局变量、自定义数据结构
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define getjcb(type) (type*)malloc(sizeof(type))
int n;//作业数
float T1=0,T2=0;//所有作业周转时间、带权周转时间总和
int times=0;//系统时间
struct jcb//作业控制块
{
char name[10];//作业标识符或作业名称
int reachtime;//到达时刻
int starttime;//开始运行时刻
int needtime;//要求服务时间
int finishtime;//作业完成时刻
float cycletime;//作业周转时间
float cltime;//带权周转时间
char state;//作业状态&#