//--------------------------------------------------------------------------
void  getnewqueue_fun(PCB P[MAXP],int n,PCB *H[3],int time,int isstop,int d)
{                                         /*获得新就绪队列*/
      static int now=0;
      int i;
      PCB *q,*q1,*q2;
      for(i=now;i<n;i++)                   /*将已提交进程插入就绪队列*/
         if((P[i].arrive)<=time)
           {  now++;
              if(H[P[i].grade]==NULL)
                H[P[i].grade]=&P[i];
              else{q=H[P[i].grade];
                   while(q->next!=NULL)
                     q=q->next;
                   q->next=&P[i];
                  }
           }
   if(isstop==1)                        /*进程已运行完*/
      H[d]=H[d]->next;
   if(isstop==0)                        /*进程未运行完*/
     {if(H[d]->next!=NULL)
        {q1=H[d];
         q2=q1->next;
         while(q2!=NULL&&(q2->arrive<time||(q2->arrive==time&&q2->serve<H[d]->serve)))
            {q1=q1->next;
             q2=q1->next;
            }
         if(q2==NULL)
            {q=H[d];
             q1->next=q;
             H[d]=H[d]->next;
             q->next=NULL;
            }
         else if(q1!=NULL)
            {q=H[d];
             q1->next=q;
             H[d]=H[d]->next;
             q->next=q2;
            }
        }
      }
   }

//----------------------------------------