This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

OS_ERROR_TIMER_OVF error

I 'm got started coding the RTOS program by using RTX. And I encountered The error "OS_ERROR_TIMER_OVF" . According to the following program,It is occurred "due to User Timer Callback Queue overflow detected". So, I changed the OS_TIMERCBQS value from 4 to 25. But the error is not disappeared.

void os_error (uint32_t error_code) {
/* HERE: include optional code to be executed on runtime error. */
switch (error_code) {
case OS_ERROR_STACK_OVF: /* Stack overflow detected for the currently running task. */ /* Thread can be identified by calling svcThreadGetId(). */

tid_overstack = svcThreadGetId(); break;
case OS_ERROR_FIFO_OVF: /* ISR FIFO Queue buffer overflow detected. */ break;
case OS_ERROR_MBX_OVF: /* Mailbox overflow detected. */ break;
case OS_ERROR_TIMER_OVF: /* User Timer Callback Queue overflow detected. */ break;
default: break;
} for (;;);
} How should I do to resolve the error? If you know the solution ,Please let me know.

Parents
  • Don't put more items into the Timer_Callback queue then there are spaces in the Queue.

    Items are put into the Queue every time a timer expires (this is the 4/25 OS_TIMERCBQS)

    These items are removed from the queue by the "Timer Thread", which is typically running at the highest thread priority on the system. So, while the callbacks are running, no other threads are running.

    Until the current timer callback completes, no other callback items are removed from the Queue. If items are put into the queue faster than they can be processed, you will get an overflow.

    Here are some possible issues / concerns / solutions.

    1) put less code in your callbacks so they finish quicker. Consider these very similar to ISR processing routines and keep then very short.

    2) Make the OS_TIMERCBQS large enough to hold the maximum number of "active callback functions". This is actually required that this be large enough to hold the maximum number or you will get TIMER overflows. Timer Queue overflows is not a recoverable error.

    3) Making timers periodic can cause an unexpected / unplanned number of callbacks to be put into the queue. A periodic timer is rescheduled as soon as it is put into the TimerCallback queue and this means that another item my be put into the queue before the callback even starts to execute. You MAY want to reconsider making these items periodic and instead have the callback function add the timer when it is complete. This will assure that you never have the same timer callback function queue more than once.

    You are going to need to determine the maximum number of active callbacks that your system may have at any moment. Your OS_TIMERCBQS needs to be at least this size. You do not need to make it larger than the maximum number of active callbacks, that size is actually the perfect size. Making it larger than this number may actually hide a bug in your code. This is not always easy to calculate, but it is required if you want to be sure you will never overflow the queue. If your design does not allow you to know for sure what this number is, you will need to change your design so that you can know.

Reply
  • Don't put more items into the Timer_Callback queue then there are spaces in the Queue.

    Items are put into the Queue every time a timer expires (this is the 4/25 OS_TIMERCBQS)

    These items are removed from the queue by the "Timer Thread", which is typically running at the highest thread priority on the system. So, while the callbacks are running, no other threads are running.

    Until the current timer callback completes, no other callback items are removed from the Queue. If items are put into the queue faster than they can be processed, you will get an overflow.

    Here are some possible issues / concerns / solutions.

    1) put less code in your callbacks so they finish quicker. Consider these very similar to ISR processing routines and keep then very short.

    2) Make the OS_TIMERCBQS large enough to hold the maximum number of "active callback functions". This is actually required that this be large enough to hold the maximum number or you will get TIMER overflows. Timer Queue overflows is not a recoverable error.

    3) Making timers periodic can cause an unexpected / unplanned number of callbacks to be put into the queue. A periodic timer is rescheduled as soon as it is put into the TimerCallback queue and this means that another item my be put into the queue before the callback even starts to execute. You MAY want to reconsider making these items periodic and instead have the callback function add the timer when it is complete. This will assure that you never have the same timer callback function queue more than once.

    You are going to need to determine the maximum number of active callbacks that your system may have at any moment. Your OS_TIMERCBQS needs to be at least this size. You do not need to make it larger than the maximum number of active callbacks, that size is actually the perfect size. Making it larger than this number may actually hide a bug in your code. This is not always easy to calculate, but it is required if you want to be sure you will never overflow the queue. If your design does not allow you to know for sure what this number is, you will need to change your design so that you can know.

Children