I have code based on the POSIX skin. For a (python related) reason, I
had to re-compile Xenomai with --enable-dlopen-skins. The result is that
unless I call rt_task_shadow, my threads don't work like they used to.
Although I *think* my code works by mixing rt_task_shadow with the POSIX
skin I'm not convinced that it is legit. Can anybody advise?
Essentially, I need a CAN object that is instantiated and configured
from main(). Then that object (pointer) is passed to a thread that
Read/Write from/to it. Here a simplified version.
A few questions:
1) Can I mix rt_task_shadow from a thread created from POSIX skin?
2) If yes, is there limitations to POSIX function? For example, are the
attributes of any pthread_attr_t discarded after calling rt_task_shadow?
4) How about a thread that doesn't use RTDM? Will it have "RT" latencies
or rt_task_shadow must be called for that too?
4) Is it just better to port everything to native skin?
class CANdevice{
RT_TASK task; // Added this for calling rt_task_shadow
public:
CANdevice(){
// add this block to Read/Write from main()
if( rt_task_self() == NULL )
{ rt_task_shadow( &task, "can", prio, flags); }
}
void Configure(){ /* Read()/Write() */ }
void Read() { /* rt_dev_recv */
void Write(){ /* rt_dev_send */
};
void* thread( void* argv ){
CANdevice* can = (CANdevice*)argv;
/* add this block to Read/Write from thread(void*) */
RT_TASK task;
if( rt_task_self() == NULL ){
printf( "NOT A XENOMAI TASK\n" );
rt_task_shadow(&task, "thread", prio, flags );
}
pthread_make_periodic_np ( pthread_self(), &starttp, &periodtp );
while(1){
can->Read();
can->Write();
pthread_wait_np(&overruns_r);
}
return NULL;
}
int main(){
CANdevice can;
can.Configure(); // main() must be Xenomai task to use RTDM
pthread_t tid;
pthread_attr_t attr;
struct sched_param param;
param.sched_priority = prio;
// attributes
pthread_attr_init( &attr );
pthread_attr_setschedpolicy( &attr, SCHED_FIFO );
pthread_attr_setschedparam( &attr, ¶m );
// thread must be Xenomai task to use RTDM
pthread_create( &tid, &attr, thread, (void*)&can );
}
/sl
_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help