From: Jan Kiszka <jan.kiszka@domain.hid>
To: mani bhatti <imranbashirbhatti@domain.hid>
Cc: xenomai@xenomai.org
Subject: [Xenomai-help] Re: [Xenomai-core] aperiodic xenomai tasks
Date: Tue, 26 Sep 2006 18:00:06 +0200 [thread overview]
Message-ID: <45194E86.4090002@domain.hid> (raw)
In-Reply-To: <20060926154124.45256.qmail@domain.hid>
[-- Attachment #1: Type: text/plain, Size: 5587 bytes --]
mani bhatti wrote:
> Hi friends
> i want to create two aperiodic tasks .I have made a small example and created two tasks and set their priority equal.i have removed rt_task_setPeriodic function from the code but problem is that the task which is started first only it works and the second task which is started later never shows up.If some one tells me the cause of this problem i would be very grateful.The source code is given below.
First of all, please post such requests for help to the xenomai-help
list (I already changed the address in this reply). Xenomai-core is
intended for discussions about the internals of Xenomai.
>
> void zaehler1_task(void *cookie){
> int ret;
>
> // ************************* Xenomai-Krempel ********************************************************************
> // ret = rt_task_set_periodic(NULL, TM_NOW, rt_timer_ns2ticks(task_period_ns1));
> // if (ret) {
> // printf("error while set periodic, code %d\n",ret);
> // return;
> // }
> // ************************* Ende Xenomai-Krempel ****************************************************************
Well, by commenting out this "Xenomai-Krempel" (be careful, people on
these lists may understand German ;)), your real-time task below enters
an infinite loop without any delays (except for the printing).
rt_task_wait_period always fails if you do not switch periodic mode on.
Therefore, the second task never gets a chance to be started.
What was your motivation behind this? You need some clocking for the
real-time task, either periodical timer-driven or some explicit
rt_task_sleep, or you pend it on an external event (provided by a driver
or whatever).
>
>
> // ********************** Beginn des wiederholt ausgefuehrten Codes **********************************************
> while(!end){
> ret = rt_task_set_mode(0, T_PRIMARY, NULL);
> if (ret) {
> printf("error while rt_task_set_mode, code %d\n",ret);
> return;
> }
> ret = rt_task_wait_period();
> printf("T1:Start\n");
>
> if (ret) {
> // printf("error while rt_task_wait_period, code %d\n",ret);
> // return;
> }
> count1++;
>
> printf("T1:Ende:%d\n", count1);
>
> fflush(NULL);
> }
> // ********************** Ende des wiederholt ausgefuehrten Codes ***********************************************
> }
>
> void zaehler2_task(void *cookie){
> int ret;
> long ii;
> long jj;
> double a;
>
> // ************************* Xenomai-Krempel ********************************************************************
> // ret = rt_task_set_periodic(NULL, TM_NOW, rt_timer_ns2ticks(task_period_ns2));
> // if (ret) {
> // printf("error while set periodic, code %d\n",ret);
> // return;
> // }
> // ************************* Ende Xenomai-Krempel ****************************************************************
>
> // ********************** Beginn des wiederholt ausgefuehrten Codes **********************************************
> while(!end){
> ret = rt_task_set_mode(0, T_PRIMARY, NULL);
> if (ret) {
> printf("error while rt_task_set_mode, code %d\n",ret);
> return;
> }
> ret = rt_task_wait_period();
>
> printf("\t\tT2:Start\n");
>
> if (ret) {
> // printf("error while rt_task_wait_period, code %d\n",ret);
> // return;
> }
>
> // for(ii=0; ii<200; ii++) {
> // for(jj=0; jj<1000000; jj++) {
> // a = (double)ii * (double)jj;
> // }
> // }
>
> count2++;
> printf("\t\tT2:Ende:%d\n", count2++);
>
> fflush(NULL);
> }
> // ********************** Ende des wiederholt ausgefuehrten Codes **
>
>
> int main(int argc, char *argv[]) {
> int err, ret;
> printf("start\n");
> // install signal handler
> signal(SIGTERM, clean_exit);
> signal(SIGINT, clean_exit);
> // start timer
> ret = rt_timer_start(TM_ONESHOT);
> switch (ret) {
> case 0: printf("Mit dem Fahrrad nich inn ersten Wagen\n\n");
> break;
> case -EBUSY: printf("timer is running\n");
> break;
> case -ENOSYS: printf("can't start timer\n");
> return ret;
> }
>
> /* create zaehler1_task */
> err = rt_task_create(&zaehler1_task_ptr,"Zaehler_1",STACK_SIZE,STD_PRIO1,0);
> /* create zaehler2_task */
> err = rt_task_create(&zaehler2_task_ptr,"Zaehler_2",STACK_SIZE,STD_PRIO2,0);
>
> /* start zaehler1_task */
> err = rt_task_start(&zaehler1_task_ptr,&zaehler1_task,NULL);
>
> /* start zaehler2_task */
> err = rt_task_start(&zaehler2_task_ptr,&zaehler2_task,NULL);
>
> // wait for signal & return of signal handler
> pause();
> fflush(NULL);
> }
>
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 250 bytes --]
next prev parent reply other threads:[~2006-09-26 16:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-26 15:41 [Xenomai-core] aperiodic xenomai tasks mani bhatti
2006-09-26 16:00 ` Jan Kiszka [this message]
[not found] <20060927135543.26891.qmail@domain.hid>
2006-09-27 14:34 ` [Xenomai-help] " Jan Kiszka
[not found] <20060927151753.9409.qmail@domain.hid>
2006-09-27 15:44 ` Jan Kiszka
[not found] <20061005134524.92486.qmail@domain.hid>
2006-10-05 15:24 ` Jan Kiszka
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=45194E86.4090002@domain.hid \
--to=jan.kiszka@domain.hid \
--cc=imranbashirbhatti@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.