* [Xenomai-help] RT Task as a kernel module halts the whole system
@ 2009-05-25 9:31 Shashank Bhatia
2009-05-25 14:02 ` Stefan Kisdaroczi
0 siblings, 1 reply; 2+ messages in thread
From: Shashank Bhatia @ 2009-05-25 9:31 UTC (permalink / raw)
To: xenomai
Dear All,
I wrote a simple RT task to be run as kernel module and tried to
run it. As soon as i issue the insmod command, it halts the whole system.
Please help me out,
The code is as follows:
#include <linux/module.h> // required by all modules
#include <linux/kernel.h> // required by printk()
#include <linux/init.h>
#include <posix/sys/mman.h>
#include <native/task.h>
#include <native/alarm.h>
#define TASK_PRI 50
#define TASK_MODE T_FPU|T_CPU(0)
#define STAK_SIZE 4096
#define ALARM_VAL 500000
#define ALRAM_INT 25000000
RT_ALARM alarm;
RT_TASK alarm_handler;
int err;
void alarm_hand_func(void *cookie)
{
if(!err)
{
// do the periodic task
}
}
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Shashank");
// Start/Init function
static int hello_init(void) {
printk(KERN_ALERT "Hello world!\n"); // A logging mechanism for
kernel
err = rt_alarm_create(&alarm,"myAlarm");
err = rt_alarm_start(&alarm,ALARM_VAL,ALARM_INT);
err=rt_task_create(&alarm_handler, "ALARMtask",STAK_SIZE,TASK_PRI,TASK_MODE);
if(!err)
rt_task_start(&alarm_handler,&alarm_hand_func,NULL);
return 0; // A non-zero return means
hello_init failed; the module can't be loaded.
}
// End/Cleanup function
static void hello_exit(void) {
//rt_task_delete(&alarm_handler);
rt_alarm_delete(&alarm);
printk(KERN_ALERT "Goodbye world!\n");
}
module_init(hello_init);
module_exit(hello_exit);
-------------------------------------
Hi-Tech Gears Limited, Gurgaon, India
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Xenomai-help] RT Task as a kernel module halts the whole system
2009-05-25 9:31 [Xenomai-help] RT Task as a kernel module halts the whole system Shashank Bhatia
@ 2009-05-25 14:02 ` Stefan Kisdaroczi
0 siblings, 0 replies; 2+ messages in thread
From: Stefan Kisdaroczi @ 2009-05-25 14:02 UTC (permalink / raw)
To: Shashank Bhatia; +Cc: xenomai
[-- Attachment #1: Type: text/plain, Size: 1852 bytes --]
Hi,
Shashank Bhatia schrieb:
> Dear All,
>
> I wrote a simple RT task to be run as kernel module and tried to
> run it. As soon as i issue the insmod command, it halts the whole system.
> Please help me out,
>
> The code is as follows:
> [...]
>
> err = rt_alarm_create(&alarm,"myAlarm");
looking at the xenomai docs [1], there are two rt_alarm_create() functions,
one for kernel-space and one for userspace:
int rt_alarm_create (RT_ALARM *alarm, const char *)
Create an alarm object from user-space.
int rt_alarm_create (RT_ALARM *alarm, const char *name, rt_alarm_t handler, void *cookie)
Create an alarm object from kernel space.
It seems you are using the wrong one.
For a user-space alarm example and other code-snippets look in the directory
ksrc/skins/native/snippets/
kisda
[1] http://www.xenomai.org/documentation/branches/v2.4.x/html/api/index.html
> err = rt_alarm_start(&alarm,ALARM_VAL,ALARM_INT);
>
> err=rt_task_create(&alarm_handler, "ALARMtask",STAK_SIZE,TASK_PRI,TASK_MODE);
>
> if(!err)
> rt_task_start(&alarm_handler,&alarm_hand_func,NULL);
>
> return 0; // A non-zero return means
> hello_init failed; the module can't be loaded.
> }
>
> // End/Cleanup function
> static void hello_exit(void) {
>
> //rt_task_delete(&alarm_handler);
>
> rt_alarm_delete(&alarm);
>
> printk(KERN_ALERT "Goodbye world!\n");
> }
>
> module_init(hello_init);
> module_exit(hello_exit);
>
> -------------------------------------
> Hi-Tech Gears Limited, Gurgaon, India
>
>
>
>
>
> _______________________________________________
> Xenomai-help mailing list
> Xenomai-help@domain.hid
> https://mail.gna.org/listinfo/xenomai-help
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 250 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-05-25 14:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-25 9:31 [Xenomai-help] RT Task as a kernel module halts the whole system Shashank Bhatia
2009-05-25 14:02 ` Stefan Kisdaroczi
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.