C语言遇到报这个错误要怎么改while ((temp=PopReady())!=-1)这句一运行就报错expected unqualifiled-id before’while‘
#include<stdio.h>
#include<windows.h>
#define N 10
#define SLOT 5
typedef enum
{
Running,
Aready,
Blocking
} ProStatus;
typedef struct
{
int name;
ProStatus status;
int ax,bx,cx,dx;
int pc;
int psw;
int next;
} PCB;
typedef struct
{
int head;
int tail;
} Ready;
int PSW,AX,BX,CX,DX,PC,TIME;
PCB pcbArea[N];
int run;
Ready ready;
int pfree;
void InitRun()
{
run=-1;
}
void InitReady()
{
ready.head=ready.tail=-1;
}
void InitFree()
{
int temp;
for(temp=0;temp<N-1;temp++)
{
pcbArea[temp].next=temp+1;
}
pcbArea[temp].next=-1;
pfree=0;
}
int PopReady()
{
int temp;
if(ready.head==-1)
{
printf("就绪队列为空,不能出队。\n");
return -1;
}
temp=ready.head ;
ready.head =pcbArea[temp].next ;
if(ready.head ==-1)
ready.tail =-1;
pcbArea[temp].next =-1;
return temp;
}
int PopFree()
{
int temp;
if(pfree==-1)
{
printf("空闲队列为空,不能出队。\n");
return -1;
}
temp=pfree;
pfree=pcbArea[temp].next ;
pcbArea[temp].next =-1;
return temp;
}
void PushReady(int x)
{
int temp;
if(ready.head ==-1)
{
ready.head =x;
ready.tail =x;
}
else
{
temp=ready.tail ;
ready.tail =x;
pcbArea[temp].next=x;
}
pcbArea[ready.tail ].next =-1;
}
void CreatePCB(int x,PCB pcb)
{
pcbArea[x].ax =pcb.ax;
pcbArea[x].bx =pcb.bx ;
pcbArea[x].cx =pcb.cx ;
pcbArea[x].dx =pcb.dx ;
pcbArea[x].name =pcb.name ;
pcbArea[x].next =-1;
pcbArea[x].pc =pcb.pc ;
pcbArea[x].psw =pcb.psw ;
pcbArea[x].status =pcb.status ;
}
void Create(PCB pcb)
{
int temp;
if(pfree==-1)
{
printf("空闲队列为空,不能创建进程。\n");
return;
}
temp=PopFree();
pcb.status =Aready;
CreatePCB(temp,pcb);
PushReady(temp);
}
void Schedule()
{
int temp;
if(ready.head ==-1)
{
printf("系统中没有进程可以调度。");
return;
}
}
//temp=PopReady();
while ((temp=PopReady())!=-1)
{
pcbArea[temp].status =Running;
TIME=SLOT;
Sleep(5000);
AX=pcbArea[temp].ax ;
BX=pcbArea[temp].bx ;
CX=pcbArea[temp].cx ;
DX=pcbArea[temp].dx ;
PC=pcbArea[temp].pc ;
PSW=pcbArea[temp].psw ;
run=temp;
printf("当前运行的程序:\n");
printf("进程号:%d\n",pcbArea[run].name );
printf("进程状态:%d\n",pcbArea[run].status );
printf("寄存器内容:\nAX\tBX\tCX\tDX\tPC\tPSW\n");
printf("%d\t%d\t%d\t%d\t%d\t%d\n",pcbArea[run].ax,pcbArea[run].bx,pcbArea[run].cx,pcbArea[run].dx,pcbArea[run].pc,pcbArea[run].psw);
}
void main()
{
int temp;
PCB tmp_pcb;
printf("请输入进程号,以负数为结束(进程号应保持唯一)。\n\n按任意键进入输入模式:");
getchar();
InitRun();
InitReady();
InitFree();
printf("请开始输入进程号:\n");
while(1)
{
scanf("%d",&temp);
if(temp<0)
break;
tmp_pcb.name=temp;
tmp_pcb.ax=temp;
tmp_pcb.bx=temp;
tmp_pcb.cx=temp;
tmp_pcb.dx=temp;
tmp_pcb.pc=temp;
tmp_pcb.psw=temp;
Create(tmp_pcb);
}
printf("\n");
Schedule();
}