How to switch to another process at schedule() ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, I'm here again.

I'm trying to do a homework which teacher ask us impelement a simple
EDF scheduling policy.
Now I have maintain a EDF process link-list successfully, and the
link-list is well sorted too.

Then I went to schedule() function, add something like this:

What I want to do is if the scheduler selected an EDF process as next process,
I will like to do is compare this process with the first one process
in EDF link-list.

If it is same process, then we have nothing to do, just context switch
to new process
because it has the earlist deadline.

But if it is not the same process, I would like to replace the "next"
process by the first
process in the EDF linked-list.

I have tried some method, but still can get it work. The following one
works fine,
but when the process has earlier deadline exit, the former process
would not get back
to run queue.

What sould I check now?

Following is the code I tried to get it work, but faild.

================ Code ========================
       next = list_entry(queue->next, task_t, run_list);

       if ( next->policy == SCHED_EDF ) {

           struct task_struct * task = list_entry( edf_queue.next, task_t,
                                                   edf_node );

           if ( task != next ) {
               printk ( "Active EDF[%d]\n", task->pid );
               printk ( "Deactive EDF[%d]\n", next->pid );

               // Works Fine.
               // But how can I get next back to run queue?
               dequeue_task ( task, array );
               set_tsk_need_resched ( next );
		enqueue_task_head (task, array);

               // It will hang up if I let the former process stay in queue.
               /*
               //dequeue_task ( task, array );
               //set_tsk_need_resched (next );
      		enqueue_task_head (task, array);
               rq->nr_running++;
               */
               next = task;
           }
       }
====================== End ==========================
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux