Skip to contentSkip to conversation

Problems with rt_task_wait_period

Xenomai-help Steve Kreyer 3 participants 6 messages Aug 7, 2006

lore
Share & tools
lore
#0 lore raw

Hi,

Iam new to xenomai.
For warming up I try to run this little test program:

-----------------------------------------------------------------------
#include <native/task.h>
#include <stdio.h>
#include <sys/mman.h>

RT_TASK task1;

void rt_task1(void* user_data){
    int err = 0;
    printf("%d\n", rt_task_set_periodic(NULL, TM_NOW, 100));
    err = rt_task_wait_period(NULL);
    if(err){
        fprintf(stderr, "Cannot wait periodic: %d, %d\n", err, EWOULDBLOCK);

    }
}
int main(){
    char* task1_data = NULL;
    mlockall(MCL_CURRENT|MCL_FUTURE);
    rt_timer_set_mode(TM_ONESHOT);
    rt_task_spawn(&task1, "task1", 0, 99, 0, rt_task1, &task1_data);
    sleep(10);
    rt_task_delete(&task1);
    return 0;
}

-----------------------------------------------------------------------

But rt_task_wait_period gives me always the Error EWOULDBLOCK, which means that I did not set the task periodic but which in fact I did... The call to rt_task_set_periodic is succesful.
Can anyone help me figure out why? If you need additional infos please let me know...

Thanks in advance!

Steve

______________________________________________________________
Verschicken Sie romantische, coole und witzige Bilder per SMS! Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193

#1 lore raw
Quoted 10 lines · Steve Kreyer

Hi,

Iam new to xenomai.
For warming up I try to run this little test program:

-----------------------------------------------------------------------
#include <native/task.h>
#include <stdio.h>
#include <sys/mman.h>

Quoted 5 lines

RT_TASK task1;

