Meassage Queue c++
Am Donnerstag, 19. Januar 2006 18:04 schrieb Nathaniel Villaume:
Quoted 11 lines
Hi Stephan,
I don't know if it is related, but I wouldn't return a pointer to a local variable:
void *data;
...
return data;Maybe something is happening where when the queue is empty the size is 0 --so malloc returns who-knows-what?
Hi,
thanks for the hint, but I don't think this is the Problem, because the Program crashes befor the read function returns. I think it is related with the way I create/bind the queue in the constructor, but I am not sure.
Please don't think too much about it, I decided to stop my c++ realtime-experiments anyway, will code plain c instead.
Greetings, Stephan
Quoted 13 lines · Stephan Zimmermann
Am Donnerstag, 19. Januar 2006 18:04 schrieb Nathaniel Villaume:
Quoted 11 lines
Hi Stephan,
I don't know if it is related, but I wouldn't return a pointer to a local variable:
void *data;
...
return data;Maybe something is happening where when the queue is empty the size is 0 --so malloc returns who-knows-what?
Quoted 7 lines
Hi,
thanks for the hint, but I don't think this is the Problem, because the Program crashes befor the read function returns. I think it is related with the way I create/bind the queue in the constructor, but I am not sure.Please don't think too much about it, I decided to stop my c++ realtime-experiments anyway, will code plain c instead.
Some further things to try before giving C++ up - and maybe stumbling over the same issue with C:
o Did you mlockall() your program? If not, lazy-mapped pages may cause SEGFAULTS in the RT domain which will kill your program.
o Does your kernel log contain any hints of Xenomai about what's going on?
o Try running your program inside a debugger to catch the fault and its location. When your system is head-less, use gdbserver.
Jan
Quoted 2 lines · Jan Kiszka
Some further things to try before giving C++ up - and maybe stumbling over the same issue with C:
I tryed out xenomai queues in plain C, works perfekt.
Quoted 2 lines
o Did you
mlockall()your program? If not, lazy-mapped pages may cause SEGFAULTS in the RT domain which will kill your program.
I call "mlockall(MCL_CURRENT | MCL_FUTURE);" as one of the first things in main();
Quoted 2 lines
o Does your kernel log contain any hints of Xenomai about what's going on?
No, ist does not contain anything
Quoted 2 lines
o Try running your program inside a debugger to catch the fault and its location. When your system is head-less, use gdbserver.
I tryed debugging, I singlestepped through it and learned that it crashes when calling rt_queue_recv(), but I can not tell why.
maybe it is because I do the "bind-thing" in the constructor, resulting in multiple objects of RT_QUEUE referring to the same queue.
Stephan
Quoted 14 lines · Stephan Zimmermann
Quoted 2 lines · Jan Kiszka
Some further things to try before giving C++ up - and maybe stumbling over the same issue with C:
I tryed out xenomai queues in plain C, works perfekt.
Quoted 2 lines
o Did you
mlockall()your program? If not, lazy-mapped pages may cause SEGFAULTS in the RT domain which will kill your program.I call "
mlockall(MCL_CURRENT | MCL_FUTURE);" as one of the first things inmain();Quoted 2 lines
o Does your kernel log contain any hints of Xenomai about what's going on?
No, ist does not contain anything
Quoted 7 lines
Quoted 2 lines
o Try running your program inside a debugger to catch the fault and its location. When your system is head-less, use gdbserver.
I tryed debugging, I singlestepped through it and learned that it crashes when calling
rt_queue_recv(), but I can not tell why.maybe it is because I do the "bind-thing" in the constructor, resulting in multiple objects of
RT_QUEUEreferring to the same queue.
But this is the idea of a queue: two users are referring to the same object in order to communicate with each other!?
Would you mind to break out a demonstration code of your problem? Just to check if there is some subtle Xenomai issue hidden or if it's an ugly pitfall when using C++ in hard-RT context.
Jan
Quoted 3 lines
Would you mind to break out a demonstration code of your problem? Just to check if there is some subtle Xenomai issue hidden or if it's an ugly pitfall when using C++ in hard-RT context.
Can I send the 'demonstration' code as a complete eclipse managed-make project directly to your email address? It is a little to much (make clean && tar.gz ~500k) to post here I think, even after a cleanup.
Stephan
Hi all,
after Jan looked over my code, it turned out to be a typical self-made ( RTFM somehow...) problem. My code did throw an exception when rt_queue_read() returned a positve value different from zero (which I naturally didn't catch :). This caused an effect that looked like a bigger Problem.
So, after all, it turned out that it is very well possible to use Xenomai in C++ Projects.
Thanks for the great support, Stephan