图4响应比高者优先算法流程图
四、实验所需仪器、设备、材料
PC机
五、实验预习要求、实验条件、方法及步骤
1)熟练掌握作业相关的基本概念。
2)熟练掌握作业调度的有关算法。
3)熟练掌握作业调度算法所需的数据结构和算法流程;
4)熟练掌握某一门编程语言,如C、C++或者Dephi等
作业调度算法源代码
#include
#include
#include
#define getpch(type)
(type*)malloc(sizeof(type)) //为进程创建一个空间
struct worktime{
float
Tb; //作业运行时刻
float
Tc; //作业完成时刻
float
Ti; //周转时间
float
Wi; //带权周转时间
};
struct jcb
{
char
name[10]; //作业名
float
subtime; //作业到达时间
float
runtime; //作业所需的运行时间
char
resource; //所需资源
float
Rp; //后备作业响应比
char
state; //作业状态
int
worked_time; //已运行时间
struct
worktime wt;
int
need_time; //要求运行时间
int
flag; //进程结束标志
struct
jcb*
link; //链指针
}*ready=NULL,*p;
typedef struct jcb JCB;
float T=0;
int N;
JCB
*front,*rear; //时间轮转法变量
void
sort()
{
JCB
*first, *second;
int
insert=0; //插入数
if((ready==NULL)||((p->subtime)subtime)))
{
p->link=ready;
ready=p;
T=p->subtime;
p->Rp=1;
}
else
{
first=ready;
second=first->link;
while(second!=NULL)
{
if((p->subtime)subtime))
{
p->link=second;
first->link=p;
second=NULL;
insert=1;
}
else
{
first=first->link;
second=second->link;
}
}
if (insert==0) first->link=p;
}
}
void SJFget()
{
JCB
*front,*mintime,*rear;
int