restart thread

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
wizhippo
Posts: 18
Joined: Thu Oct 31, 2013 3:41 pm

restart thread

Post 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);
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: restart thread

Post 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
wizhippo
Posts: 18
Joined: Thu Oct 31, 2013 3:41 pm

Re: restart thread

Post 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
Post Reply