rtai_bits problem (Newbie)

TI5 Jörg Nädele naedele at mail.fh-ulm.de
Wed Jun 8 21:45:41 CEST 2005


Hello RTAI experts,
i've got a problem with rtai_bits.
First of all I'd like to show you what I want to make:

I've two non-periodic tasks:
rt_set_oneshot_mode();
rt_mount();
rt_task_init(&mytask1,timing,0,3000,2,0,0);
rt_task_init(&mytask2,print,0,3000,0,0,0);
rt_task_resume(&mytask1);
rt_task_resume(&mytask2);

Furtheron I have two bit fields:
rt_bits_init(&bits,0xFFFF0000);
rt_bits_init(&bits2,0xFFFF0000);

And one interrupt:
rt_request_global_irq(7,(void*)interrupt_handler);
rt_enable_irq(7);

The interrupt handler is called and should wake up mytask1 with:
rt_bits_signal(&bits, SET_BITS, 0x0000FFFF);


mytask1 runs in a while(1) loop:

while(1){
  //wait until interupt signals via rt_bits_signal
  rt_bits_wait(&bits, ALL_SET, 0x0000FFFF, NOP_BITS,0,&resulting_mask);
   . . .
   //made some calculations
   //mytask1 signals mytask2 to wake up
   rt_bits_signal(&bits2, SET_BITS, 0x0000FFFF);
   // *********** 1) ************
   // ***************************
}

mytask2 runs also in a while(1) loop:
while(1){
  //wait until mytask1 signals via rt_bits_signal
  rt_bits_wait(&bits2, ALL_SET, 0x0000FFFF, NOP_BITS,0,&resulting_mask);
   . . .
   //some outputs
   //mytask1 signals mytask2 to wake up
   // *********** 2) ************
   // ***************************
}

To marks 1) and 2)
Currently I'm setting the bits field back to 0xFFFF0000 with:
rt_bits_signal(&bits, CLR_BITS, 0x0000FFFF); // 1)
rt_bits_signal(&bits2, CLR_BITS, 0x0000FFFF); // 2)

Because I'd like to avoid that in the next loop the rt_bits_wait would be
jumped over.


But there is a strange behaviour:
If I use only:
rt_bits_signal(&bits, CLR_BITS, 0x0000FFFF);
The PC hangs up
But if I use:
rt_bits_signal(&bits, CLR_BITS, 0x0000FFFF);
rt_sleep(nano2count(someMiliSec));
The PC doesn't hang up.

The problem is now that I run in timing problems because of the sleep :o(

Does any one out there knows what I'm doing wrong?

Thanks a lot for your help!
BR
Joerg Naedele
Ulm / Germany





More information about the Rtai mailing list