Skip to contentSkip to conversation

Problems with Threads and RTnet

Xenomai-help Karl Reichert 3 participants 6 messages Jun 26, 2008 – Jul 1, 2008

lore
Share & tools
lore
#0 lore raw
Quoted 14 lines
Quoted 3 lines · Karl Reichert

Hello list,

I have some problems with RTnet and threads. I create two thread via

rt_task_spawn(), one is sending and one is receiving (non-blocking) frames over rtnet.

Quoted 2 lines

Each task is existed with return (I also tried rt_task_delete()) and the

main-function is waiting for task-termination via rt_task_join().

Quoted 2 lines

When I run this program the first time, everything is fine. When I run

it a second time without rebooting, I can't receive any more frames (returnvalue -1).

Quoted 1 line
Quoted 10 lines
Quoted 1 line

So it seems that the termination of the tasks and the main-function from

the first run failed to free the "RTnet resources", too.

Quoted 2 lines

Any idea, what I'am doing wrong?

What version of Xenomai are you running ? Do not you get error messages in the console ?

Signature · 1 line
                                                  Gilles.

I'm running Xenomai 2.4.3 with Rtnet 0.9.10

And sorry for the mistake, rt_dev_recv() returns with -110 which means "connection timeout". There might be some problems with the socket, but I don't have a clue, what's going on.

I do not get any error messages in console. Neither dmesg nor /var/log/sys reports an error.

Best regards,
Karl

Signature · 1 line
von Karl Reichert
#1 lore raw
Quoted 34 lines
Quoted 5 lines
Quoted 3 lines · Karl Reichert

Hello list,

I have some problems with RTnet and threads. I create two thread via

rt_task_spawn(), one is sending and one is receiving (non-blocking)

frames

Quoted 3 lines

over rtnet.

Quoted 2 lines

Each task is existed with return (I also tried rt_task_delete()) and

the

Quoted 7 lines

main-function is waiting for task-termination via rt_task_join().

Quoted 2 lines

When I run this program the first time, everything is fine. When I run

it a second time without rebooting, I can't receive any more frames (returnvalue -1).

Quoted 2 lines

So it seems that the termination of the tasks and the main-function

from

Quoted 9 lines

the first run failed to free the "RTnet resources", too.

Quoted 2 lines

Any idea, what I'am doing wrong?

What version of Xenomai are you running ? Do not you get error messages in the console ?

Signature · 1 line
                                                  Gilles.

I'm running Xenomai 2.4.3 with Rtnet 0.9.10

And sorry for the mistake, rt_dev_recv() returns with -110 which means "connection timeout". There might be some problems with the socket, but I don't have a clue, what's going on.

Quoted 6 lines

I do not get any error messages in console. Neither dmesg nor /var/log/sys reports an error.

Best regards,
Karl

Forgot to close the socket when program finishes, this is why the second run always failed. Now it works :)

I thought that the socket will be closed automatically when the program exits, as this is the case in POSIX?!
Is there a reason why this is not done in RTnet? Or would there be a possibility to give at least a warning that there are still open sockets, when a program exits? This would prevent others to get the same issues.

Thanks for all your input!
Karl

Signature · 1 line
von Karl Reichert
#2 lore raw
Quoted 6 lines · Karl Reichert

Forgot to close the socket when program finishes, this is why the second run always failed. Now it works :)

I thought that the socket will be closed automatically when the program exits, as this is the case in POSIX?! Is there a reason why this is not done in RTnet?

RTDM should do it with Xenomai 2.4. Are you sure you are not using an older version of the kernel-space support ?

Signature · 1 line
                                                 Gilles.
#3 lore raw
Quoted 9 lines
Quoted 6 lines

Forgot to close the socket when program finishes, this is why the second run always failed. Now it works :)

I thought that the socket will be closed automatically when the program exits, as this is the case in POSIX?! Is there a reason why this is not done in RTnet?

RTDM should do it with Xenomai 2.4. Are you sure you are not using an older version of the kernel-space support ?

No, I'm using Xenomai 2.4.3 without any additional patches, so there is no older version of kernel-space support installed.

Signature · 1 line
von Karl Reichert
#4 lore raw
Quoted 10 lines · Karl Reichert
Quoted 8 lines
Quoted 6 lines

Forgot to close the socket when program finishes, this is why the second run always failed. Now it works :)

I thought that the socket will be closed automatically when the program exits, as this is the case in POSIX?! Is there a reason why this is not done in RTnet?

RTDM should do it with Xenomai 2.4. Are you sure you are not using an older version of the kernel-space support ?

No, I'm using Xenomai 2.4.3 without any additional patches, so there is no older version of kernel-space support installed.

If you have a simple test program, I would be glade to cross-check here.

Moreover, you could have a look at /proc/xenomai/rtdm/open_fildes before and after closing your app. It should give an overview on all open descriptors. If they are stalled after closing your RTnet app, this is definitely a bug that has to be understood and fixed.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2
Corporate Competence Center Embedded Linux
#5 lore raw
Quoted 12 lines
Quoted 10 lines
Quoted 8 lines
Quoted 6 lines

Forgot to close the socket when program finishes, this is why the second run always failed. Now it works :)

I thought that the socket will be closed automatically when the program exits, as this is the case in POSIX?! Is there a reason why this is not done in RTnet?

RTDM should do it with Xenomai 2.4. Are you sure you are not using an older version of the kernel-space support ?

No, I'm using Xenomai 2.4.3 without any additional patches, so there is

no older version of kernel-space support installed.

Quoted 9 lines

If you have a simple test program, I would be glade to cross-check here.

Moreover, you could have a look at /proc/xenomai/rtdm/open_fildes before and after closing your app. It should give an overview on all open descriptors. If they are stalled after closing your RTnet app, this is definitely a bug that has to be understood and fixed.

Jan

After a deeper look I found out, that we are using Xenomai 2.3.2, not 2.4.x So the socket has to be manually closed.

After doing so, /proc/xenomai/rtdm/open_fildes shows no more open descriptors.

So everything is fine, thanks for your help!

Karl

Signature · 1 line
von Karl Reichert