RTX51 full: os_wait() returns too early

Hello!

Assuming an OS timer tick interval of 5ms, os_wait() returns exactly after 5ms with the code as follows:

while (1) {
    os_wait(K_TMO, 1, 0);
}

However, with the code like that:

while (1) {
    os_wait(K_SIG, 255, 0);
    os_wait(K_TMO, 1, 0);
}

the second call to os_wait returns after something beetween 0 and 5ms.

I have read somewhere that os_wait(K_TMO, 1, 0) only waits until the next timer tick but why only in the second case?

Regards,
Markus

Parents
  • If you are going to wait one tick, then the problem is how much time is left until that tick. If you are going to wait 20 ticks, then you may get 19+eps .. 20 ticks which isn't as noticeable as when you wait for just one tick.

    You have a similar problem with normal timer interrupts. If you set the timer to produce one intrrupt every 1ms and ask your code to wait for one second (one interrupt) then you may get a zero delay.

    Your first example does not consume any time, so there will always be a full tick period. Your second example consume an unknown amount of time.

Reply
  • If you are going to wait one tick, then the problem is how much time is left until that tick. If you are going to wait 20 ticks, then you may get 19+eps .. 20 ticks which isn't as noticeable as when you wait for just one tick.

    You have a similar problem with normal timer interrupts. If you set the timer to produce one intrrupt every 1ms and ask your code to wait for one second (one interrupt) then you may get a zero delay.

    Your first example does not consume any time, so there will always be a full tick period. Your second example consume an unknown amount of time.

Children
More questions in this forum