The _lwp_wait() function blocks the current LWP
until the LWP specified by wait_for terminates. If
the specified LWP terminated prior to the call to _lwp_wait(), _lwp_wait() returns immediately. If wait_for
is zero, _lwp_wait() waits for any undetached LWP in
the current process. If wait_for is not zero, it
must specify an undetached LWP in the current process. If departed_lwp is not NULL, it points to a
location where the ID of the exited LWP is stored (see _lwp_exit(2)).
When an LWP exits and there are one or more LWPs in the process waiting
for this specific LWP to exit, one of the waiting LWPs is unblocked and
it returns from _lwp_wait() successfully. Any other LWPs
waiting for this same LWP to exit are also unblocked, but they return from _lwp_wait() with an error (ESRCH) indicating
the waited-for LWP no longer exists. If there are no LWPs in the process
waiting for this specific LWP to exit but there are one or more LWPs waiting
for any LWP to exit, one of the waiting LWPs is unblocked and it returns
from _lwp_wait() successfully.
If an LWP is waiting for any LWP to exit, it blocks until an undetached
LWP for which no other LWP is waiting terminates, at which time it returns
successfully, or until all other LWPs in the process are either daemon LWPs
or LWPs waiting in _lwp_wait(), in which case it returns EDEADLK.
The ID of an LWP that has exited may be reused via _lwp_create() after the LWP has been successfully waited for.
|