用类C++编的时间片轮转法模拟进程调度遇到的问题??

来源:百度知道 编辑:UC知道 时间:2024/06/17 22:34:42
问题:我用的优先级调度作业(构成队列)进入内存,进程用时间片轮转调度(队列)。
在dos界面中,可以输入inputjob()中的数据。运行到inputprocess就弹出else中内容,符合if中内容也不执行(你们可以试试),runprocess()也没执行。这是什么问题啊,我找不到毛病。(我编程水平很菜,大家说说问题啊)。

#include "conio.h"
#include "stdio.h"
typedef struct jcb{
char jcbname[4];
int arrivetime;
int runtime;
int priority;
int state;
}jcb;

typedef struct njcb{
jcb data;
struct njcb *next;
}njcb,*ljcb;

typedef struct{
ljcb front;
ljcb rear;
}linkqueue;

int initqueue(linkqueue &q){
//构造一个空队列q
q.front=q.rear=new njcb;
if(!q.front) return 0;
q.front->next=NULL;
return 1;
}
int enqueue(linkqueue &q,jcb e){
//插入元素e作为队列q的新队尾元素
ljcb p=new njcb;
if(!p) printf("存储分配失败");
return 0;
p->data=e;
p->next=NULL;
q.rear->next=p;
q.rear=p;
return 1;
}
int dequeue(linkqueue &q,jcb &e){
//若队列不空,删除q的队头元素,用e返回其值,并返回1;队列若空,返回0
if(q.front==q.rear) return 0;
ljcb p=q.front->next;
e=p->data;
q.front->next=p->next;