Re: How to switch to another process at schedule() ?

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

 



On Wed, 28 Jun 2006, Brian Hsu wrote:

> Hi, I'm here again.
>
> I'm trying to do a homework which teacher ask us impelement a simple
> EDF scheduling policy.

Since this is really homework, you really should ask these questions
to your teacher or a teachers assistant.

>
> 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);

enqueue_task_head only puts the task at the front of it's prio queue.
If next is higher in priority than task (as it probably is since it was
picked) than next will be queued again.

>
>                 // It will hang up if I let the former process stay in queue.

It hangs because you keep scheduling next (it's has the highest prio)
but you keep setting need_resched, and thus it goes into the scheduler
an infinit amount of times.

>                 /*
>                 //dequeue_task ( task, array );
>                 //set_tsk_need_resched (next );
>        		enqueue_task_head (task, array);
>                 rq->nr_running++;
>                 */
>                 next = task;
>             }
>         }


-- Steve

-
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