From: "Jack Whorn" <jackwhorn@domain.hid>
To: xenomai@xenomai.org
Subject: [Xenomai-help] Preemptive scheduling
Date: Wed, 28 Mar 2007 22:31:15 +0200 [thread overview]
Message-ID: <20070328203115.190280@domain.hid> (raw)
Hi,
I`m new to Xenomai and I`m experiencing some issues.
Why does a Xenomai thread (native skin) with an infinite loop hang the system, though there are higher-priority RT-threads present, and
rt_task_set_mode periodically clears T_LOCK and T_SHIELD and sets T_RRB?
Isn`t the scheduler preemptive, first considering the thread`s priority and subsequently the thread`s position in its priority`s ready queue?
I have attached some sample code.
Thanks for any hint,
Jack
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <signal.h>
#include <string.h>
#include <sys/time.h>
#include <sys/io.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <native/task.h>
#include <native/queue.h>
#include <native/intr.h>
#include <native/timer.h>
#define STACK_SIZE 8192
#define PRIO 10
static RT_TASK timer_task_desc;
// ..s.ms.µs.ns
static RTIME task_period_ns = 0100000000llu;
static unsigned long overruns = 0;
static void clean_exit(int dummy) {
rt_task_delete(&timer_task_desc);
}
static void thread(void *cookie) {
int ret;
int i;
int c;
ret = rt_task_set_mode(T_LOCK, T_RRB, &c);
if (ret)
return;
ret = rt_task_set_periodic(NULL, TM_NOW, rt_timer_ns2ticks(task_period_ns));
if (ret)
return;
while (1) {
ret = rt_task_set_mode(T_LOCK | T_SHIELD, T_RRB | T_PRIMARY, NULL);
if (ret)
return;
ret = rt_task_wait_period(&overruns);
if (ret == -ETIMEDOUT) {
} else if (ret) {
clean_exit(0);
}
while (1); /* infinite loop */
}
kill(0, SIGTERM);
}
int main(int argc, char** argv) {
int err;
signal(SIGTERM, clean_exit);
signal(SIGINT, clean_exit);
mlockall(MCL_CURRENT | MCL_FUTURE);
err = rt_task_spawn(&timer_task_desc, "thread", STACK_SIZE, PRIO, 0, &thread, NULL);
if (err)
return 0;
pause();
return EXIT_SUCCESS;
}
--
"Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ...
Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail
next reply other threads:[~2007-03-28 20:31 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-28 20:31 Jack Whorn [this message]
2007-03-28 21:20 ` [Xenomai-help] Preemptive scheduling Gilles Chanteperdrix
2007-03-29 3:17 ` Jack Whorn
2007-03-29 8:46 ` Gilles Chanteperdrix
2007-04-03 20:05 ` Jack Whorn
2007-04-03 20:24 ` Philippe Gerum
2007-04-03 20:55 ` Jack Whorn
2007-04-04 8:17 ` Philippe Gerum
2007-04-04 15:10 ` Jack Whorn
2007-04-05 18:38 ` Philippe Gerum
2007-04-10 22:47 ` Jack Whorn
2007-04-11 8:15 ` Dmitry Adamushko
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=20070328203115.190280@domain.hid \
--to=jackwhorn@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.