From: mani bhatti <imranbashirbhatti@domain.hid>
To: xenomai-help <xenomai@xenomai.org>
Subject: [Xenomai-help] Problem with Aperiodic xenomai tasks
Date: Thu, 5 Oct 2006 06:57:10 -0700 (PDT) [thread overview]
Message-ID: <20061005135710.35700.qmail@domain.hid> (raw)
In-Reply-To: <451A9C64.7040802@domain.hid>
[-- Attachment #1: Type: text/plain, Size: 4240 bytes --]
HI
I want to have two tasks in xenomai the pariodic task and the non pariodic tasks which is signalled by the pariodic task.The problem is that if i make one thread pariodic and the other one non pariodic then the pariodic thread never runs after specific time period and only non pariodic thread appears .The code for tasks is given below.I would be very thankful if please some one figure out what wrong i am doing.Thanks
void zaehler1_task(void *cookie){
int ret;
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;
}
while(!end){
ret = rt_task_set_mode(0, T_RRB, 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;
}
rt_mutex_lock(&threadmutex,TM_INFINITE);
count1++;
printf("T1:Ende:%d\n", count1);
if(count1==15)
{ rt_cond_signal(&cond); }
rt_mutex_unlock(&threadmutex);
}
}
void zaehler2_task(void *cookie){
int ret;
long ii;
long jj;
double a;
while(!end){
rt_mutex_lock(&threadmutex,TM_INFINITE);
rt_cond_wait(&cond,&threadmutex,TM_INFINITE);
printf("\t\tT2:Start\n");
count2++;
printf("\t\tT2:Ende:%d\n", count2++);
rt_mutex_unlock(&threadmutex);
}
}
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;
}
rt_cond_create(&cond,NULL);
/* 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);
return 0;
}
Jan Kiszka <jan.kiszka@domain.hid> wrote: mani bhatti wrote:
> Thanks Jan for your reply
> Actually the semaphore and mutexes stuff you have referred to i have
> already grounds for them.The only problem i have is please some body
> tell me that i dont want to make a thread periodic i,e i dont want to
> call a thread after periodic time interval i wanted it to make it
> aperiodic like threads in C++ are scheduled by scheduler byitself
This has nothing to do with C++, rather with the class library you are
used to.
> and sleep on waiting condition with out any specific time interval
> and wake only when signalled from pariodic thread. I hope you
> understand my point.Thanks a lot .
Let's try it differently:
thread_a()
{
rt_task_set_periodic(...);
while (1) {
rt_task_wait_period(NULL);
/* do some work */
if (I_should_trigger_thread_b)
rt_sem_v(&sem);
}
}
thread_b()
{
while (1) {
rt_sem_p(&sem, TM_INFINITE);
/* so some other work */
}
}
Again, read up what the services are exactly doing or you will be lost
once you have to modify things only slightly.
Jan
---------------------------------
How low will we go? Check out Yahoo! Messengers low PC-to-Phone call rates.
[-- Attachment #2: Type: text/html, Size: 7840 bytes --]
next prev parent reply other threads:[~2006-10-05 13:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20060927151753.9409.qmail@domain.hid>
2006-09-27 15:44 ` [Xenomai-help] Re: [Xenomai-core] aperiodic xenomai tasks Jan Kiszka
2006-10-05 13:57 ` mani bhatti [this message]
2006-11-30 16:45 ` [Xenomai-help] porting to kernel 2.2 mani bhatti
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=20061005135710.35700.qmail@domain.hid \
--to=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.