求大神看看这三个算法先来先服务、最高优先权、时间片轮转算法
求各位大神帮我看看这三个算法的意思,最好能多注释一下,看不懂诶void FCFS() //先来先服务调度算法
{
if(queRead>=0)
{
queRun = queRead;
pcbs[queRun].nStatus = PCB::kRun;
if(pcbs[queRead].nPointer!=-1)
{
queRead = pcbs[queRead].nPointer;
}
else
queRead = -1;
}
}
void Priority() //优先权调度算法
{
int tmp=queRead,tmpi=queRead,tmpq=pcbs[queRead].priority;
while(tmp!=-1)
{
if(pcbs[tmp].priority>tmpq)
{
tmpq = pcbs[tmp].priority;
tmpi = tmp;
}
tmp = pcbs[tmp].nPointer;
}
if(tmpi==queRead)
queRead = pcbs[queRead].nPointer;
queRun = tmpi;
pcbs[queRun].nStatus = PCB::kRun;
}
void RR() //时间片轮转调度算法
{
if(queRead==-1 || pcbs[queRead].nStatus==PCB::kRun)
return;
pcbs[queRun].nStatus = PCB::kReady;
int tmp = queRead;
while(pcbs[tmp].nPointer!=queRun && tmp>0)
tmp = pcbs[tmp].nPointer;
if(tmp<0)
pcbs[queRun].nPointer = queRead;
queRun = queRead;
pcbs[queRun].nStatus = PCB::kRun;
if(pcbs[queRead].nPointer>=0)
queRead = pcbs[queRead].nPointer;
else
{
for(int i=0;i<32;i++)
if(pcbs[i].nStatus==PCB::kReady)
{
queRead = i;
break;
}
}
}