Hi Everyone,
I recently worked for some epics drivers to implement a graceful shutdown and got a question.
The drivers are SLAC specific but the question is general.
I saw there are some API changes to allow joinable thread.
Thus, I used it: "epicsThreadCreateOpt() with joinable option, and epicsThreadMustJoin()"
It looks mostly the same as the old way but is slightly better personally.
old way:
- The exit hook breaks an infinite loop in driver thread
- driver thread send an event when it returns
- main thread (the exit hook) waits the event from the driver thread then exits
new with joinable thread:
- The exit hook breaks an infinite loop in the driver thread
- driver thread simply returns
- main thread (the exit hook) waits with epicsThreadMustJoin() then exits
There is a small downside: more steps to create thread - I have to set up a thread option structure before calling epicsThreadCreateOpt(),
Since, the un-joinable thread is default and it is for backward compatibility.
I am wondering about our evolutional direction:
Are we going to keep the un-joinable thread as a default? Or, migrate to the joinable thread?
Thank you for your advice.
I hope everyone keeps stay healthy and safe.
Best regards,
Kukhee
Kukhee Kim
TID AIR Advanced Control System
SLAC National Accelerator Laboratory
2575 Sand Hill Rd, MS 94
Menlo Park, CA 94025
Email:
khkim at SLAC.Stanford.EDU
Phone: (650)926-4912
Fax: (650)926-2923
|