[Again] Help: RTEMS Threads, Preemptation and Time slicing...

Alex kbyte at iol.pt
Mon Nov 1 10:34:06 UTC 2004


Mr joel,

I saw the online docs before I post my message and I realised that preemptation could be handled through posix api, so
my program is targeted to posix but as I cant switch the preemptation flag with posix I mixed posix and rtems std api and I wrote the following:


...
rtems_task_mode(RTEMS_PREEMPT|RTEMS_TIMESLICE, RTEMS_PREEMPT_MASK|RTEMS_TIMESLICE_MASK,&old_mode)
...

in the thread source code and in the main thread source code.
As I know, the instruction turns on preemptation and time slice, right?
We can mix posix and rtems std api in the same program, right?

Am I confusing any concepts about this?

ok, but I will study the rtems scheduler source code to see what is happening,

Thanks to all of you.

Alex








http://www.rtems.org/onlinedocs/releases/rtemsdocs-
> 4.6.2/share/rtems/html/c_user/c_user00050.html
> And POSIX does not give this level of control over the threading
> attributes.  You have SCHED_FIFO, SCHED_RR, etc.  See
> 
> 
> http://www.rtems.org/onlinedocs/releases/rtemsdocs-
> 4.6.2/share/rtems/html/posix_users/posix_users00278.html


----- Mensagem Original -----
De: Joel Sherrill joelOARcorpcom <joel.sherrill at OARcorp.com>
Data: Sabado, 30 de Outubro de 2004, 15:05
Assunto: Re: [Again] Help: RTEMS Threads, Preemptation and Time slicing...

