[ECOS] Re: Réf. : Twothreads.c without cyg_thread_delay

Gary Thomas gary@mlbassoc.com
Fri Nov 24 16:48:00 GMT 2006


David Luca wrote:
> Timeslicing is enabled by default in eCos kernel.
> This is what I'm interested, to see two threads of
> same priority working. Using cyg_thread_delay doesn't
> mean much advantage over infinite loops because the
> tasks can be very long in working time before it
> reaches cyg_thread_delay. Its just a cooperative
> multitasking. Timeslicing is the reason I must use
> RTOS. If timeslicing is not working, then eCos is not
> a true RTOS. Anyone tested timeslicing?

Of course!

I just tried it.  I changed the thread function to simply
put a unique value into the platform LEDs - no delays:

/* this is a simple program which runs in a thread */
void simple_program(cyg_addrword_t data)
{
   int message = (int) data;

   printf("Beginning execution; thread data is %d\n", message);
   while (true) {
       HAL_SET_LEDS(1<<data);
   }
}

Using the default scheduler (MLQUEUE), I changed the timeslice count
to be something that I can see (500 ticks = 5 seconds).  Running this,
I see first one value in the LEDS then a different value 5 seconds later.
The pattern repeats, ad nauseum.

Timeslicing definitely works, as do eCos' other scheduling mechanisms.

I believe that you're having trouble with your platform - interrupts aren't
working for your system clock.  Have you tried running the various kernel
tests?

> 
> --- Jean-Marc.Lopez@faiveleytransport.com wrote:
> 
> 
> ---------------------------------
> Hi David.
>  
> 
> Excuse me but with your explanations, it's looks like
> you did not manage properly  the threads priorities. 
> 
>  
> 
> It's just  a problem of Real time OS. 
> 
>  
> 
> If your 2 threads had the same priority, and Thread_1
> never "give the hand" to the kernel, the Thread 2 will
> never run. …Except if you configure the timeSlicing
> option in your kernel. ( never done at this moment). 
> 
>  
> 
> By using a cyg_thread_delay function, we said to the 
> kernel to stop the current Thread ( Thread 1 ) and to
> run the Thread 2 ( or the thread who have the higtest
> priority after the Thread1). 
> 
>  
> 
> By setting the timeslicing option, the kernel will
> commute between the 2 threads every x ms ( depending
> of your kernel configuration) even if threads have the
> same priority. (but not experimented yet). 
> 
>  
> 
>  
> LPZ
> 
>  
> -----David Luca <davidluca3000@yahoo.com> a écrit :
> -----
> 
> Pour : ecos-devel <ecos-devel@sourceware.org>,
> ecos-discuss <ecos-discuss@sourceware.org>
> De : David Luca <davidluca3000@yahoo.com>
> Date : 24/11/2006 14:29
> Objet : Twothreads.c without cyg_thread_delay
> 
> 
> 
> 
> 
> Hello,
> Today I started twothreads.c application, but I
> replaced printf(not working yet on my platform) with
> leds. My question is, without the cyg_thread_delay, is
> it possible to run concurrently the two threads?
> Because if I comment this function, only one task is
> running, I can see that only one led is turn on and
> off.
> Thank you in advance,
> David Luca.


-- 
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------

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



More information about the Ecos-discuss mailing list