Hi... :-)
> Paolo Marras wrote:
(...)
> How can I do it using RTLinux and developing an OO application??
I use C++ in my RTL modules, and it works almost like normal linking -
no need for special interfaces or other ugly hacks. (Linux kernel
modules are NOT Windoze DLLs... :-) All you need to do is provide the
functions needed for instantiating and deleting objects - that is new
and delete. (See below.)
> Can I program a class RTL_TASK with its routines and then instantiate
> an object MY_RT_TASK?
There is one thing to keep in mind though; you mustn't use kernel calls
from within RTL tasks! So if your tasks need to create new instances,
you have to use a homebrew memory management system to replace kmalloc()
and kfree(). The easiest way would be to simply kmalloc() a heap in
init_module(), and then set up a freelist + alloc()/free() for it. I'm
not sure, but someone may have some code for download... I haven't
needed
to dig into that part yet - all my objects are created in module_init().
> How can I deal with my intention to create an OO application and the
> use of RT loadable modules?
(See above.) Just a note; If you have static instances in the modules,
you need to use __do_global_ctors_aux() and __do_global_dtors_aux() to
run the constructors/destructors. Call the first one in module_init()
and
the second one in cleanup_module() and when linking, first specify
crtbegin.o and after your object files, link in crtend.o. (On my RedHat
system they're in /usr/lib/gcc-lib/i386-redhat-linux/2.7.2.3/.)
For more details, read down the list! :-)
// David Olofson
// ReoLogica Instruments AB
/*-----------------------------------------------*/
extern "C" {
#include <linux/kernel.h>
void *kmalloc(unsigned size, int prio);
void kfree(void *p);
};
void *operator new (unsigned size) {
return kmalloc(size,0);
}
void *operator new[] (unsigned size, unsigned nb) {
return kmalloc(size*nb,0);
}
void operator delete (void *p) {
kfree(p);
}
void operator delete[] (void *p) {
kfree(p);
}
/*-----------------------------------------------*/
--- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
----
For more information on Real-Time Linux see:
http://www.rtlinux.org/~rtlinux/