> Thomas Doerfler wrote:
> > Alex,
> > 
> > first of all: would you mind switching the "urgent" flag off, 
> > when you send mail to the rtems mailing list? I am sure the 
> > issue is important and maybe also urgent for you, but on a 
> > mailing list it looks like "read my message first, the others 
> > are not so important" and I am sure this is not what you really 
> > want to look like :-)
> > 
> > I am not so familiar with the POSIX API, but I would guess that  
> > disabling preemption will also disable timeslicing. And, if you 
> > did not modify your source code after your first mail, your 
> > system clock driver is still not active, therefore the system 
> > has no time information and no ability for timeslicing.
> 
> Preemption MUST be enabled to have timeslicing.  See
> 
> http://www.rtems.org/onlinedocs/releases/rtemsdocs-
> 4.6.2/share/rtems/html/c_user/c_user00050.html
> And POSIX does not give this level of control over the threading
> attributes.  You have SCHED_FIFO, SCHED_RR, etc.  See
> 
> 
> http://www.rtems.org/onlinedocs/releases/rtemsdocs-
> 4.6.2/share/rtems/html/posix_users/posix_users00278.html
> --joel
> > wkr,
> > thomas.
> > 
> > 
> > 
> >>Thank you to all of you, but let me explain better what I want:
> >>
> >>I know that my sample code is "dummy", but no problem, what I 
> want is to make some threading tests to rtems for i386 arch, so, 
> sometimes, the "dummy" projects are the best to test the real 
> capabilities of the systems, right?, because, if people always 
> write fine and objective programs we never test the system in 
> other (dumies, may be :-) ) conditions.
> >>
> >>So, what I want it to have one thread running (like the "dummy" 
> for cicle I wrote) and I wat to see the other thread, executing 
> the same dummy code, to enter in the cpu DUE to time slicing. I 
> dont want to use bloking instructions like sleeps, "wait for 
> single object" and somethings like these. 
> >>I already tested the rtems threads with this kind of blocking 
> instructions and the systems work fine, but now I want to see 
> thread switching between threads with same priority, due to time 
> slicing.>>
> >>In my sample program, I think I turned off preemptation and I 
> turned on the time slicing right? But the system doesnt switch 
> between the threads... 
> >>
> >>Is this a rtems scheduler bug?
> >>
> >>Is this a bug in my code? (I thing it is, but where?)
> >>
> >> I am a beginner in rtems and I need help from you...
> >>
> >>
> >>Thanks once again...
> >>
> >>Alex
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>----- Mensagem Original -----
> >>De: Joel Sherrill joelOARcorpcom <joel.sherrill at OARcorp.com>
> >>Data: Quinta-Feira, 28 de Outubro de 2004, 12:24
> >>Assunto: Re: Help: RTEMS Threads, Preemptation and Time slicing...
> >>
> >>
> >>>Ian Caddy wrote:
> >>>
> >>>>Hi Alex,
> >>>>
> >>>>If your threads are the same priority, pre-emption will not 
> >>>
> >>>cause one of 
> >>>
> >>>>them to stop, as it will only pre-empt for HIGHER priority 
> threads.>>>>
> >>>>In this case, you will need to configure these threads for 
> round-
> >>>
> >>>robbin 
> >>>
> >>>>(or timeslicing) to achieve what you are asking.
> >>>>
> >>>>In saying that though, your system design should never, in 
> >>>
> >>>practise, 
> >>>
> >>>>consist of tasks that are continuously running as no other 
> task 
> >>>
> >>>of a 
> >>>
> >>>>lower priority level will ever get to run in this sort of 
> >>>
> >>>system.  A 
> >>>
> >>>>normal system design will have tasks waiting on things from 
> >>>
> >>>other tasks, 
> >>>
> >>>>or if not, sleeps that allow the task to yield to lower 
> priority 
> >>>
> >>>tasks.
> >>>I find that often people have threads that either execute much 
> quicker>>>then the timeslicing quantum or have no scheduling 
> points so 
> >>>unless 
> >>>timeslicing is enabled, there is no switching.
> >>>
> >>>Unless you configure the system differently, the timeslice 
> quantum 
> >>>is 10 
> >>>milliseconds which is a LOT of CPU cycles on most modern CPUs.
> >>>
> >>>Tasking Design Rule: Find ways for your tasks to naturally 
> block 
> >>>so they
> >>>spent most of their life blocked.
> >>>
> >>>--joel
> >>>
> >>>
> >>>>I hope this helps.
> >>>>
> >>>>regards,
> >>>>
> >>>>Ian Caddy
> >>>>
> >>>>
> >>>>Alex wrote:
> >>>>
> >>>>
> >>>>>Hi all,
> >>>>>I am making little rtems programs involving threads and the 
> >>>
> >>>POSIX API.
> >>>
> >>>>>I want to create a program that launchs 2 threads via posix 
> >>>
> >>>calls. 
> >>>
> >>>>>Then I want to split the processor attent to both threads, i 
> >>>
> >>>mean, 
> >>>
> >>>>>both threads must execute in "parallel" and not to
> >>>>>wait one from another...
> >>>>>
> >>>>>The RTEMS manual says the scheduler look to the different 
> taks 
> >>>
> >>>in this 
> >>>
> >>>>>order:
> >>>>>Priority, preemptation (when activated) and then time slicing 
> >>>
> >>>(when 
> >>>
> >>>>>activated), right?
> >>>>>
> >>>>>So, in the rtems program I launch the 2 extra threads with 
> >>>
> >>>equal 
> >>>
> >>>>>priority, priority 1! For each thread, including the main 
> >>>
> >>>thread I 
> >>>
> >>>>>turn on the preemptation and time slicing, but the
> >>>>>second extra thread only starts execution when the first 
> extra 
> >>>
> >>>thread 
> >>>
> >>>>>finishs its execution.
> >>>>>
> >>>>>I cant understand why... :-(
> >>>>>
> >>>>>Note: If I use a, for example, the sleep() instruction in the 
> >>>
> >>>body of 
> >>>
> >>>>>the thread, the processor
> >>>>>is switch to the other extra thread in a good way, but if i 
> >>>
> >>>dont use 
> >>>
> >>>>>functions that transfer the
> >>>>>execution to other threads, the processor is never switched 
> to 
> >>>
> >>>other 
> >>>
> >>>>>threads...
> >>>>>Can you help me? How to execute the 2 extra threads at the 
> same 
> >>>
> >>>time 
> >>>
> >>>>>while the main thread is waiting for the 2 extra threads?
> >>>>>by the way, is there any way to turn on preemptation and time 
> >>>
> >>>slicing 
> >>>
> >>>>>using only posix api?
> >>>>>
> >>>>>
> >>>
> >>>
> >>>-- 
> >>>Joel Sherrill, Ph.D.             Director of Research & Development
> >>>joel at OARcorp.com                 On-Line Applications Research
> >>>Ask me about RTEMS: a free RTOS  Huntsville AL 35805
> >>>   Support Available             (256) 722-9985
> >>>
> >>>
> >>
> >>________________________________________________________________________________
> >>A protecção do e-mail contra vírus é cada vez mais necessária!
> >>Proteja a sua Caixa de Correio: 
> http://www.iol.pt/correio/rodape.php?dst=0409301>>
> > 
> > 
> > --------------------------------------------
> > IMD Ingenieurbuero fuer Microcomputertechnik
> > Thomas Doerfler           Herbststrasse 8
> > D-82178 Puchheim          Germany
> > email:    Thomas.Doerfler at imd-systems.de
> > PGP public key available at: http://www.imd-
> > systems.de/pgp_keys.htm
> > 
> 
> 
> -- 
> Joel Sherrill, Ph.D.             Director of Research & Development
> joel at OARcorp.com                 On-Line Applications Research
> Ask me about RTEMS: a free RTOS  Huntsville AL 35805
>    Support Available             (256) 722-9985
> 
> 

________________________________________________________________________________
Um acesso à internet com anti-vírus, bloqueador de janelas e caixa de correio com 21 MB?
IOL. Tem tudo para ser mais simples.
Saiba como instalar: http://www.iol.pt/correio/rodape.php?dst=0409231




More information about the users mailing list