how to restart a thread?



I need, during the execution of the application, to be able to restart a thread. I am trying to do it in the following way:

while (1) {

if (sDrivers.niReset==2) {
    if (status==TX_SUCCESS)

if (sDrivers.niReset==1) {
    if (status==TX_SUCCESS)



but it doesn't work properly for me.

What would be the correct way to do it?


Thank you.


  • From the ThreadX manual :-

    However, if you look at the source code for the function tx_thread_reset() :-





    after a call to tx_thread_reset() the thread will be in the suspended state, ready to run from the entry point, a call to tx_thread_resume() will be required as well.


    I suspect the API tx_thread_reset() was added, but the documentation not updated.

  • Hello,

    I'm running exactly this method to stop and restart a thread that is using a NetX framework. I have a problem on the other hand with the dhcp_client framework which does not restart.
    if i don't delete the dhcp module before terminating my thread at reinit i get a g_dns1_err_callback_internal error.

    Which correct method should I use with the DHCP module ?...

    I use 2 threads one for the MQTTS Ethernet, the other for Web by Wifi.
    each uses a separate dhcp module, and therefore each managed by its own thread.
    The two threads do not run at the same time, when one starts up, the thread stops and resets the other thread, and vice versa.

    Thank you for your help.


  • What is the sequence of API calls you use for NetX and each NetX applications during the shutdown and restart of the thread? What are the return values from each of these API calls, are there any errors?

    g_dns1_err_callback_internal is part of the generated code of the SSP, that is used during the initialisation of the DNS client g_dns1, it is called if there is an error in creating the packet pool used by the DNS client, or creating the DNS client. Do you delete the packet pool and shut down the DNS client as part of your restart proceedure?