The fastest way to stop a thread/task

Status
Not open for further replies.

mrmu

Member
Read the multi-thread lib exmaple, and really love it. Now have a question:

What is the fastest way to stop a thread/task (even it is a blocking one)?
Assume, I have one board controls a lathe. There is a thread keeps monitoring the emergency stop button at a very high frequency (1000Hz, for example ) and running at the highest priority, higher than all the other threads. Whenever the emergency stop button is pressed some threads must stop immedietely even they are in the middle of something. I don't want to shut down the whole machine by the emergency stop button because I want to resume some work later on. Note, the subthreads don't have to save their states for later, some other thread can do that for them and just use state machine design, I guess they can just restart and check the state variables and resume their job. So what's the best way to do this? To ask them to suspend? If with freeRTOS, I guess I can vTaskDelete() ? But I assume to delete them takes longer than necessary because they will save their state first.

I guess this kind of immediate interruption of thread/taks is needed in general robots/areo/aircraft/industry control or any thing requires real time. So if any work around will benefit a lot people. Thus I put this in a separate topic rather than replying to the original multi-thread one.

thanks in advance.
 
xyou could use a watchdog or reset code to reboot if needed, but in the case of the threading (at least on teensythreads) you can stop a thread simply by ending the scope, or stop it using blocking methods and perhaps have another thread reactivate it when needed.
 
Yes. That is what I was thinking. Thanks. I will read something about the teensythreads library.
 
Status
Not open for further replies.
Back
Top