This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Question on pthread_cancel/pthread_exit and thread stack unwind
Hi Yufeng,
One alternative is to make sure all items are created / destructed in the
main thread then handed over to the spawned threads, keeping track of which
object is under the domain of which TID. Use reference counting, and post
their imminent demise to a reaper list which the main thread acts
upon. Any TID that is noted causes the main thread to go through it's
outstanding object list to put all those items on the reap list -- note
that reference counts may let them stay around for a few cycles until the
things referring to them are destructed. Disallow stack based objects in
threads.
May not be doable depending on all your developers and the third party code
you use.
Or, you could try fixing those issues of pthread_cancel / pthread_exit
abuse with QA and apoplectical management.
Or, try bribing the developers with cookies and donuts. If that fails, use
thumbscrews.
Or, if you want proper garbage collecting in a multithreaded environment,
use Java. (Multithreading is a "bolt on" for C and
C++. Unfortunately. It's not going become part of the language proper any
time soon.)
--Eljay