This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: GCJ built multithreaded program keeps creating zombies
- From: Wolfgang Bangerth <bangerth at ticam dot utexas dot edu>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: gcc-bugs at gcc dot gnu dot org, <aeby at graeff dot com>
- Date: Wed, 18 Dec 2002 18:09:21 -0600 (CST)
- Subject: Re: GCJ built multithreaded program keeps creating zombies
> Wolfgang> But in his code there is a Thread.join(), so if this does
> Wolfgang> something it probably calls waitpid(), no?
>
> Nope, Thread.join is implemented in a platform-independent way.
> There are no calls to pthread_join in libgcj.
OK, I see, you set a mutex on exit of the new thread, and in join() you
just wait to get it. Is this right?
Then on Linux you will create a zombie for every thread you create. I
think one should either have the equivalent of waitpid() or pthread_join
to release the zombies into the realm of the truly dead. Unfortunately, I
can't find the place where you actually create a new thread right away...
The problem is more general then, though, as something likewise must
happen on every OS: when you create a new thread or process, the OS
reserves some space for the return value (an int for a process, a void*
for a process), which it has to keep even after the death of the process
or thread. If you don't ask the OS for this value (which you do with
waitpid or pthread_join), the OS will not release this memory until the
end of the spawning thread or process. If you create _many_ threads, this
may become a problem also on systems other than Linux.
Regards
Wolfgang
-------------------------------------------------------------------------
Wolfgang Bangerth email: bangerth@ticam.utexas.edu
www: http://www.ticam.utexas.edu/~bangerth