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.
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 ****************************************************************
// ********************** 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);
}
Stay in the know. Pulse on the new Yahoo.com. Check it out.
_______________________________________________ Xenomai-core mailing list Xenomai-core@gna.org https://mail.gna.org/listinfo/xenomai-core