preemption question

gregory.menke at gsfc.nasa.gov gregory.menke at gsfc.nasa.gov
Thu Mar 14 15:42:46 UTC 2002


 > 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... ;)

Gregm





More information about the users mailing list