Page 1 of 1

cooperativ scheduling, some questions

Posted: Fri Oct 07, 2011 8:39 am
by CalM
Hi

again there is somthing i'm just wondering about. The cooperative Scheduling mechanism and the used chSchReadyI call gives me some questions, or may suggestions. I am using the 2.2.6 source.
If i am right the current Task is moved from running state, if preempted, back in the ready list. If this is done it will be inserted just befor the next lower priority thread, meaning that in coopmode with every reschedule the cooperative threads, if more then one will rotate in the list. In this case, if i'am not wrong, i would like to have the thread inserted direct after the next highter prior thread. Or did i get something totally wrong ?

Regards

CalM

Re: cooperativ scheduling, some questions

Posted: Fri Oct 07, 2011 9:50 am
by Giovanni
Hi,

If i am right the current Task is moved from running state, if preempted, back in the ready list.


When preemption occurs the current thread always goes behind any other ready thread with equal or greater priority, it loses its rotation turn among threads with equal priority. Of course it can't go behind a thread with lower priority or ahead of a thread with higher priority, that would be a violation of queue ordering.

The only options we have are to insert it behind or ahead of threads with equal priority in order to maintain correct ordering. In ChibiOS the thread is put behind its peers in order to enforce a quick rotation among threads with same priority. Are you suggesting something different?

Giovanni

Re: cooperativ scheduling, some questions

Posted: Fri Oct 07, 2011 11:24 am
by CalM
Hi

i would suggest, if possible, to add a additional option in config for reenquieng behaviour of a preempted task. Using a simple #define in the Scheduler, the cooperativ behaviour should be switchible between Rotating / Round Roobin, and pure First Come First Serve. This would be interresting in some cases, where multiple Task with same Priority may execute an are preempted, as runtime is way more predictible than with the current implimentation, and this is what i would expect form a coop schedule. But this are my thoughts about this.

CalM

Re: cooperativ scheduling, some questions

Posted: Fri Oct 07, 2011 11:43 am
by Giovanni
A new option would not be needed, the behavior could be associated to CH_TIME_QUANTUM=0. This new behavior would make threads with equal priority purely cooperatively scheduled.

I have to think about this, it is feasible but I need to assess impact.

Giovanni

Re: cooperativ scheduling, some questions

Posted: Fri Oct 07, 2011 2:22 pm
by CalM
Thanks for this quick answare Giovanni

CalM

Re: cooperativ scheduling, some questions

Posted: Sun Jan 29, 2012 10:50 pm
by Giovanni
After a while, I have news about this topic, probably it will be implemented exactly as discussed after the 2.4.0 release, it will be part of some improvements to the kernel scheduled for 2.5.x.

Giovanni