Ksem lifetime?

alanlb at rrinc.com alanlb at rrinc.com
Fri May 19 11:38:36 PDT 2000


Hello, folks.

Here's another detail that I've been puzzling over while debugging the
beos-native Ksem implementation: when is a Ksem that isn't explicitly
destroyed actually destroyed?  Is a Ksem's lifetime co-terminal with
its "owner", or does it continue existing until explicitly destroyed?

In BeOS, a thread T and all other threads spawned by T belong to a team,
which "owns" all semaphores created by the threads in the team; thus,
if a child thread creates a semaphore and then exits, that semaphore
is not automatically destroyed.

I've been assuming all along that each jthread destroys all of the locks
that it created itself, prior to invoking jthread_exit.  Is this
assumption correct, or should I add code to my threading layer that
destroys each of a native thread's semaphores immediately before the
thread itself exits?

/Alan


More information about the kaffe mailing list