suspend and resume of threads in Multi threading

I am using four threads in a application which are main(priority 0), sensor read(priority 6), BLE notify sender(priority 6), ideal thread(priority 15). sensor and BLE notify sender thread have same priority so they are running in co-operative scheduling 

here my problem is I can't able to suspend the sensor and BLE thread. so I can run the ideal thread.

Is there a way to do this.

BR

Karthik 

Parents
  • Hi,

     

    You can suspend and resume a thread like described in the documentation:

    https://docs.zephyrproject.org/latest/kernel/services/threads/index.html#thread-suspension

     

    However, it does sound like your problem is something else. Can you please elaborate on what is happening in your application?

     

    Kind regards,

    Håkon

  • Hi,

    sensor FIFO takes 800ms to fill up so at that time  I wanted to run the BLE thread to transmit FIFO data to central that I am able to achieve making these two thread run in co-operative thread.

    I want add more function to this when the notify disable I wanted to suspend the sensor thread so it stop filling FIFO and ideal thread can be run on that time.

     Is it possible suspend both BLE thread and sensor thread and resume some who detecting the notify enable  

    BR 

    Karthik

  • Ok, so FIFO is filled up, then the BLE thread should start sending. What you can do is to use a semaphore (in the FIFO thread) that is given when when BLE thread is finished, for instance?

    Kind regards,

    Håkon

  • thanks 

    I have switched to using k_thread_create() instead of the K_THREAD_DEFINE macro to create threads. This allows me to suspend the threads based on the notify status.

    BR,

    Karthik

  • Hi Karthik,

     

    Glad to hear that you found a solution to your problem. Hope you have a wonderful day!

     

    Kind regards,

    Håkon

Reply Children
No Data