From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Rodolfo <rolfetas@domain.hid>
Cc: Xenomai help <xenomai@xenomai.org>
Subject: Re: [Xenomai-help] loading module
Date: Wed, 23 May 2007 15:07:18 +0200 [thread overview]
Message-ID: <46543C86.3040006@domain.hid> (raw)
In-Reply-To: <46543535.5090106@domain.hid>
Rodolfo wrote:
> Gilles Chanteperdrix wrote:
>
>>Rodolfo wrote:
>>
>>
>>>Hi,
>>>I am totally new to Xenomai and have no experience with RTAI. I'm trying
>>>to load a kernel module that uses the native API for testing, but I get
>>>the following segmentation fault. Can anyone help me out??
>>>
>>
>>Please post here the sources of your module.
>>
>>
>
>
>
> here's the source of the testing module.
>
> #include <linux/module.h>
> #include <linux/kernel.h>
> #include <linux/proc_fs.h>
> #include <native/task.h>
> #include <native/types.h>
> #include <native/timer.h>
> #include <rtdm/rtdm_driver.h>
> #include <nucleus/pod.h>
>
> MODULE_LICENSE("GPL");
> MODULE_DESCRIPTION("Hello World Xenomai Application");
>
> /************************* Global Variables ******************************/
>
> RT_TASK thread;
> RTIME timer_period_ns;
> RTIME task_period_ns;
> RTIME expected;
> int timer_period_counts;
> unsigned long overrun; // rt_task_wait_period() writes here overrun
> count.0 if everything OK
>
> /************************* Periodic realtime thread **********************/
>
> void fun(int dummy) {
> int count = 0;
> while(1) {
> ++count;
> rt_task_wait_period(&overrun);
Before calling rt_task_wait_period, you should have called
rt_task_set_periodic. Here, rt_task_wait_period will continuously return
-EWOULDBLOCK and you will get a hard lockup.
> if ((count%100)==0) {
> rtdm_printk("Periode %d ist abgelaufen\n",count);
> }
> }
> }
>
> /************************* Initialisation *******************************/
>
> static int hello_init(void)
> {
> //testing rt_task_create(...);
> int count = 0;
> printk("task create");
> rt_task_create(&thread,"fun_task",3000,1,0);
> printk("created..");
> printk("task start");
> rt_task_start(&thread,fun,0);
At this point you do not know if rt_task_create succeeded, since you did
not check its return value.
> printk("started........");
>
>
>
> //timer_period_ns = 10000000;/*10ms*/
> /*timer_period_counts = start_rt_timer(nano2count(timer_period_ns));*/
>
> //timer_period_counts=rt_timer_set_mode(rt_timer_ns2tsc(timer_period_ns));
Setting the timer to periodic mode results in a lower timer resolution.
Aperiodic mode, the default is usually fine.
> /* Calculate the start time for the task. */
> /* We set this to "now plus 10 periods" */
> //expected = xnpod_get_time() + 10 * timer_period_counts;
xnpod_get_time is not part of the native API, what you want is
rt_timer_read.
>
> /* Task period initialization */
> //task_period_ns =50000000;/*5ms*/
> /*rt_task_make_periodic(&thread, expected,
> nano2count(task_period_ns));*/
> //rt_task_set_periodic(&thread, expected,
> rt_timer_ns2tsc(task_period_ns));
> return 0;
> }
>
> /************************* Cleanup *********************************/
>
> static void hello_exit(void)
> {
> /*stop_rt_timer();*/
>
> /* Now delete our task */
> // rt_task_delete(&thread);
> }
>
> module_init(hello_init);
> module_exit(hello_exit);
Why do you want to use Xenomai in kernel-space ? Since, as you said it,
you are a beginner, you should use Xenomai in user-space. There, gdb
will help you debug your segmentation faults.
--
Gilles Chanteperdrix
next prev parent reply other threads:[~2007-05-23 13:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-23 12:16 [Xenomai-help] loading module Rodolfo
2007-05-23 12:34 ` Gilles Chanteperdrix
2007-05-23 12:49 ` Rodolfo
2007-05-23 13:13 ` Gilles Chanteperdrix
[not found] ` <1179925338.6119.56.camel@domain.hid>
2007-05-23 13:31 ` Rodolfo
[not found] ` <46543535.5090106@domain.hid>
2007-05-23 13:07 ` Gilles Chanteperdrix [this message]
2007-05-23 13:32 ` Rodolfo
2007-05-23 13:44 ` Gilles Chanteperdrix
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=46543C86.3040006@domain.hid \
--to=gilles.chanteperdrix@xenomai.org \
--cc=rolfetas@domain.hid \
--cc=xenomai@xenomai.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.