proc.c
//PAGEBREAK!
// Wake up all processes sleeping on chan.
// The ptable lock must be held.
PAGEBREAK.
Wake up all processes sleeping on chan.
The ptable lock must be held.
PAGEBREAK . Wake up all processes sleeping on chan . The ptable lock must be held .
static void
wakeup1(void *chan)
{
  struct proc *p;
  for(p = ptable.proc; p < &ptable.proc[NPROC]; p++)
  {
    if(p->state == SLEEPING && p->chan == chan)
    {
      p->state = RUNNABLE;
    }
      #ifdef MLFQ
      p->tickers=0;
      if(p->priority == 0) {
				c0++;
				for(int i=c0;i>0;i--) {
					q0[i] = q0[i-1];
				}
				q0[0] = p;
			}
			else if(p->priority == 1) {
				c1++;
				for(int i=c1;i>0;i--) {
					q1[i] = q1[i-1];
				}
				q1[0] = p;
			}
			else if(p->priority == 2) {
				c2++;
				for(int i=c2;i>0;i--) {
					q2[i] = q2[i-1];
				}
				q2[0] = p;
			}
      else if(p->priority == 3) {
				c3++;
				for(int i=c3;i>0;i--) {
					q3[i] = q3[i-1];
				}
				q3[0] = p;
			}
			else  {
				c4++;
				for(int i=c4;i>0;i--) {
					q4[i] = q4[i-1];
				}
				q4[0] = p;
			}
      #endif
  }
}
static void wakeup1 ( void * chan ) { struct proc * p ; for ( p = ptable . proc ; p < & ptable . proc [ NPROC ] ; p ++ ) { if ( p -> state == SLEEPING && p -> chan == chan ) { p -> state = RUNNABLE ; } #ifdef MLFQ p -> tickers = 0 ; if ( p -> priority == 0 ) { c0 ++ ; for ( int i = c0 ; i > 0 ; i -- ) { q0 [ i ] = q0 [ i - 1 ] ; } q0 [ 0 ] = p ; } else if ( p -> priority == 1 ) { c1 ++ ; for ( int i = c1 ; i > 0 ; i -- ) { q1 [ i ] = q1 [ i - 1 ] ; } q1 [ 0 ] = p ; } else if ( p -> priority == 2 ) { c2 ++ ; for ( int i = c2 ; i > 0 ; i -- ) { q2 [ i ] = q2 [ i - 1 ] ; } q2 [ 0 ] = p ; } else if ( p -> priority == 3 ) { c3 ++ ; for ( int i = c3 ; i > 0 ; i -- ) { q3 [ i ] = q3 [ i - 1 ] ; } q3 [ 0 ] = p ; } else { c4 ++ ; for ( int i = c4 ; i > 0 ; i -- ) { q4 [ i ] = q4 [ i - 1 ] ; } q4 [ 0 ] = p ; } #endif } }
PAGEBREAK!
PAGEBREAK!