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

CMSIS-RTOS osThreadYield does not pass control

Hi

I am trying to use the osThreadYield function of the CMSIS-RTOS and even though I have many other threads in the READY state, control is not passed to them and I stay in the current thread which basically hangs the entire system.

This thread is the highest priority thread which is polling a CAN bus interface for messages but I want it to give up control to allow other tasks if they need to run.

I suspect that there is a statement missing from the description below that as task will give up control to HIGHER prioirty threads that are READY. Not just any thread as they imply below.

Does anyone know if this is the case? Or why this highest priority thread will not give up control when asked to?

Thanks
Steve

osStatus osThreadYield ( void )

Returns status code that indicates the execution status of the function.

Note MUST REMAIN UNCHANGED: osThreadYield shall be consistent in every CMSIS-RTOS.

Pass control to the next thread that is in state READY. If there is no other thread in the state READY, the current thread continues execution and no thread switching occurs.

Parents Reply Children
  • The problem with documenting the API of an OS, is that the documentation has to assume that the user knows a number of general OS concept. Yield is a common OS concept and the Keil version of Yield behaves as expected from a Yield.

  • I do not necessarily agree.

    Yield means to to "give up" and without any other qualifiers it needs to be explained in the documentation as to what will gain control.

    The concept of Yield in other embedded OS's I've worked with do not have a only yield to greater thread concept in a round robin where all threads have a chance to run.

  • Yes, but Yield within the "OS concept space" means "give up the reminder of your processing time", which allows the OS to reschedule.

    And since it doesn't give up any priority, it will then become more or less a "no operation" call if there are no other tasks with suitable priority ready to run so the rescheduling has no other suitable task to pick.

    The a manual has a bit of a problem with how much time to spend on defining concepts like:
    - yield
    - time slice
    - quantum
    - priority
    - round robin
    - priority inversion
    - preemption
    - ...

    if assuming that the reader isn't complementing the manual with a general text about operating system concepts and functionality.

    Everyone might pick up on round robin being just a circular buffer - so sounds just about the same as for a serial port data buffer. But for an OS, it suddenly involves threads of same priority - and that are ready aka runnable. So it's a hard task to make the API documentation fully self-contained. There will always be things that can be improved. But there will also always be things that must be left for the reader to pick up by complementary sources.