preemption question

Joel Sherrill joel.sherrill at OARcorp.com
Thu Mar 14 17:17:05 UTC 2002



gregory.menke at gsfc.nasa.gov wrote:
> 
>  > Hi,
>  >
>  > if :
>  >
>  > ***********************************
>  > long c1, c2, c3;
>  >
>  > rtems_task t1(
>  >   rtems_task_argument argument
>  > )
>  > {
>  >     c1=0;
>  >     while(1){
>  >         c1++;
>  >     }
>  > }
>  >
>  > rtems_task t2(
>  >   rtems_task_argument argument
>  > )
>  > {
>  >     c2=0;
>  >     while(1){
>  >         c2++;
>  >     }
>  > }
>  > rtems_task t3(
>  >   rtems_task_argument argument
>  > )
>  > {
>  >
>  >     c3=0;
>  >     while(1){
>  >         c3++;
>  >     }
>  > }
>  >
>  > ***********************************
>  > and  tasks mode = RTEMS_PREEMPT + RTEMS_NO_TIMESLICE, with egal priority.
>  >
>  > Which has to be the result after n second?
>  >
>  > c1 >0
>  > c2 =0
>  > c3 =0
>  >
>  > or
>  >
>  > c1 >0
>  > c2 >0
>  > c3 >0
>  >
> 
> Assuming a short enough runtime so the vars don't roll over, the first
> scenario is what you should see.  If you enable timeslicing, then
> scenario #2 should appear.  Be sure to make your variables above of
> type volatile... ;)

I would also add that you need to configure a clock driver AND
make sure the task that is going to report the values of c[1-3]
is letting the other tasks run.

> Gregm

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



More information about the users mailing list