* [Xenomai-help] 2.6 kernel module with math functions
@ 2005-11-18 9:07 Cedric Herreman
2005-11-18 13:19 ` Gilles Chanteperdrix
0 siblings, 1 reply; 5+ messages in thread
From: Cedric Herreman @ 2005-11-18 9:07 UTC (permalink / raw)
To: xenomai
[-- Attachment #1: Type: text/plain, Size: 1064 bytes --]
Hello,
I am porting a 2.4 RTAI kernel module to Xenomai 2.0 kernel 2.6. I used some basic math functions in the original module. This is posing problems for me now.
In the module source i include <math.h>. I add -I/usr/include to the compiler flags and also "-ffast-math -mhard-float".
If i compile this, i get warnings about double definitions of "__attribute_pure__" and "__attribute_used__".
If i insert the kernel module, i get an error message :
"Xenomai: Invalid use of FPU in Xenomai context at " + probably the address of the instruction where the math function is called.
Can anyone give me a hint ? Thanks.
This is the makefile :
obj-m := rt_canio.o
XENODIR = /usr/realtime
KDIR := /lib/modules/2.6.13.3/build
PWD := $(shell pwd)
EXTRA_CFLAGS := -I$(XENODIR)/include -I/usr/include -ffast-math -mhard-float
all:
$(MAKE) -C $(KDIR) M=$(PWD) modules
clean:
$(MAKE) -C $(KDIR) M=$(PWD) clean
---------------------------------
Yahoo! FareChase - Search multiple travel sites in one click.
[-- Attachment #2: Type: text/html, Size: 1428 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [Xenomai-help] 2.6 kernel module with math functions 2005-11-18 9:07 [Xenomai-help] 2.6 kernel module with math functions Cedric Herreman @ 2005-11-18 13:19 ` Gilles Chanteperdrix 2005-11-25 9:33 ` Cedric Herreman 0 siblings, 1 reply; 5+ messages in thread From: Gilles Chanteperdrix @ 2005-11-18 13:19 UTC (permalink / raw) To: Cedric Herreman; +Cc: xenomai Cedric Herreman wrote: > Hello, > > I am porting a 2.4 RTAI kernel module to Xenomai 2.0 kernel 2.6. I used some basic math functions in the original module. This is posing problems for me now. > > In the module source i include <math.h>. I add -I/usr/include to the compiler flags and also "-ffast-math -mhard-float". > > If i compile this, i get warnings about double definitions of "__attribute_pure__" and "__attribute_used__". > > If i insert the kernel module, i get an error message : > "Xenomai: Invalid use of FPU in Xenomai context at " + probably the address of the instruction where the math function is called. > > Can anyone give me a hint ? Thanks. You can only use floating point operations from real-time threads contexts, not from module initialization and finalization routines, and you have to signal Xenomai, when creating kernel space real-time threads, that the thread will be allowed to use FPU. For the RTAI skin, this is what the rt_task_init function 6th argument is for. There is currently no math library module in Xenomai. So, the answer is that you have to avoid math functions, or make a xeno_math module, the way it is done in RTAI, i.e. using a math library such as the one made by Sun and used by FreeBSD, or one among the various libcs available. We once discussed this with Philippe, and a good candidate seemed to be newlib at that time: http://sourceware.org/newlib/ Looking at newlib sources, it seems that some of its contents come from the Sun library too. -- Gilles Chanteperdrix. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Xenomai-help] 2.6 kernel module with math functions 2005-11-18 13:19 ` Gilles Chanteperdrix @ 2005-11-25 9:33 ` Cedric Herreman 2005-11-25 9:39 ` Philippe Gerum 0 siblings, 1 reply; 5+ messages in thread From: Cedric Herreman @ 2005-11-25 9:33 UTC (permalink / raw) To: xenomai-help [-- Attachment #1: Type: text/plain, Size: 2310 bytes --] OK, I made an extra math module, copying some of the source code from newlib for the functions i needed. It works. Another question : if i create an application (in stead of kernel module) that starts a real time thread. Can i then use math functions inside the real time running part ? In the latency example, the sqrt function is used for displaying the results of the latency test. This is outside the real time task. Is it possible to use this call in the real time function ? Or any other library function (that is not performing system calls) ? Cedric. Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org> wrote: Cedric Herreman wrote: > Hello, > > I am porting a 2.4 RTAI kernel module to Xenomai 2.0 kernel 2.6. I used some basic math functions in the original module. This is posing problems for me now. > > In the module source i include . I add -I/usr/include to the compiler flags and also "-ffast-math -mhard-float". > > If i compile this, i get warnings about double definitions of "__attribute_pure__" and "__attribute_used__". > > If i insert the kernel module, i get an error message : > "Xenomai: Invalid use of FPU in Xenomai context at " + probably the address of the instruction where the math function is called. > > Can anyone give me a hint ? Thanks. You can only use floating point operations from real-time threads contexts, not from module initialization and finalization routines, and you have to signal Xenomai, when creating kernel space real-time threads, that the thread will be allowed to use FPU. For the RTAI skin, this is what the rt_task_init function 6th argument is for. There is currently no math library module in Xenomai. So, the answer is that you have to avoid math functions, or make a xeno_math module, the way it is done in RTAI, i.e. using a math library such as the one made by Sun and used by FreeBSD, or one among the various libcs available. We once discussed this with Philippe, and a good candidate seemed to be newlib at that time: http://sourceware.org/newlib/ Looking at newlib sources, it seems that some of its contents come from the Sun library too. -- Gilles Chanteperdrix. --------------------------------- Yahoo! Music Unlimited - Access over 1 million songs. Try it free. [-- Attachment #2: Type: text/html, Size: 2765 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Xenomai-help] 2.6 kernel module with math functions 2005-11-25 9:33 ` Cedric Herreman @ 2005-11-25 9:39 ` Philippe Gerum 2005-11-27 17:18 ` Gilles Chanteperdrix 0 siblings, 1 reply; 5+ messages in thread From: Philippe Gerum @ 2005-11-25 9:39 UTC (permalink / raw) To: Cedric Herreman; +Cc: xenomai-help Cedric Herreman wrote: > OK, > > I made an extra math module, copying some of the source code from newlib > for the functions i needed. It works. > > Another question : if i create an application (in stead of kernel > module) that starts a real time thread. Can i then use math functions > inside the real time running part ? > > In the latency example, the sqrt function is used for displaying the > results of the latency test. This is outside the real time task. Is it > possible to use this call in the real time function ? Or any other > library function (that is not performing system calls) ? > Yes. RT threads in user-space have their own FPU context managed by Xenomai. > Cedric. > > */Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>/* wrote: > > Cedric Herreman wrote: > > Hello, > > > > I am porting a 2.4 RTAI kernel module to Xenomai 2.0 kernel 2.6. > I used some basic math functions in the original module. This is > posing problems for me now. > > > > In the module source i include . I add -I/usr/include to the > compiler flags and also "-ffast-math -mhard-float". > > > > If i compile this, i get warnings about double definitions of > "__attribute_pure__" and "__attribute_used__". > > > > If i insert the kernel module, i get an error message : > > "Xenomai: Invalid use of FPU in Xenomai context at " + probably > the address of the instruction where the math function is called. > > > > Can anyone give me a hint ? Thanks. > > You can only use floating point operations from real-time threads > contexts, not from module initialization and finalization routines, and > you have to signal Xenomai, when creating kernel space real-time > threads, that the thread will be allowed to use FPU. For the RTAI skin, > this is what the rt_task_init function 6th argument is for. > > There is currently no math library module in Xenomai. So, the answer is > that you have to avoid math functions, or make a xeno_math module, the > way it is done in RTAI, i.e. using a math library such as the one made > by Sun and used by FreeBSD, or one among the various libcs available. > We once discussed this with Philippe, and a good candidate seemed to be > newlib at that time: > > http://sourceware.org/newlib/ > > Looking at newlib sources, it seems that some of its contents come from > the Sun library too. > > -- > > > Gilles Chanteperdrix. > > > ------------------------------------------------------------------------ > Yahoo! Music Unlimited - Access over 1 million songs. Try it free. > <http://pa.yahoo.com/*http://us.rd.yahoo.com/evt=36035/*http://music.yahoo.com/unlimited/> > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Xenomai-help mailing list > Xenomai-help@domain.hid > https://mail.gna.org/listinfo/xenomai-help -- Philippe. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Xenomai-help] 2.6 kernel module with math functions 2005-11-25 9:39 ` Philippe Gerum @ 2005-11-27 17:18 ` Gilles Chanteperdrix 0 siblings, 0 replies; 5+ messages in thread From: Gilles Chanteperdrix @ 2005-11-27 17:18 UTC (permalink / raw) To: Philippe Gerum; +Cc: xenomai-help Philippe Gerum wrote: > Cedric Herreman wrote: > > OK, > > > > I made an extra math module, copying some of the source code from newlib > > for the functions i needed. It works. > > > > Another question : if i create an application (in stead of kernel > > module) that starts a real time thread. Can i then use math functions > > inside the real time running part ? > > > > In the latency example, the sqrt function is used for displaying the > > results of the latency test. This is outside the real time task. Is it > > possible to use this call in the real time function ? Or any other > > library function (that is not performing system calls) ? > > > > Yes. RT threads in user-space have their own FPU context managed by Xenomai. As for math functions implemented in libm, they may be called from real-time threads, but if we want to be precise, we can not guarantee their worst case behaviour, you have to do a mathematical analysis of their implementation for that (sqrt is probably implemented in hardware, so you have to read intel spec to know if the max cycles count is known, but it would be strange if it was not). -- Gilles Chanteperdrix. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-11-27 17:18 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2005-11-18 9:07 [Xenomai-help] 2.6 kernel module with math functions Cedric Herreman 2005-11-18 13:19 ` Gilles Chanteperdrix 2005-11-25 9:33 ` Cedric Herreman 2005-11-25 9:39 ` Philippe Gerum 2005-11-27 17:18 ` 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.