_LWP_PARK(2) | System Calls Manual | _LWP_PARK(2) |
_lwp_park
—
#include <lwp.h>
int
_lwp_park
(clockid_t
clock_id, int
flags, struct timespec
*ts, lwpid_t
unpark, const void
*hint, const void
*unparkhint);
_lwp_park
() can be used to synchronize access to
resources among multiple light-weight processes. It causes the calling LWP to
wait interruptably in the kernel, until one of the following conditions is
met:
NULL
,
and the time it specifies has passed. The ts time
can be an relative interval to wait if the flags
argument does not contain TIMER_ABSTIME
or it can
be an absolute time. The clock_id argument contains
the clock to be used; it can be: CLOCK_REALTIME
or
CLOCK_MONOTONIC
._lwp_kill
(), or is elected to handle a signal on
behalf of its containing process._lwp_wakeup
()._lwp_unpark
() or
_lwp_unpark_all
().If the ts argument contains a relative time
interval, it will be modified to contain the remaining time to sleep when
_lwp_park
() returns.
The preferred method to awaken an LWP sleeping as a result of a
call to _lwp_park
() is to make a call to
_lwp_unpark
(), or
_lwp_unpark_all
(). The
_lwp_wakeup
() system call is a more general
facility, and requires more resources to execute.
The optional hint argument specifies the
address of object upon which the LWP is synchronizing. When the
hint value is matched between calls to
_lwp_park
() and
_lwp_unpark
() or
_lwp_unpark_all
(), it may reduce the time necessary
for the system to resume execution of waiting LWPs.
The unpark and unparkhint arguments can be used to fold a park operation and unpark operation into a single system call. If unpark is non-zero, the system will behave as if the following call had been made before the calling thread begins to wait:
_lwp_unpark(unpark, unparkhint);
_lwp_park
() may return a value of 0. Otherwise, -1 is
returned and errno is set to provide more information.
EALREADY
]EINTR
]_lwp_unpark
(),
_lwp_unpark_all
(),
_lwp_wakeup
().EINVAL
]ESRCH
]ETIMEDOUT
]_lwp_park
() system call first appeared in
NetBSD 5.0.
December 7, 2017 | NetBSD 9.0 |