* [Xenomai] Context Switch with rtnet
@ 2012-09-14 15:01 Franz Engel
2012-09-16 14:29 ` Jan Kiszka
2012-09-21 9:58 ` Kai Bollue
0 siblings, 2 replies; 13+ messages in thread
From: Franz Engel @ 2012-09-14 15:01 UTC (permalink / raw)
To: xenomai@xenomai.org
Hi,
I've a little problem. I'm using the rtnet.h-header and the following function:
ret = recvfrom ( ethernetConnection.sock, &recBuffer, sizeof ( recBuffer ),0, ( struct sockaddr * ) ðernetConnection.dest_addr,&destlen );
I compiled the program with the xenomai compiling flags and library.
When I look to the xenomai state I get something like this:
CPU PID MSW CSW PF STAT %CPU NAME
22 0 0 834840 0 00000082 0.1 rtnet-stack
22 0 0 1 0 00000082 0.0 rtnet-rtpc
0 6262 2 2 0 00300380 0.0 qs_robotpositio
2 6265 2 6 0 00300380 0.0 qs_robotpositio
0 6266 1 1 0 00300380 0.0 robotrsiinterfa
1 6268 1147 2365 0 00300182 0.8 robotrsiinterfa
You can see, I get a lote of context and module switches just as the rtnet-stack itself. Is that normal?
Thanks in advanced,
Franz
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Xenomai] Context Switch with rtnet
2012-09-14 15:01 [Xenomai] Context Switch with rtnet Franz Engel
@ 2012-09-16 14:29 ` Jan Kiszka
2012-09-20 15:24 ` Franz Engel
2012-09-21 9:58 ` Kai Bollue
1 sibling, 1 reply; 13+ messages in thread
From: Jan Kiszka @ 2012-09-16 14:29 UTC (permalink / raw)
To: Franz Engel; +Cc: xenomai@xenomai.org
On 2012-09-14 17:01, Franz Engel wrote:
> Hi,
>
> I've a little problem. I'm using the rtnet.h-header and the following function:
> ret = recvfrom ( ethernetConnection.sock, &recBuffer, sizeof ( recBuffer ),0, ( struct sockaddr * ) ðernetConnection.dest_addr,&destlen );
>
>
> I compiled the program with the xenomai compiling flags and library.
>
> When I look to the xenomai state I get something like this:
> CPU PID MSW CSW PF STAT %CPU NAME
> 22 0 0 834840 0 00000082 0.1 rtnet-stack
> 22 0 0 1 0 00000082 0.0 rtnet-rtpc
> 0 6262 2 2 0 00300380 0.0 qs_robotpositio
> 2 6265 2 6 0 00300380 0.0 qs_robotpositio
> 0 6266 1 1 0 00300380 0.0 robotrsiinterfa
> 1 6268 1147 2365 0 00300182 0.8 robotrsiinterfa
>
> You can see, I get a lote of context and module switches just as the rtnet-stack itself. Is that normal?
Well, I have no clue what you configured, so I can only guess. If your
task 6268 is a pure RT task that is not supposed to interact with Linux
services, you first of all have a bug in your software stack. You should
look for the reason of those mode switches to Linux, e.g. by asking
Xenomai to raise SIGXCPU when this happens.
Regarding the rtnet-stack context switches: basically, every switch is
one packet arriving at your NIC. Either you are receiving a lot of small
but valid packets or you are on an open network, and that is basically
heavy unrelated broadcast traffic of other sources than the RT device(s).
Jan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 259 bytes
Desc: OpenPGP digital signature
URL: <http://www.xenomai.org/pipermail/xenomai/attachments/20120916/21fcac64/attachment.pgp>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Xenomai] Context Switch with rtnet
2012-09-16 14:29 ` Jan Kiszka
@ 2012-09-20 15:24 ` Franz Engel
2012-09-20 17:33 ` Wolfgang Grandegger
2012-09-20 17:36 ` Gilles Chanteperdrix
0 siblings, 2 replies; 13+ messages in thread
From: Franz Engel @ 2012-09-20 15:24 UTC (permalink / raw)
To: 'Jan Kiszka'; +Cc: xenomai
Hi Jan,
> > Hi,
> >
> > I've a little problem. I'm using the rtnet.h-header and the following
> function:
> > ret = recvfrom ( ethernetConnection.sock, &recBuffer, sizeof (
> > recBuffer ),0, ( struct sockaddr * )
> > ðernetConnection.dest_addr,&destlen );
> >
> >
> > I compiled the program with the xenomai compiling flags and library.
> >
> > When I look to the xenomai state I get something like this:
> > CPU PID MSW CSW PF STAT %CPU NAME
> > 22 0 0 834840 0 00000082 0.1 rtnet-stack
> > 22 0 0 1 0 00000082 0.0 rtnet-rtpc
> > 0 6262 2 2 0 00300380 0.0
> qs_robotpositio
> > 2 6265 2 6 0 00300380 0.0
> qs_robotpositio
> > 0 6266 1 1 0 00300380 0.0
> robotrsiinterfa
> > 1 6268 1147 2365 0 00300182 0.8
> robotrsiinterfa
> >
> > You can see, I get a lote of context and module switches just as the
> rtnet-stack itself. Is that normal?
>
> Well, I have no clue what you configured, so I can only guess. If your
> task 6268 is a pure RT task that is not supposed to interact with Linux
> services, you first of all have a bug in your software stack. You
> should look for the reason of those mode switches to Linux, e.g. by
> asking Xenomai to raise SIGXCPU when this happens.
I use the SIGXCPU signal to look where I get a context switch. It is exactly
in the line of the recvfrom. I get the same result when I step through my
code. I debug from line to line and check the /proc/xenomai/state, so I can
see that the CSW and MSW increases when I step over the recvfrom. I tried my
code also with the native commands, like rt_recvfrom. But the result is the
same.
>
> Regarding the rtnet-stack context switches: basically, every switch is
> one packet arriving at your NIC. Either you are receiving a lot of
> small but valid packets or you are on an open network, and that is
> basically heavy unrelated broadcast traffic of other sources than the
> RT device(s).
>
> Jan
I'm connected to a robot that sends me his position every 4ms.
I send you a minimal example of my code. But I'm not sure if I understand
your question for the configuration correct. Depends the realtime capability
of rtnet only by my kdevelop project (cmake, *.c and *.h) or is it possible
that I miss some settings in the kernel? I start rtnet before I run my
program and I load the modules for my NIC and for UDP etc. Is there
something more what I have to do?
Thanks and regards,
Franz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DemoCSW.tar.gz
Type: application/octet-stream
Size: 3601 bytes
Desc: not available
URL: <http://www.xenomai.org/pipermail/xenomai/attachments/20120920/c87f6809/attachment.obj>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Xenomai] Context Switch with rtnet
2012-09-20 15:24 ` Franz Engel
@ 2012-09-20 17:33 ` Wolfgang Grandegger
2012-09-20 17:36 ` Gilles Chanteperdrix
1 sibling, 0 replies; 13+ messages in thread
From: Wolfgang Grandegger @ 2012-09-20 17:33 UTC (permalink / raw)
To: Franz Engel; +Cc: 'Jan Kiszka', xenomai
On 09/20/2012 05:24 PM, Franz Engel wrote:
> Hi Jan,
>
>>> Hi,
>>>
>>> I've a little problem. I'm using the rtnet.h-header and the following
>> function:
>>> ret = recvfrom ( ethernetConnection.sock, &recBuffer, sizeof (
>>> recBuffer ),0, ( struct sockaddr * )
>>> ðernetConnection.dest_addr,&destlen );
>>>
>>>
>>> I compiled the program with the xenomai compiling flags and library.
>>>
>>> When I look to the xenomai state I get something like this:
>>> CPU PID MSW CSW PF STAT %CPU NAME
>>> 22 0 0 834840 0 00000082 0.1 rtnet-stack
>>> 22 0 0 1 0 00000082 0.0 rtnet-rtpc
>>> 0 6262 2 2 0 00300380 0.0
>> qs_robotpositio
>>> 2 6265 2 6 0 00300380 0.0
>> qs_robotpositio
>>> 0 6266 1 1 0 00300380 0.0
>> robotrsiinterfa
>>> 1 6268 1147 2365 0 00300182 0.8
>> robotrsiinterfa
>>>
>>> You can see, I get a lote of context and module switches just as the
>> rtnet-stack itself. Is that normal?
>>
>> Well, I have no clue what you configured, so I can only guess. If your
>> task 6268 is a pure RT task that is not supposed to interact with Linux
>> services, you first of all have a bug in your software stack. You
>> should look for the reason of those mode switches to Linux, e.g. by
>> asking Xenomai to raise SIGXCPU when this happens.
>
> I use the SIGXCPU signal to look where I get a context switch. It is exactly
> in the line of the recvfrom. I get the same result when I step through my
> code. I debug from line to line and check the /proc/xenomai/state, so I can
> see that the CSW and MSW increases when I step over the recvfrom. I tried my
> code also with the native commands, like rt_recvfrom. But the result is the
> same.
What is the reason for the mode switch? How to get it see:
http://www.rts.uni-hannover.de/xenomai/lxr/source/examples/native/sigdebug.c
Wolfgang.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Xenomai] Context Switch with rtnet
2012-09-20 15:24 ` Franz Engel
2012-09-20 17:33 ` Wolfgang Grandegger
@ 2012-09-20 17:36 ` Gilles Chanteperdrix
1 sibling, 0 replies; 13+ messages in thread
From: Gilles Chanteperdrix @ 2012-09-20 17:36 UTC (permalink / raw)
To: Franz Engel; +Cc: 'Jan Kiszka', xenomai
On 09/20/2012 05:24 PM, Franz Engel wrote:
> Hi Jan,
>
>>> Hi,
>>>
>>> I've a little problem. I'm using the rtnet.h-header and the following
>> function:
>>> ret = recvfrom ( ethernetConnection.sock, &recBuffer, sizeof (
>>> recBuffer ),0, ( struct sockaddr * )
>>> ðernetConnection.dest_addr,&destlen );
>>>
>>>
>>> I compiled the program with the xenomai compiling flags and library.
>>>
>>> When I look to the xenomai state I get something like this:
>>> CPU PID MSW CSW PF STAT %CPU NAME
>>> 22 0 0 834840 0 00000082 0.1 rtnet-stack
>>> 22 0 0 1 0 00000082 0.0 rtnet-rtpc
>>> 0 6262 2 2 0 00300380 0.0
>> qs_robotpositio
>>> 2 6265 2 6 0 00300380 0.0
>> qs_robotpositio
>>> 0 6266 1 1 0 00300380 0.0
>> robotrsiinterfa
>>> 1 6268 1147 2365 0 00300182 0.8
>> robotrsiinterfa
>>>
>>> You can see, I get a lote of context and module switches just as the
>> rtnet-stack itself. Is that normal?
>>
>> Well, I have no clue what you configured, so I can only guess. If your
>> task 6268 is a pure RT task that is not supposed to interact with Linux
>> services, you first of all have a bug in your software stack. You
>> should look for the reason of those mode switches to Linux, e.g. by
>> asking Xenomai to raise SIGXCPU when this happens.
>
> I use the SIGXCPU signal to look where I get a context switch. It is exactly
> in the line of the recvfrom. I get the same result when I step through my
> code. I debug from line to line and check the /proc/xenomai/state, so I can
> see that the CSW and MSW increases when I step over the recvfrom. I tried my
> code also with the native commands, like rt_recvfrom. But the result is the
> same.
Stepping in gdb causes switches to secondary mode (each step is a switch
to secondary mode).
Anyway, you did not tell us:
- what version of xenomai
- what version of the Linux kernel
- what version of the I-pipe patch
- what architecture
- what NIC
you are using.
--
Gilles.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Xenomai] Context Switch with rtnet
2012-09-14 15:01 [Xenomai] Context Switch with rtnet Franz Engel
2012-09-16 14:29 ` Jan Kiszka
@ 2012-09-21 9:58 ` Kai Bollue
2012-09-21 10:02 ` Gilles Chanteperdrix
1 sibling, 1 reply; 13+ messages in thread
From: Kai Bollue @ 2012-09-21 9:58 UTC (permalink / raw)
To: xenomai
On 14.09.2012 17:01, Franz Engel wrote:
> Hi,
>
> I've a little problem. I'm using the rtnet.h-header and the following function:
> ret = recvfrom ( ethernetConnection.sock, &recBuffer, sizeof ( recBuffer ),0, ( struct sockaddr * ) ðernetConnection.dest_addr,&destlen );
Hi,
stupid question: But you do use an rtnet socket, not a normal one, do
you? In this case, shouldn't it be rt_dev_recvfrom(...)?
Kai
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Xenomai] Context Switch with rtnet
2012-09-21 9:58 ` Kai Bollue
@ 2012-09-21 10:02 ` Gilles Chanteperdrix
2012-09-21 10:08 ` Kai Bollue
0 siblings, 1 reply; 13+ messages in thread
From: Gilles Chanteperdrix @ 2012-09-21 10:02 UTC (permalink / raw)
To: Kai Bollue; +Cc: xenomai
On 09/21/2012 11:58 AM, Kai Bollue wrote:
> On 14.09.2012 17:01, Franz Engel wrote:
>> Hi,
>>
>> I've a little problem. I'm using the rtnet.h-header and the following function:
>> ret = recvfrom ( ethernetConnection.sock, &recBuffer, sizeof ( recBuffer ),0, ( struct sockaddr * ) ðernetConnection.dest_addr,&destlen );
>
> Hi,
>
> stupid question: But you do use an rtnet socket, not a normal one, do
> you? In this case, shouldn't it be rt_dev_recvfrom(...)?
When using the posix skin, recvfrom is substituted at compilation (or
more exactly link-edit) time with __wrap_recvfrom, implemented in
libpthread_rt.so, allowing to work with real-time sockets.
(But that works only if you used socket too instead of rt_dev_socket).
--
Gilles.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Xenomai] Context Switch with rtnet
2012-09-21 10:02 ` Gilles Chanteperdrix
@ 2012-09-21 10:08 ` Kai Bollue
0 siblings, 0 replies; 13+ messages in thread
From: Kai Bollue @ 2012-09-21 10:08 UTC (permalink / raw)
To: Gilles Chanteperdrix; +Cc: xenomai
On 21.09.2012 12:02, Gilles Chanteperdrix wrote:
> On 09/21/2012 11:58 AM, Kai Bollue wrote:
>> On 14.09.2012 17:01, Franz Engel wrote:
>>> Hi,
>>>
>>> I've a little problem. I'm using the rtnet.h-header and the following function:
>>> ret = recvfrom ( ethernetConnection.sock, &recBuffer, sizeof ( recBuffer ),0, ( struct sockaddr * ) ðernetConnection.dest_addr,&destlen );
>> Hi,
>>
>> stupid question: But you do use an rtnet socket, not a normal one, do
>> you? In this case, shouldn't it be rt_dev_recvfrom(...)?
> When using the posix skin, recvfrom is substituted at compilation (or
> more exactly link-edit) time with __wrap_recvfrom, implemented in
> libpthread_rt.so, allowing to work with real-time sockets.
>
Ah, sorry, I missed that.
Kai
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Xenomai] Context Switch with rtnet
[not found] <mailman.1.1348308001.4459.xenomai@xenomai.org>
@ 2012-09-22 13:20 ` Franz Engel
2012-09-22 13:33 ` Gilles Chanteperdrix
2012-09-22 13:43 ` Gilles Chanteperdrix
0 siblings, 2 replies; 13+ messages in thread
From: Franz Engel @ 2012-09-22 13:20 UTC (permalink / raw)
To: xenomai
> On Fri, 21 Sep 2012 12:08:40 +0200, Kai Bollue <mlist1@bollue.de>
> > On 21.09.2012 12:02, Gilles Chanteperdrix wrote:
> >> On 09/21/2012 11:58 AM, Kai Bollue wrote:
> >>> On 14.09.2012 17:01, Franz Engel wrote:
> >>> Hi,
> >>>
> >>> I've a little problem. I'm using the rtnet.h-header and the
> following function:
> >>> ret = recvfrom ( ethernetConnection.sock, &recBuffer, sizeof (
> >>> recBuffer ),0, ( struct sockaddr * )
> >>> ðernetConnection.dest_addr,&destlen );
> >> Hi,
> >>
> >> stupid question: But you do use an rtnet socket, not a normal one,
> do
> >> you? In this case, shouldn't it be rt_dev_recvfrom(...)?
> > When using the posix skin, recvfrom is substituted at compilation (or
> > more exactly link-edit) time with __wrap_recvfrom, implemented in
> > libpthread_rt.so, allowing to work with real-time sockets.
> >
>
> Ah, sorry, I missed that.
>
Sorry, I missed to answer on some questions:
Let me explain my problem again. When I run my program ("mytask") the CSW
and MSW increase every time the program receive a message:
CPU PID MSW CSW PF STAT %CPU NAME
0 0 0 396 0 00500080 100.0 ROOT/0
1 0 0 0 0 00500080 100.0 ROOT/1
0 1336 1 1 0 00300380 0.0 kogmo_man
0 0 0 209 0 00000082 0.0 rtnet-stack
0 0 0 1 0 00000082 0.0 rtnet-rtpc
0 0 0 1 0 00000082 0.0 rtcfg-rx
0 5182 1 15 0 00340182 0.0 mytask
0 0 0 143 0 00000000 0.0 IRQ22: rteth0
1 0 0 186 0 00000000 0.0 IRQ22: rteth0
0 0 0 2054479 0 00000000 0.0 IRQ4364: [timer]
1 0 0 547805 0 00000000 0.0 IRQ4364: [timer]
Wolfgang advised me to find the reason for this phenomenon like the program
on this link:
http://www.rts.uni-hannover.de/xenomai/lxr/source/examples/native/sigdebug.c
I tried it and modified my code (see the code further down). When I insert
an "cout" after "rt_task_set_mode(0, T_WARNSW, NULL);" I get a failure
message (so it should work). But when I run this program without the cout I
get no message, but the CSW and MSW counter are still increases.
That's my versions:
rtnet 0.9.12
xenomai 2.5.5.2
linux kernel 2.6.32-20
ubuntu 10.04
i-pipe patch: adeos-ipipe-2.6.32.20-x86-2.7-03.patch
NIC driver: 8139too
CPU: Intel vPro
Any other ideas? Or is it not a problem but the normal state that the
counters increases?
Here is the code of my cmake-file:
cmake_minimum_required(VERSION 2.8)
##################################
# BEGIN OF EDITING THIS TEMPLATE #
##################################
############################################
# PLEASE ENTER HERE THE NAME OF YOUR PROJECT
set(ProjectName robotrsiVersuch) #e.g. "robotdatalogger" (do not forget the
quotes)
PROJECT(${ProjectName})
###############################################
# ENTER HERE THE VERSION NUMBER OF YOUR PROJECT
set(${ProjectName}_VERSION_MAJOR 1)
set(${ProjectName}_VERSION_MINOR 0)
###############################################
# ENABLE OR DIABLE THE USE OF XENOMAI AND QT
option(USE_XENOMAI "xenomai" ON )
option(USE_RTNET "rtnet" ON )
#############################################
# NOW ADD ALL SOURCE FILES OF YOUR PROJECT
# IF YOU'RE USING QT, ALSO ADD ALL HEADERS OF
# QT-OBJECTS, UI-FILES AND RESOURCES
#####################
# INCLUDE DIRECTORIES
set(MAIN_DIR ${PROJECT_SOURCE_DIR}/../..)
set(SOURCE_DIR src)
#############################################
# ENTER THE INSTALL DIRECTORY
# added by stefan.thumfart@profactor.at
set(INSTALLDIR ${MAIN_DIR}/bin)
set(INCLUDES
${SOURCE_DIR}
)
###########
# LIBRARIES
set(EXTRA_LIBS
)
######
# CPPs
set(SOURCES
main.cpp
src/rsiinterface.cpp
src/rsiinterface.h
)
#############
# MOC-Headers
set(MOC_HEADERS
)
##########
# UI-Files
set(UIS
)
###########
# Resources
set(RESOURCES
)
##################################
# END OF EDITING THIS TEMPLATE #
##################################
message (STATUS "Usage of Xenomai: ${USE_XENOMAI}")
message (STATUS "Usage of RTnet: ${USE_RTNET}")
message(STATUS "Generating buid files for project ${ProjectName}, version
${${ProjectName}_VERSION_MAJOR}.${${ProjectName}_VERSION_MINOR}")
include_directories(${INCLUDES})
IF(USE_XENOMAI)
message(STATUS "Starting Xenomai configuration")
message(STATUS "startign RTnet configuration")
include_directories(/usr/local/rtnet/include)
include_directories(/usr/xenomai/include/rtdm)
message(STATUS "RTnet configuration finished")
find_library(XENO_rtdm rtdm /usr/xenomai/lib)
set(EXTRA_LIBS ${EXTRA_LIBS} ${XENO_rtdm})
message(STATUS ${EXTRA_LIBS} )
set(XENOMAI_DIR "/usr/xenomai")
set(XENOMAI_INCLUDE_DIR ${XENOMAI_DIR}/include)
set(XENOMAI_INCLUDE_POSIX_DIR ${XENOMAI_DIR}/include/native)
exec_program("${XENOMAI_DIR}/bin/xeno-config --skin=native --ldflags"
OUTPUT_VARIABLE XENOMAI_EXE_LINKER_FLAGS)
set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS}
${XENOMAI_EXE_LINKER_FLAGS})
exec_program("${XENOMAI_DIR}/bin/xeno-config --skin=native --cflags"
OUTPUT_VARIABLE XENOMAI_DEFINITIONS)
set(EXTRA_DEFINITIONS ${EXTRA_DEFINITIONS} ${XENOMAI_DEFINITIONS})
ADD_DEFINITIONS(${EXTRA_DEFINITIONS})
set(EXTRA_LIBS ${EXTRA_LIBS} rtdk)
message(STATUS ${XENOMAI_EXE_LINKER_FLAGS})
message(STATUS ${XENOMAI_DEFINITIONS})
message(STATUS "Xenomai configuration finished")
ELSE(USE_XENOMAI)
find_library(RT_TIME_LIB rt)
set(EXTRA_LIBS ${EXTRA_LIBS} ${RT_TIME_LIB})
ENDIF(USE_XENOMAI)
IF (USE_RTNET)
ENDIF (USE_RTNET)
add_executable(${ProjectName} ${SOURCES})
TARGET_LINK_LIBRARIES(${ProjectName} ${EXTRA_LIBS})
install(TARGETS ${ProjectName} DESTINATION ${INSTALLDIR})
And this is my cpp:
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <getopt.h>
#include <execinfo.h>
#include <sys/mman.h>
#include <stdexcept>
#include <arpa/inet.h>
#include <native/task.h>
#include "rtdk.h"
#include <rtnet.h>
#define RECBUFFERSIZE 600
#define SENDBUFFERSIZE 300
RT_TASK task;
const char *reason_str[7];
struct conn_t
{
int sock;
struct sockaddr_in dest_addr;
struct sockaddr_in local_addr;
};
struct conn_t getSocket ()
{
struct conn_t ethernetConnection;
//ethernetConnection.dest_addr.sin_family = AF_INET;
ethernetConnection.dest_addr.sin_addr.s_addr = inet_addr
("192.168.100.12");
ethernetConnection.dest_addr.sin_port = htons (6002);
//ethernetConnection.local_addr.sin_family = AF_INET;
ethernetConnection.local_addr.sin_addr.s_addr = inet_addr
("192.168.100.11");
ethernetConnection.local_addr.sin_port = htons (6008);
if ( ( ethernetConnection.sock = socket ( AF_INET, SOCK_DGRAM,
IPPROTO_UDP ) ) < 0 )
{
throw std::runtime_error("Can not open socket");
}
else
{
}
if ( bind ( ethernetConnection.sock, ( struct sockaddr * )
ðernetConnection.local_addr, sizeof ( ethernetConnection.local_addr ) ) <
0 )
{
close ( ethernetConnection.sock );
throw std::runtime_error("Can not bind socket");
}
else
{
}
return ethernetConnection;
}
void task_body (void *cookie)
{
char recBuffer[RECBUFFERSIZE];
socklen_t destlen;
struct conn_t ethernetConnection;
ethernetConnection = getSocket();
destlen = sizeof ( ethernetConnection.dest_addr );
int k;
rt_task_set_mode(0, T_WARNSW, NULL);
for(k=0;k<1000;k++)
{
recvfrom( ethernetConnection.sock, &recBuffer, sizeof ( recBuffer
),0, ( struct sockaddr * ) ðernetConnection.dest_addr,&destlen );
//ret = rt_dev_sendto ( ethernetConnection.sock, &sendBuffer, strlen
( sendBuffer ) +1, 0, ( struct sockaddr * )
ðernetConnection.dest_addr,destlen);
}
}
void warn_upon_switch(int sig, siginfo_t *si, void *context)
{
unsigned int reason = si->si_value.sival_int;
void *bt[32];
int nentries;
printf("\nSIGDEBUG received, reason %d: %s\n", reason,
reason <= SIGDEBUG_WATCHDOG ? reason_str[reason] : "<unknown>");
/* Dump a backtrace of the frame which caused the switch to
secondary mode: */
nentries = backtrace(bt,sizeof(bt) / sizeof(bt[0]));
backtrace_symbols_fd(bt,nentries,fileno(stdout));
}
int main (int argc, char **argv)
{
struct sigaction sa;
int err;
reason_str[SIGDEBUG_UNDEFINED] = "undefined";
reason_str[SIGDEBUG_MIGRATE_SIGNAL] = "received signal";
reason_str[SIGDEBUG_MIGRATE_SYSCALL] = "invoked syscall";
reason_str[SIGDEBUG_MIGRATE_FAULT] = "triggered fault";
reason_str[SIGDEBUG_MIGRATE_PRIOINV] = "affected by priority inversion";
reason_str[SIGDEBUG_NOMLOCK] = "missing mlockall";
reason_str[SIGDEBUG_WATCHDOG] = "runaway thread";
mlockall(MCL_CURRENT | MCL_FUTURE);
//rt_print_auto_init(0);
sigemptyset(&sa.sa_mask);
sa.sa_sigaction = warn_upon_switch;
sa.sa_flags = SA_SIGINFO;
sigaction(SIGDEBUG, &sa, NULL);
err = rt_task_create(&task,"mytask",0,1,T_FPU);
if (err) {
fprintf(stderr,"failed to create task, code %d\n",err);
return 0;
}
err = rt_task_start(&task,&task_body,NULL);
if (err) {
fprintf(stderr,"failed to start task, code %d\n",err);
return 0;
}
pause();
return 0;
}
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Xenomai] Context Switch with rtnet
2012-09-22 13:20 ` Franz Engel
@ 2012-09-22 13:33 ` Gilles Chanteperdrix
2012-09-22 13:55 ` Franz Engel
2012-09-22 13:43 ` Gilles Chanteperdrix
1 sibling, 1 reply; 13+ messages in thread
From: Gilles Chanteperdrix @ 2012-09-22 13:33 UTC (permalink / raw)
To: Franz Engel; +Cc: xenomai
On 09/22/2012 03:20 PM, Franz Engel wrote:
>> On Fri, 21 Sep 2012 12:08:40 +0200, Kai Bollue <mlist1@bollue.de>
>>> On 21.09.2012 12:02, Gilles Chanteperdrix wrote:
>>>> On 09/21/2012 11:58 AM, Kai Bollue wrote:
>>>>> On 14.09.2012 17:01, Franz Engel wrote:
>>>>> Hi,
>>>>>
>>>>> I've a little problem. I'm using the rtnet.h-header and the
>> following function:
>>>>> ret = recvfrom ( ethernetConnection.sock, &recBuffer, sizeof (
>>>>> recBuffer ),0, ( struct sockaddr * )
>>>>> ðernetConnection.dest_addr,&destlen );
>>>> Hi,
>>>>
>>>> stupid question: But you do use an rtnet socket, not a normal one,
>> do
>>>> you? In this case, shouldn't it be rt_dev_recvfrom(...)?
>>> When using the posix skin, recvfrom is substituted at compilation (or
>>> more exactly link-edit) time with __wrap_recvfrom, implemented in
>>> libpthread_rt.so, allowing to work with real-time sockets.
>>>
>>
>> Ah, sorry, I missed that.
>>
>
> Sorry, I missed to answer on some questions:
>
> Let me explain my problem again. When I run my program ("mytask") the CSW
> and MSW increase every time the program receive a message:
> CPU PID MSW CSW PF STAT %CPU NAME
> 0 0 0 396 0 00500080 100.0 ROOT/0
> 1 0 0 0 0 00500080 100.0 ROOT/1
> 0 1336 1 1 0 00300380 0.0 kogmo_man
> 0 0 0 209 0 00000082 0.0 rtnet-stack
> 0 0 0 1 0 00000082 0.0 rtnet-rtpc
> 0 0 0 1 0 00000082 0.0 rtcfg-rx
> 0 5182 1 15 0 00340182 0.0 mytask
> 0 0 0 143 0 00000000 0.0 IRQ22: rteth0
> 1 0 0 186 0 00000000 0.0 IRQ22: rteth0
> 0 0 0 2054479 0 00000000 0.0 IRQ4364: [timer]
> 1 0 0 547805 0 00000000 0.0 IRQ4364: [timer]
>
> Wolfgang advised me to find the reason for this phenomenon like the program
> on this link:
> http://www.rts.uni-hannover.de/xenomai/lxr/source/examples/native/sigdebug.c
> I tried it and modified my code (see the code further down). When I insert
> an "cout" after "rt_task_set_mode(0, T_WARNSW, NULL);" I get a failure
> message (so it should work). But when I run this program without the cout I
> get no message, but the CSW and MSW counter are still increases.
>
>
> That's my versions:
> rtnet 0.9.12
> xenomai 2.5.5.2
That is not the latest release in the 2.5 branch. You are advised to
upgrade to 2.5.6, it should work with the same linux kernel version.
>
> exec_program("${XENOMAI_DIR}/bin/xeno-config --skin=native --ldflags"
> OUTPUT_VARIABLE XENOMAI_EXE_LINKER_FLAGS)
> set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS}
> ${XENOMAI_EXE_LINKER_FLAGS})
> exec_program("${XENOMAI_DIR}/bin/xeno-config --skin=native --cflags"
> OUTPUT_VARIABLE XENOMAI_DEFINITIONS)
Here you are retrieving the flags for the native skin, not for the posix
skin, unless there is some other part of your makefile which gets them.
> if ( ( ethernetConnection.sock = socket ( AF_INET, SOCK_DGRAM,
> IPPROTO_UDP ) ) < 0 )
> (...)
> if ( bind ( ethernetConnection.sock, ( struct sockaddr * )
> ðernetConnection.local_addr, sizeof ( ethernetConnection.local_addr
) ) <
> 0 )
> (...)
> recvfrom( ethernetConnection.sock, &recBuffer, sizeof ( recBuffer
> ),0, ( struct sockaddr * ) ðernetConnection.dest_addr,&destlen );
Here you are using the posix calls socket, bind and recvfrom. It will
allow you to work with an RTDM socket only if you compile for the posix
skin. See:
http://www.xenomai.org/index.php/Porting_POSIX_applications_to_Xenomai#Compilation_for_the_Xenomai_POSIX_skin
Now, I have no idea why you do not get any signal when using these calls.
--
Gilles.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Xenomai] Context Switch with rtnet
2012-09-22 13:20 ` Franz Engel
2012-09-22 13:33 ` Gilles Chanteperdrix
@ 2012-09-22 13:43 ` Gilles Chanteperdrix
1 sibling, 0 replies; 13+ messages in thread
From: Gilles Chanteperdrix @ 2012-09-22 13:43 UTC (permalink / raw)
To: Franz Engel; +Cc: xenomai
On 09/22/2012 03:20 PM, Franz Engel wrote:
>> On Fri, 21 Sep 2012 12:08:40 +0200, Kai Bollue <mlist1@bollue.de>
>>> On 21.09.2012 12:02, Gilles Chanteperdrix wrote:
>>>> On 09/21/2012 11:58 AM, Kai Bollue wrote:
>>>>> On 14.09.2012 17:01, Franz Engel wrote:
>>>>> Hi,
>>>>>
>>>>> I've a little problem. I'm using the rtnet.h-header and the
>> following function:
>>>>> ret = recvfrom ( ethernetConnection.sock, &recBuffer, sizeof (
>>>>> recBuffer ),0, ( struct sockaddr * )
>>>>> ðernetConnection.dest_addr,&destlen );
>>>> Hi,
>>>>
>>>> stupid question: But you do use an rtnet socket, not a normal one,
>> do
>>>> you? In this case, shouldn't it be rt_dev_recvfrom(...)?
>>> When using the posix skin, recvfrom is substituted at compilation (or
>>> more exactly link-edit) time with __wrap_recvfrom, implemented in
>>> libpthread_rt.so, allowing to work with real-time sockets.
>>>
>>
>> Ah, sorry, I missed that.
>>
>
> Sorry, I missed to answer on some questions:
>
> Let me explain my problem again. When I run my program ("mytask") the CSW
> and MSW increase every time the program receive a message:
> CPU PID MSW CSW PF STAT %CPU NAME
> 0 0 0 396 0 00500080 100.0 ROOT/0
> 1 0 0 0 0 00500080 100.0 ROOT/1
> 0 1336 1 1 0 00300380 0.0 kogmo_man
> 0 0 0 209 0 00000082 0.0 rtnet-stack
> 0 0 0 1 0 00000082 0.0 rtnet-rtpc
> 0 0 0 1 0 00000082 0.0 rtcfg-rx
> 0 5182 1 15 0 00340182 0.0 mytask
> 0 0 0 143 0 00000000 0.0 IRQ22: rteth0
> 1 0 0 186 0 00000000 0.0 IRQ22: rteth0
> 0 0 0 2054479 0 00000000 0.0 IRQ4364: [timer]
> 1 0 0 547805 0 00000000 0.0 IRQ4364: [timer]
>
> Wolfgang advised me to find the reason for this phenomenon like the program
> on this link:
> http://www.rts.uni-hannover.de/xenomai/lxr/source/examples/native/sigdebug.c
> I tried it and modified my code (see the code further down). When I insert
> an "cout" after "rt_task_set_mode(0, T_WARNSW, NULL);" I get a failure
> message (so it should work). But when I run this program without the cout I
> get no message, but the CSW and MSW counter are still increases.
>
>
> That's my versions:
> rtnet 0.9.12
> xenomai 2.5.5.2
> linux kernel 2.6.32-20
> ubuntu 10.04
> i-pipe patch: adeos-ipipe-2.6.32.20-x86-2.7-03.patch
> NIC driver: 8139too
> CPU: Intel vPro
>
>
> Any other ideas? Or is it not a problem but the normal state that the
> counters increases?
>
> Here is the code of my cmake-file:
> cmake_minimum_required(VERSION 2.8)
>
> ##################################
> # BEGIN OF EDITING THIS TEMPLATE #
> ##################################
>
> ############################################
> # PLEASE ENTER HERE THE NAME OF YOUR PROJECT
>
> set(ProjectName robotrsiVersuch) #e.g. "robotdatalogger" (do not forget the
> quotes)
>
> PROJECT(${ProjectName})
>
> ###############################################
> # ENTER HERE THE VERSION NUMBER OF YOUR PROJECT
> set(${ProjectName}_VERSION_MAJOR 1)
> set(${ProjectName}_VERSION_MINOR 0)
>
> ###############################################
> # ENABLE OR DIABLE THE USE OF XENOMAI AND QT
> option(USE_XENOMAI "xenomai" ON )
> option(USE_RTNET "rtnet" ON )
>
> #############################################
> # NOW ADD ALL SOURCE FILES OF YOUR PROJECT
> # IF YOU'RE USING QT, ALSO ADD ALL HEADERS OF
> # QT-OBJECTS, UI-FILES AND RESOURCES
>
> #####################
> # INCLUDE DIRECTORIES
>
> set(MAIN_DIR ${PROJECT_SOURCE_DIR}/../..)
> set(SOURCE_DIR src)
>
>
> #############################################
> # ENTER THE INSTALL DIRECTORY
> # added by stefan.thumfart@profactor.at
> set(INSTALLDIR ${MAIN_DIR}/bin)
>
> set(INCLUDES
> ${SOURCE_DIR}
> )
>
>
> ###########
> # LIBRARIES
>
> set(EXTRA_LIBS
>
> )
>
> ######
> # CPPs
>
> set(SOURCES
> main.cpp
> src/rsiinterface.cpp
> src/rsiinterface.h
> )
>
> #############
> # MOC-Headers
> set(MOC_HEADERS
>
> )
>
> ##########
> # UI-Files
> set(UIS
>
> )
>
> ###########
> # Resources
> set(RESOURCES
>
> )
>
> ##################################
> # END OF EDITING THIS TEMPLATE #
> ##################################
>
>
> message (STATUS "Usage of Xenomai: ${USE_XENOMAI}")
> message (STATUS "Usage of RTnet: ${USE_RTNET}")
>
> message(STATUS "Generating buid files for project ${ProjectName}, version
> ${${ProjectName}_VERSION_MAJOR}.${${ProjectName}_VERSION_MINOR}")
>
> include_directories(${INCLUDES})
>
>
> IF(USE_XENOMAI)
> message(STATUS "Starting Xenomai configuration")
>
> message(STATUS "startign RTnet configuration")
> include_directories(/usr/local/rtnet/include)
> include_directories(/usr/xenomai/include/rtdm)
> message(STATUS "RTnet configuration finished")
>
> find_library(XENO_rtdm rtdm /usr/xenomai/lib)
> set(EXTRA_LIBS ${EXTRA_LIBS} ${XENO_rtdm})
> message(STATUS ${EXTRA_LIBS} )
>
> set(XENOMAI_DIR "/usr/xenomai")
> set(XENOMAI_INCLUDE_DIR ${XENOMAI_DIR}/include)
> set(XENOMAI_INCLUDE_POSIX_DIR ${XENOMAI_DIR}/include/native)
>
> exec_program("${XENOMAI_DIR}/bin/xeno-config --skin=native --ldflags"
> OUTPUT_VARIABLE XENOMAI_EXE_LINKER_FLAGS)
> set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS}
> ${XENOMAI_EXE_LINKER_FLAGS})
> exec_program("${XENOMAI_DIR}/bin/xeno-config --skin=native --cflags"
> OUTPUT_VARIABLE XENOMAI_DEFINITIONS)
> set(EXTRA_DEFINITIONS ${EXTRA_DEFINITIONS} ${XENOMAI_DEFINITIONS})
> ADD_DEFINITIONS(${EXTRA_DEFINITIONS})
>
> set(EXTRA_LIBS ${EXTRA_LIBS} rtdk)
>
> message(STATUS ${XENOMAI_EXE_LINKER_FLAGS})
> message(STATUS ${XENOMAI_DEFINITIONS})
> message(STATUS "Xenomai configuration finished")
> ELSE(USE_XENOMAI)
> find_library(RT_TIME_LIB rt)
> set(EXTRA_LIBS ${EXTRA_LIBS} ${RT_TIME_LIB})
> ENDIF(USE_XENOMAI)
>
>
> IF (USE_RTNET)
>
> ENDIF (USE_RTNET)
>
>
> add_executable(${ProjectName} ${SOURCES})
>
> TARGET_LINK_LIBRARIES(${ProjectName} ${EXTRA_LIBS})
>
> install(TARGETS ${ProjectName} DESTINATION ${INSTALLDIR})
>
> And this is my cpp:
> #include <unistd.h>
> #include <stdlib.h>
> #include <stdio.h>
> #include <string.h>
> #include <signal.h>
> #include <getopt.h>
> #include <execinfo.h>
> #include <sys/mman.h>
>
> #include <stdexcept>
> #include <arpa/inet.h>
> #include <native/task.h>
> #include "rtdk.h"
> #include <rtnet.h>
>
>
> #define RECBUFFERSIZE 600
> #define SENDBUFFERSIZE 300
>
> RT_TASK task;
> const char *reason_str[7];
>
> struct conn_t
> {
> int sock;
> struct sockaddr_in dest_addr;
> struct sockaddr_in local_addr;
> };
>
> struct conn_t getSocket ()
> {
> struct conn_t ethernetConnection;
>
> //ethernetConnection.dest_addr.sin_family = AF_INET;
> ethernetConnection.dest_addr.sin_addr.s_addr = inet_addr
> ("192.168.100.12");
> ethernetConnection.dest_addr.sin_port = htons (6002);
>
> //ethernetConnection.local_addr.sin_family = AF_INET;
> ethernetConnection.local_addr.sin_addr.s_addr = inet_addr
> ("192.168.100.11");
> ethernetConnection.local_addr.sin_port = htons (6008);
>
> if ( ( ethernetConnection.sock = socket ( AF_INET, SOCK_DGRAM,
> IPPROTO_UDP ) ) < 0 )
> {
> throw std::runtime_error("Can not open socket");
> }
> else
> {
> }
>
> if ( bind ( ethernetConnection.sock, ( struct sockaddr * )
> ðernetConnection.local_addr, sizeof ( ethernetConnection.local_addr ) ) <
> 0 )
> {
> close ( ethernetConnection.sock );
> throw std::runtime_error("Can not bind socket");
> }
> else
> {
> }
>
> return ethernetConnection;
> }
>
> void task_body (void *cookie)
> {
> char recBuffer[RECBUFFERSIZE];
>
> socklen_t destlen;
>
> struct conn_t ethernetConnection;
>
> ethernetConnection = getSocket();
>
> destlen = sizeof ( ethernetConnection.dest_addr );
>
> int k;
>
> rt_task_set_mode(0, T_WARNSW, NULL);
>
> for(k=0;k<1000;k++)
> {
> recvfrom( ethernetConnection.sock, &recBuffer, sizeof ( recBuffer
> ),0, ( struct sockaddr * ) ðernetConnection.dest_addr,&destlen );
>
> //ret = rt_dev_sendto ( ethernetConnection.sock, &sendBuffer, strlen
> ( sendBuffer ) +1, 0, ( struct sockaddr * )
> ðernetConnection.dest_addr,destlen);
> }
> }
>
>
> void warn_upon_switch(int sig, siginfo_t *si, void *context)
> {
> unsigned int reason = si->si_value.sival_int;
> void *bt[32];
> int nentries;
>
> printf("\nSIGDEBUG received, reason %d: %s\n", reason,
> reason <= SIGDEBUG_WATCHDOG ? reason_str[reason] : "<unknown>");
> /* Dump a backtrace of the frame which caused the switch to
> secondary mode: */
> nentries = backtrace(bt,sizeof(bt) / sizeof(bt[0]));
> backtrace_symbols_fd(bt,nentries,fileno(stdout));
> }
Beware the stack, you probably can not use printf with the default
thread stack size (this is the reason why backtrace_symbols_fd is used).
--
Gilles.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Xenomai] Context Switch with rtnet
2012-09-22 13:33 ` Gilles Chanteperdrix
@ 2012-09-22 13:55 ` Franz Engel
2012-09-22 14:02 ` Gilles Chanteperdrix
0 siblings, 1 reply; 13+ messages in thread
From: Franz Engel @ 2012-09-22 13:55 UTC (permalink / raw)
To: 'Gilles Chanteperdrix'; +Cc: xenomai
> On 09/22/2012 03:40 PM, Gilles Chanteperdrix wrote:
> > On 09/22/2012 03:20 PM, Franz Engel wrote:
> >> On Fri, 21 Sep 2012 12:08:40 +0200, Kai Bollue <mlist1@bollue.de>
> >>> On 21.09.2012 12:02, Gilles Chanteperdrix wrote:
> >>>> On 09/21/2012 11:58 AM, Kai Bollue wrote:
> >>>>> On 14.09.2012 17:01, Franz Engel wrote:
> >>>>> Hi,
> >>>>>
> >>>>> I've a little problem. I'm using the rtnet.h-header and the
> >> following function:
> >>>>> ret = recvfrom ( ethernetConnection.sock, &recBuffer, sizeof (
> >>>>> recBuffer ),0, ( struct sockaddr * )
> >>>>> ðernetConnection.dest_addr,&destlen );
> >>>> Hi,
> >>>>
> >>>> stupid question: But you do use an rtnet socket, not a normal one,
> >> do
> >>>> you? In this case, shouldn't it be rt_dev_recvfrom(...)?
> >>> When using the posix skin, recvfrom is substituted at compilation
> >>> (or more exactly link-edit) time with __wrap_recvfrom, implemented
> >>> in libpthread_rt.so, allowing to work with real-time sockets.
> >>>
> >>
> >> Ah, sorry, I missed that.
> >>
> >
> > Sorry, I missed to answer on some questions:
> >
> > Let me explain my problem again. When I run my program ("mytask") the
> > CSW and MSW increase every time the program receive a message:
> > CPU PID MSW CSW PF STAT %CPU NAME
> > 0 0 0 396 0 00500080 100.0 ROOT/0
> > 1 0 0 0 0 00500080 100.0 ROOT/1
> > 0 1336 1 1 0 00300380 0.0 kogmo_man
> > 0 0 0 209 0 00000082 0.0 rtnet-stack
> > 0 0 0 1 0 00000082 0.0 rtnet-rtpc
> > 0 0 0 1 0 00000082 0.0 rtcfg-rx
> > 0 5182 1 15 0 00340182 0.0 mytask
> > 0 0 0 143 0 00000000 0.0 IRQ22:
> rteth0
> > 1 0 0 186 0 00000000 0.0 IRQ22:
> rteth0
> > 0 0 0 2054479 0 00000000 0.0 IRQ4364:
> [timer]
> > 1 0 0 547805 0 00000000 0.0 IRQ4364:
> [timer]
> >
> > Wolfgang advised me to find the reason for this phenomenon like the
> > program on this link:
> > http://www.rts.uni-
> hannover.de/xenomai/lxr/source/examples/native/sigd
> > ebug.c I tried it and modified my code (see the code further down).
> > When I insert an "cout" after "rt_task_set_mode(0, T_WARNSW, NULL);"
> I
> > get a failure message (so it should work). But when I run this
> program
> > without the cout I get no message, but the CSW and MSW counter are
> > still increases.
> >
> >
> > That's my versions:
> > rtnet 0.9.12
> > xenomai 2.5.5.2
>
>
> That is not the latest release in the 2.5 branch. You are advised to
> upgrade to 2.5.6, it should work with the same linux kernel version.
>
> >
>
> > exec_program("${XENOMAI_DIR}/bin/xeno-config --skin=native --
> ldflags"
> > OUTPUT_VARIABLE XENOMAI_EXE_LINKER_FLAGS)
> > set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS}
> > ${XENOMAI_EXE_LINKER_FLAGS})
> > exec_program("${XENOMAI_DIR}/bin/xeno-config --skin=native --
> cflags"
> > OUTPUT_VARIABLE XENOMAI_DEFINITIONS)
>
>
> Here you are retrieving the flags for the native skin, not for the
> posix skin, unless there is some other part of your makefile which gets
> them.
Oh, sorry. I mixed two of my demo projects. In the correct cmake file I use the posix skin. In my second project I use the native skin and the rt_dev_* commands. But it has the same result.
>
> > if ( ( ethernetConnection.sock = socket ( AF_INET, SOCK_DGRAM,
> > IPPROTO_UDP ) ) < 0 )
>
> > (...)
> > if ( bind ( ethernetConnection.sock, ( struct sockaddr * )
> > ðernetConnection.local_addr, sizeof (
> ethernetConnection.local_addr
> ) ) <
> > 0 )
> > (...)
> > recvfrom( ethernetConnection.sock, &recBuffer, sizeof (
> > recBuffer ),0, ( struct sockaddr * )
> > ðernetConnection.dest_addr,&destlen );
>
> Here you are using the posix calls socket, bind and recvfrom. It will
> allow you to work with an RTDM socket only if you compile for the posix
> skin. See:
>
> http://www.xenomai.org/index.php/Porting_POSIX_applications_to_Xenomai#
> Compilation_for_the_Xenomai_POSIX_skin
>
> Now, I have no idea why you do not get any signal when using these
> calls.
Here is my "good" cmake file:
cmake_minimum_required(VERSION 2.8)
##################################
# BEGIN OF EDITING THIS TEMPLATE #
##################################
############################################
# PLEASE ENTER HERE THE NAME OF YOUR PROJECT
set(ProjectName robotrsiVersuch) #e.g. "robotdatalogger" (do not forget the quotes)
PROJECT(${ProjectName})
###############################################
# ENTER HERE THE VERSION NUMBER OF YOUR PROJECT
set(${ProjectName}_VERSION_MAJOR 1)
set(${ProjectName}_VERSION_MINOR 0)
###############################################
# ENABLE OR DIABLE THE USE OF XENOMAI AND QT
option(USE_XENOMAI "xenomai" ON )
option(USE_RTNET "rtnet" ON )
#############################################
# NOW ADD ALL SOURCE FILES OF YOUR PROJECT
# IF YOU'RE USING QT, ALSO ADD ALL HEADERS OF
# QT-OBJECTS, UI-FILES AND RESOURCES
#####################
# INCLUDE DIRECTORIES
set(MAIN_DIR ${PROJECT_SOURCE_DIR}/../..)
set(SOURCE_DIR src)
#############################################
# ENTER THE INSTALL DIRECTORY
set(INSTALLDIR ${MAIN_DIR}/bin)
set(INCLUDES
${SOURCE_DIR}
)
###########
# LIBRARIES
set(EXTRA_LIBS
)
######
# CPPs
set(SOURCES
main.cpp
src/rsiinterface.cpp
src/rsiinterface.h
)
#############
# MOC-Headers
set(MOC_HEADERS
)
##########
# UI-Files
set(UIS
)
###########
# Resources
set(RESOURCES
)
##################################
# END OF EDITING THIS TEMPLATE #
##################################
message (STATUS "Usage of Xenomai: ${USE_XENOMAI}")
message (STATUS "Usage of RTnet: ${USE_RTNET}")
message(STATUS "Generating buid files for project ${ProjectName}, version ${${ProjectName}_VERSION_MAJOR}.${${ProjectName}_VERSION_MINOR}")
include_directories(${INCLUDES})
IF(USE_XENOMAI)
message(STATUS "Starting Xenomai configuration")
message(STATUS "startign RTnet configuration")
include_directories(/usr/local/rtnet/include)
include_directories(/usr/xenomai/include/rtdm)
message(STATUS "RTnet configuration finished")
find_library(XENO_rtdm rtdm /usr/xenomai/lib)
set(EXTRA_LIBS ${EXTRA_LIBS} ${XENO_rtdm})
message(STATUS ${EXTRA_LIBS} )
set(XENOMAI_DIR "/usr/xenomai")
set(XENOMAI_INCLUDE_DIR ${XENOMAI_DIR}/include)
set(XENOMAI_INCLUDE_POSIX_DIR ${XENOMAI_DIR}/include/posix)
exec_program("${XENOMAI_DIR}/bin/xeno-config --skin=posix --ldflags" OUTPUT_VARIABLE XENOMAI_EXE_LINKER_FLAGS)
set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} ${XENOMAI_EXE_LINKER_FLAGS})
exec_program("${XENOMAI_DIR}/bin/xeno-config --skin=posix --cflags" OUTPUT_VARIABLE XENOMAI_DEFINITIONS)
set(EXTRA_DEFINITIONS ${EXTRA_DEFINITIONS} ${XENOMAI_DEFINITIONS})
ADD_DEFINITIONS(${EXTRA_DEFINITIONS})
set(EXTRA_LIBS ${EXTRA_LIBS} rtdk)
message(STATUS ${XENOMAI_EXE_LINKER_FLAGS})
message(STATUS ${XENOMAI_DEFINITIONS})
message(STATUS "Xenomai configuration finished")
ELSE(USE_XENOMAI)
find_library(RT_TIME_LIB rt)
set(EXTRA_LIBS ${EXTRA_LIBS} ${RT_TIME_LIB})
ENDIF(USE_XENOMAI)
IF (USE_RTNET)
ENDIF (USE_RTNET)
add_executable(${ProjectName} ${SOURCES})
TARGET_LINK_LIBRARIES(${ProjectName} ${EXTRA_LIBS})
install(TARGETS ${ProjectName} DESTINATION ${INSTALLDIR})
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Xenomai] Context Switch with rtnet
2012-09-22 13:55 ` Franz Engel
@ 2012-09-22 14:02 ` Gilles Chanteperdrix
0 siblings, 0 replies; 13+ messages in thread
From: Gilles Chanteperdrix @ 2012-09-22 14:02 UTC (permalink / raw)
To: Franz Engel; +Cc: xenomai
On 09/22/2012 03:55 PM, Franz Engel wrote:
>> On 09/22/2012 03:40 PM, Gilles Chanteperdrix wrote:
>>> On 09/22/2012 03:20 PM, Franz Engel wrote:
>>>> On Fri, 21 Sep 2012 12:08:40 +0200, Kai Bollue <mlist1@bollue.de>
>>>>> On 21.09.2012 12:02, Gilles Chanteperdrix wrote:
>>>>>> On 09/21/2012 11:58 AM, Kai Bollue wrote:
>>>>>>> On 14.09.2012 17:01, Franz Engel wrote:
>>>>>>> Hi,
>>>>>>>
>>>>>>> I've a little problem. I'm using the rtnet.h-header and the
>>>> following function:
>>>>>>> ret = recvfrom ( ethernetConnection.sock, &recBuffer, sizeof (
>>>>>>> recBuffer ),0, ( struct sockaddr * )
>>>>>>> ðernetConnection.dest_addr,&destlen );
>>>>>> Hi,
>>>>>>
>>>>>> stupid question: But you do use an rtnet socket, not a normal one,
>>>> do
>>>>>> you? In this case, shouldn't it be rt_dev_recvfrom(...)?
>>>>> When using the posix skin, recvfrom is substituted at compilation
>>>>> (or more exactly link-edit) time with __wrap_recvfrom, implemented
>>>>> in libpthread_rt.so, allowing to work with real-time sockets.
>>>>>
>>>>
>>>> Ah, sorry, I missed that.
>>>>
>>>
>>> Sorry, I missed to answer on some questions:
>>>
>>> Let me explain my problem again. When I run my program ("mytask") the
>>> CSW and MSW increase every time the program receive a message:
>>> CPU PID MSW CSW PF STAT %CPU NAME
>>> 0 0 0 396 0 00500080 100.0 ROOT/0
>>> 1 0 0 0 0 00500080 100.0 ROOT/1
>>> 0 1336 1 1 0 00300380 0.0 kogmo_man
>>> 0 0 0 209 0 00000082 0.0 rtnet-stack
>>> 0 0 0 1 0 00000082 0.0 rtnet-rtpc
>>> 0 0 0 1 0 00000082 0.0 rtcfg-rx
>>> 0 5182 1 15 0 00340182 0.0 mytask
The thing is, we only see 1 MSW for mytask, I think it is normal to have
an MSW during task startup. CSW are completely normal for a recvfrom loop.
--
Gilles.
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2012-09-22 14:02 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-14 15:01 [Xenomai] Context Switch with rtnet Franz Engel
2012-09-16 14:29 ` Jan Kiszka
2012-09-20 15:24 ` Franz Engel
2012-09-20 17:33 ` Wolfgang Grandegger
2012-09-20 17:36 ` Gilles Chanteperdrix
2012-09-21 9:58 ` Kai Bollue
2012-09-21 10:02 ` Gilles Chanteperdrix
2012-09-21 10:08 ` Kai Bollue
[not found] <mailman.1.1348308001.4459.xenomai@xenomai.org>
2012-09-22 13:20 ` Franz Engel
2012-09-22 13:33 ` Gilles Chanteperdrix
2012-09-22 13:55 ` Franz Engel
2012-09-22 14:02 ` Gilles Chanteperdrix
2012-09-22 13:43 ` Gilles Chanteperdrix
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.