Page 1 of 1

Controlling threads

Posted: Fri Jan 04, 2013 4:33 pm
by Vanush
Hi,

I have a monitor thread that I would like to monitor ADC values under some algorithm. What is the best way to start/stop this thread from a controller thread? I would like to start it and stop it once a result has been found.

thought about using a binary semaphore, and waiting on the semaphore in the first statement of the while TRUE loop. The other thread would then signal the monitor thread to continue. However, when it reaches the top of the while loop the thread will suspend again. I would like it to continue until some point in the future determined by the controller thread.

Does anyone have any suggestions?

Re: Controlling threads

Posted: Fri Jan 04, 2013 6:18 pm
by Giovanni
Hi,

You could make the call to chSemWait() conditional and decide when to do that and when to skip it and restart, you could check a global flag.

Giovanni