From: Jan Kiszka <jan.kiszka@domain.hid>
To: Saul <xeno@domain.hid>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] Non-deterministic behaviour in primary mode
Date: Wed, 29 Mar 2006 13:28:28 +0200 [thread overview]
Message-ID: <442A6F5C.50602@domain.hid> (raw)
In-Reply-To: <1143612388.32703.257789950@domain.hid>
[-- Attachment #1: Type: text/plain, Size: 4111 bytes --]
Saul wrote:
> Hi,
>
> I'm trying to run a short test program, just to get into the swing
> of this shiny new real-time system. I'm running Xenomai 2.1.0 on
> kernel 2.6.15.6
>
> The following program runs a busy delay in primary mode (verified by
> enabling the primary mode switch warning) and calculates the time taken.
> Another task is resumed and prints the time.
>
> I get output something like this:
> 1: 40.017 ms
> 2: 40.017 ms
> 3: 53.357 ms
> 4: 53.356 ms
> 5: 40.017 ms
> 6: 40.020 ms
> 7: 53.355 ms
> 8: 40.020 ms
> 9: 40.017 ms
> 10: 53.356 ms
> 11: 40.020 ms
> 12: 40.019 ms
> 13: 106.710 ms
> 14: 40.017 ms
> 15: 40.018 ms ...
>
> I assume I've done something silly but I can't find anything wrong. My
> computer is a 3GHz P4. Xenomai is built-in statically, and at boot says
> "Xenomai: SMI-enabled Intel chipset found, enabling SMI workaround."
>
> Anyway, the erratic execution times come and go with the smallest
> changes in the program e.g. moving the delay into it's own function or
> creating functions for timing the delay loop, so I wouldn't be too
> surprised if the problem can't be reproduced.
>
> Also, I found that using rt_timer_spin() instead of a real busy loop
> does not have the same problem, which indicates that the simple busy
> loop is in fact being interrupted during execution.
>
> Is it a problem that I'm not explicitly destroying the tasks? They don't
> linger in /proc/xenomai/sched once the program is killed. How much
> is automatically cleaned up upon process exit?
Tasks are cleaned up, other stuff not.
>
> #include <stdio.h>
> #include <stdlib.h> // exit
> #include <unistd.h> // pause
> #include <sys/mman.h> // mlockall
> #include <signal.h>
> #include <xenomai/native/task.h>
> #include <xenomai/native/timer.h>
>
> #define MS 1000000
>
> RT_TASK timed_task;
> RT_TASK display_task;
> int timed_count = 0;
> double timed_delay = 0;
>
> void my_processing(void)
> {
> int i;
> // rt_timer_spin(40*MS);
> for (i=80000000; --i; );
> }
>
> void timed_task_handler(void *cookie)
> {
> RTIME start_tsc = rt_timer_tsc();
> rt_task_set_mode(0, T_WARNSW, NULL);
> for (timed_count=0;;) {
> rt_task_sleep(40*MS); /* allow linux to run */
>
> RTIME prev_tsc = rt_timer_tsc();
> my_processing();
> RTIME tsc = rt_timer_tsc();
> timed_delay = rt_timer_tsc2ns(tsc-prev_tsc)*1e-9;
>
> timed_count++;
> rt_task_resume(&display_task);
> if (timed_count >= 100)
> break;
> }
> rt_task_set_mode(T_WARNSW, 0, NULL);
> printf("total time: %.3f\n",
> rt_timer_tsc2ns(rt_timer_tsc()-start_tsc)*1e-6);
> exit(0);
> }
>
> void display_task_handler(void *cookie)
> {
> for (;;) {
> rt_task_suspend(NULL);
> printf("%3d: %.3f ms\n",
> timed_count, timed_delay * 1e3);
> }
> exit(0);
> }
>
> void context_switch_warn_handler(int sig)
> {
> printf("WARNING: detected switch to secondary mode\n");
> }
>
> int main(int argc, char *argv[])
> {
> int err;
> mlockall(MCL_CURRENT|MCL_FUTURE);
> signal(SIGXCPU, context_switch_warn_handler);
> rt_timer_set_mode(TM_ONESHOT);
> rt_task_spawn(&timed_task, "timed-task",
> 0, 99, 0, timed_task_handler, 0);
> rt_task_spawn(&display_task, "display-task",
> 0, 98, 0, display_task_handler, 0);
> pause();
> return 0;
> }
>
> Any clues?
> Thanks in advance,
> Saul.
>
No obvious problem with your program. Does the latency test of Xenomai
show any significant times? Maybe the SMI workaround does not catch all
issues on your system (though up to 60 ms jitter is still quite a lot).
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 250 bytes --]
next prev parent reply other threads:[~2006-03-29 11:28 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-29 6:06 [Xenomai-help] Non-deterministic behaviour in primary mode Saul
2006-03-29 11:28 ` Jan Kiszka [this message]
2006-03-30 4:27 ` Saul
2006-03-29 12:27 ` Philippe Gerum
2006-03-30 4:47 ` Saul
2006-03-30 12:05 ` Gilles Chanteperdrix
2006-03-31 6:44 ` Saul
2006-03-30 21:00 ` Philippe Gerum
2006-03-31 7:43 ` Saul
2006-03-31 9:55 ` Philippe Gerum
2006-03-31 15:35 ` Gilles Chanteperdrix
2006-04-11 3:06 ` Saul
2006-04-11 12:08 ` Gilles Chanteperdrix
2006-04-12 0:56 ` Saul
2006-04-12 7:49 ` Jan Kiszka
2006-03-29 12:41 ` Philippe Gerum
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=442A6F5C.50602@domain.hid \
--to=jan.kiszka@domain.hid \
--cc=xeno@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.