kernel/sched.c
void insert_to_ready_queue( process* proc ) {
  sprint( "going to insert process %d to ready queue.\n", proc->pid );
  // if the queue is empty in the beginning
  if( ready_queue_head == NULL ){
    proc->status = READY;
    proc->queue_next = NULL;
    ready_queue_head = proc;
    return;
  }

  // ready queue is not empty
  process *p;
  // browse the ready queue to see if proc is already in-queue
  for( p=ready_queue_head; p->queue_next!=NULL; p=p->queue_next )
    if( p == proc ) return;  //already in queue

  // p points to the last element of the ready queue
  if( p==proc ) return;
  p->queue_next = proc;
  proc->status = READY;
  proc->queue_next = NULL;

  return;
}
//
// insert a process, proc, into the END of ready queue.
//
insert a process, proc, into the END of ready queue.
insert a process proc into the END of ready queue .
void insert_to_ready_queue( process* proc ) {
  sprint( "going to insert process %d to ready queue.\n", proc->pid );
  if( ready_queue_head == NULL ){
    proc->status = READY;
    proc->queue_next = NULL;
    ready_queue_head = proc;
    return;
  }
  process *p;
  for( p=ready_queue_head; p->queue_next!=NULL; p=p->queue_next )
    if( p == proc ) return;  
  if( p==proc ) return;
  p->queue_next = proc;
  proc->status = READY;
  proc->queue_next = NULL;
  return;
}
void insert_to_ready_queue ( process * proc ) { sprint ( " \n " , proc -> pid ) ; if ( ready_queue_head == NULL ) { proc -> status = READY ; proc -> queue_next = NULL ; ready_queue_head = proc ; return ; } process * p ; for ( p = ready_queue_head ; p -> queue_next != NULL ; p = p -> queue_next ) if ( p == proc ) return ; if ( p == proc ) return ; p -> queue_next = proc ; proc -> status = READY ; proc -> queue_next = NULL ; return ; }
insert a process, proc, into the END of ready queue.
insert a process proc into the END of ready queue .
// if the queue is empty in the beginning // ready queue is not empty // browse the ready queue to see if proc is already in-queue //already in queue // p points to the last element of the ready queue