Change_Scheduling_Policy

来源:互联网 发布:php二维数组排序函数 编辑:程序博客网 时间:2024/06/08 14:30
int Change_Scheduling_Policy(int policy,int quantum){ struct Kernel_Thread *thread,*ithread;  int i;  if(policy==0)              { if(g_SchedPolicy==0)return 0;                if(g_SchedPolicy==1){ for(i=1;i<MAX_QUEUE_LEVEL;++i)                                                {thread=Get_Front_Of_Thread_Queue(&s_runQueue[i]);                                                 while(thread!=0){                                                 ithread=Get_Next_In_Thread_Queue(thread);                                                 thread->currentReadyQueue=0;                                                 Remove_From_Thread_Queue(&s_runQueue[i],thread);                                      Add_To_Back_Of_Thread_Queue(&s_runQueue[0],thread);                                                                                                  thread=ithread;}                                                              }                                           g_Quantum=quantum;                                           g_SchedPolicy=0;                                               }                                                       }  if(policy==1){ if(g_SchedPolicy==0){                                        thread=Get_Front_Of_Thread_Queue(&s_runQueue[0]);                                       while(thread!=0)                                                      {if(thread->priority==0)break;                                                       thread=Get_Next_In_Thread_Queue(thread);                                                       }                                       thread->currentReadyQueue=3;                                       Remove_From_Thread_Queue(&s_runQueue[0],thread);                                       Add_To_Front_Of_Thread_Queue(&s_runQueue[3],thread);                                       g_Quantum=quantum;                                       g_SchedPolicy=1;                                       }                 if(g_SchedPolicy==1)return 0;                }  return 0;}

原创粉丝点击