This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Round robin scheduler question


> > I think I favour option 2.
>
> Actually, a simpler option might be to make your two threads call
> cyg_thread_yield() every so often. That will cause the cpu to be
> passed between the two threads and does not require you to modify
> eCos.
If I get Ian's situation, it goes like this --

Thread A (highest priority)
while (control-c-flag not set)
 { dump global counters; sleep for time ZZZ }

What is relation b/w ZZZ and NNN / time-slice??

Thread D (second highest priority)
while (1)
{ sleep for time NNN ; if control-c then set control-c-flag }

Thread B/C (third highest priority, both having same priority)
while (1)
{ increment corresponding global counter }

If  his setup is like this, then what he wants, for that he will need to modify
appropriate scheduler to small extent.  Considering this is the case and he is
using mlqueue scheduler on NOSMP configuration,

here is a quick way to do it...
queue->rotate() for current level happens under timeslice_cpu when timeslice is
over and that's what put the current thread at the end of current-level-queue.

Introduce a global variable (say timeover).
set timeover=0 when switching to new thread in unlock_inner (sched.cxx)

set timeover=1 when enter timeslice_cpu function (mlqueue.cxx)
and in the function schedule() (mlqueue.cxx)

#ifdef  CYGPKG_KERNEL_SMP_SUPPORT
....
#else
     register cyg_uint32 index;
--- add these ---
    if  (timeover != 1)
   {  (&sched->run_queue[(get_current_thread()->priority)] ) -> rotate(); }
--------------------------
     HAL_LSBIT_INDEX(index,queue_map);

we could have avoided variable timeover and instead used comparison (that will
not work as desired in one boundary condition)

  timeslice_count [cpu_this] != CYGNUM_KERNEL_SCHED_TIMESLICE_TICKS

hope it helps
sandeep




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.511 / Virus Database: 308 - Release Date: 8/19/2003


-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]