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

Stop Thread in CMSIS RTOS (not Terminate)

Hi

I am working with CMSIS RTOS RTX. I have an external device and some threads are running to work with this device. However, sometimes I need to turn off the device at the middle of working. Therefore, some threads are still waiting for the response from this device. Hence, I need to stop those threads. But I do not want to terminate them, because I need them later. After restarting the external device I want to have those threads as a fresh thread (not waiting in previous state). Any help is appreciated.

  • Wouldn't that be standard resource management?

    Have the threads wait for data or for "end what you are doing" event.

    If they see the event, they exit all inner loops, signals that they have reacted to the message, clear all internal state, and does a "wait for device back".
    When they do see that event that the device is back, then they start processing again with their cleared state, i.e. the same as being restarted.

    The guy who wants to power down that device?
    Send event that it will close down.
    Wait for all potential "subscriber" threads to signal that they are back at a stable state.
    Then power down.

    Then later power up and send event that "device is back".

    Play with events.
    Play with mailboxes.
    Play with semaphores.
    There are plenty of options for how to implement the logic.
    The OS is a tool kit. Start spending time figuring out what tools it contains and what the different tools are good for.