void rt_task1(void* user_data){
    int err = 0;
    printf("%d\n", rt_task_set_periodic(NULL, TM_NOW, 100));

You are running in one-shot mode, thus all time units are in *nanoseconds*. 100 ns cycles tend to pass quite quickly, thus the setup actually fails (but it doesn't report this - a corner case for considering this a bug).

Quoted 18 lines
    err = rt_task_wait_period(NULL);
    if(err){
        fprintf(stderr, "Cannot wait periodic: %d, %d\n", err, EWOULDBLOCK);

    }
}
int main(){
    char* task1_data = NULL;
    mlockall(MCL_CURRENT|MCL_FUTURE);
    rt_timer_set_mode(TM_ONESHOT);
    rt_task_spawn(&task1, "task1", 0, 99, 0, rt_task1, &task1_data);
    sleep(10);
    rt_task_delete(&task1);
    return 0;
}

-----------------------------------------------------------------------

Quoted 8 lines

But rt_task_wait_period gives me always the Error EWOULDBLOCK, which means that I did not set the task periodic but which in fact I did... The call to rt_task_set_periodic is succesful.
Can anyone help me figure out why? If you need additional infos please let me know...

Thanks in advance!

Steve

Jan

#2 lore raw
Quoted 13 lines · Jan Kiszka
Quoted 12 lines · Steve Kreyer

Hi,

Iam new to xenomai.
For warming up I try to run this little test program:

-----------------------------------------------------------------------
#include <native/task.h>
#include <stdio.h>
#include <sys/mman.h>

RT_TASK task1;

Quoted 8 lines
Quoted 3 lines
void rt_task1(void* user_data){
    int err = 0;
    printf("%d\n", rt_task_set_periodic(NULL, TM_NOW, 100));

You are running in one-shot mode, thus all time units are in *nanoseconds*. 100 ns cycles tend to pass quite quickly, thus the setup actually fails (but it doesn't report this - a corner case for considering this a bug).

The setup does not really fail, but the period is so short that the tick occurs before the task has a chance to wait for the first release point in the timeline, so rt_task_wait_period() notices that no timer is outstanding, but incorrectly concludes that no timer was ever armed.

Quoted 34 lines
Quoted 19 lines
    err = rt_task_wait_period(NULL);
    if(err){
        fprintf(stderr, "Cannot wait periodic: %d, %d\n", err, EWOULDBLOCK);

    }
}
int main(){
    char* task1_data = NULL;
    mlockall(MCL_CURRENT|MCL_FUTURE);
    rt_timer_set_mode(TM_ONESHOT);
    rt_task_spawn(&task1, "task1", 0, 99, 0, rt_task1, &task1_data);
    sleep(10);
    rt_task_delete(&task1);
    return 0;
}

-----------------------------------------------------------------------

Quoted 8 lines

But rt_task_wait_period gives me always the Error EWOULDBLOCK, which means that I did not set the task periodic but which in fact I did... The call to rt_task_set_periodic is succesful.
Can anyone help me figure out why? If you need additional infos please let me know...

Thanks in advance!

Steve

Jan

_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help

Signature · 1 line
Philippe.
#3 lore raw
Quoted 22 lines · Philippe Gerum
Quoted 13 lines · Jan Kiszka
Quoted 12 lines · Steve Kreyer

Hi,

Iam new to xenomai.
For warming up I try to run this little test program:

-----------------------------------------------------------------------
#include <native/task.h>
#include <stdio.h>
#include <sys/mman.h>

RT_TASK task1;

Quoted 7 lines
Quoted 3 lines
void rt_task1(void* user_data){
    int err = 0;
    printf("%d\n", rt_task_set_periodic(NULL, TM_NOW, 100));

You are running in one-shot mode, thus all time units are in *nanoseconds*. 100 ns cycles tend to pass quite quickly, thus the setup actually fails (but it doesn't report this - a corner case for considering this a bug).

Quoted 4 lines

The setup does not really fail, but the period is so short that the tick occurs before the task has a chance to wait for the first release point in the timeline, so rt_task_wait_period() notices that no timer is outstanding, but incorrectly concludes that no timer was ever armed.

Mmh, wouldn't the box simply lock up if the setup succeeded? It's a periodic timer... :->

Jan

#4 lore raw
Quoted 23 lines · Jan Kiszka
Quoted 22 lines · Philippe Gerum
Quoted 20 lines · Jan Kiszka
Quoted 10 lines · Steve Kreyer

Hi,

Iam new to xenomai.
For warming up I try to run this little test program:

-----------------------------------------------------------------------
#include <native/task.h>
#include <stdio.h>
#include <sys/mman.h>

Quoted 5 lines

RT_TASK task1;

void rt_task1(void* user_data){
    int err = 0;
    printf("%d\n", rt_task_set_periodic(NULL, TM_NOW, 100));

You are running in one-shot mode, thus all time units are in *nanoseconds*. 100 ns cycles tend to pass quite quickly, thus the setup actually fails (but it doesn't report this - a corner case for considering this a bug).

Quoted 7 lines
Quoted 4 lines

The setup does not really fail, but the period is so short that the tick occurs before the task has a chance to wait for the first release point in the timeline, so rt_task_wait_period() notices that no timer is outstanding, but incorrectly concludes that no timer was ever armed.

Mmh, wouldn't the box simply lock up if the setup succeeded? It's a periodic timer... :->

No it would not, because of the first test in xnpod_wait_thread_period() that checks if the timer is still enqueued, and because the application properly tests the return value. Actually, using an additional flag to state that a timer has indeed been started would be better than recycling the enqueuing bit for the purpose of testing the timer validity. An elapsed timer is still a valid one.

Quoted 3 lines

Jan

Signature · 1 line
Philippe.
#5 lore raw
In reply to Jan Kiszka
Quoted 23 lines · Jan Kiszka
Quoted 22 lines · Philippe Gerum
Quoted 20 lines · Jan Kiszka
Quoted 10 lines · Steve Kreyer

Hi,

Iam new to xenomai.
For warming up I try to run this little test program:

-----------------------------------------------------------------------
#include <native/task.h>
#include <stdio.h>
#include <sys/mman.h>

Quoted 5 lines

RT_TASK task1;

void rt_task1(void* user_data){
    int err = 0;
    printf("%d\n", rt_task_set_periodic(NULL, TM_NOW, 100));

You are running in one-shot mode, thus all time units are in *nanoseconds*. 100 ns cycles tend to pass quite quickly, thus the setup actually fails (but it doesn't report this - a corner case for considering this a bug).

Quoted 7 lines
Quoted 4 lines

The setup does not really fail, but the period is so short that the tick occurs before the task has a chance to wait for the first release point in the timeline, so rt_task_wait_period() notices that no timer is outstanding, but incorrectly concludes that no timer was ever armed.

Mmh, wouldn't the box simply lock up if the setup succeeded? It's a periodic timer... :->

What I meant is that there is nothing in xnpod_set_thread_periodic() that actually checks if the settings are valid in the idate == XN_INFINITE case, therefore the setup never formally fails.

Quoted 3 lines

Jan

Signature · 1 line
Philippe.