Page 1 of 1

restart thread

Posted: Sat Sep 20, 2014 11:15 pm
by wizhippo
Is this the proper way to restart a thread? It is not working for me

Code: Select all

   chThdTerminate(SequencerThread_tp);
   chThdWait(SequencerThread_tp);

   SequencerThread_tp = chThdCreateStatic(waSequencerThread, sizeof(waSequencerThread),
                    NORMALPRIO + 9, SequencerThread, seq_events);

Re: restart thread

Posted: Sun Sep 21, 2014 7:29 am
by Giovanni
ChThdTerminate() does not kill a thread, only sets a flag that can be checked using chThdShouldTerminate(). It is up to the thread to exit after detecting the flag.

Giovanni

Re: restart thread

Posted: Sun Sep 21, 2014 12:57 pm
by wizhippo
I found my issue. The thread was restarting as expected as I was checking within it if it should terminate.
I had another condition that was terminating unexpectedly the thread after restart.

Thank you for your response