|HP-UX Reference > P
postwait(2)HP-UX 11i Version 3: February 2007
postwait: pw_getukid(), pw_wait(), pw_post(), pw_postv(), pw_getvmax() — lightweight synchronization mechanism
#include <sys/time.h> #include <sys/pw.h> int pw_getukid(ukid_t *ukid); int pw_wait(struct timespec *ts); int pw_post(ukid_t ukid); int pw_postv(int count, ukid_t targets, int errors); int pw_getvmax(void);
Postwait is a fast, lightweight sleep/wakeup mechanism that can be used for synchronization by cooperating kernel threads within a single process or between separate processes.
A thread calls pw_wait() to block. It resumes execution when it is posted by another thread, the call expires, or is signaled. If one or more posts are already pending, pw_wait returns immediately.
Threads using postwait are identified by their ukid. A thread retrieves its ukid by calling pw_getukid(). It shares this ukid with anyone it chooses by any means it considers appropriate (for example, shared memory).
pw_wait() is called with a timeout ts. If ts is NULL, the thread will not timeout. It will remain blocked until posted or a signal wakes it up.
If ts points to a zero-valued timespec, pw_wait() will return immediately with a value (and errno) indicating whether or not it was posted.
If ts points to a timespec whose value is greater than zero, the thread will block for that amount of time unless it is posted or interrupted by a signal, in which case the timespec pointed to by ts is updated with the remaining time. The return value and errno are set to indicate the reason the call returned.
pw_postv() is used to post many threads with a single call. It posts to all threads in the targets array. An errno value for each target is returned in the errors array. (0 indicates success.) If the errors pointer is zero, no target-specific errors are copied out.
There is a maximum number of threads that can be posted with a single pw_postv() call. This value is returned by pw_getvmax().
Posts sent to a kernel thread that already has a post pending against it are discarded.
pw_getukid() returns 0 if it succeeds, -1 otherwise.
pw_wait() returns 0 if posted, -1 otherwise.
pw_post() returns 0 if the post succeeds, -1 otherwise.
pw_postv() returns 0 if every post succeeds, -1 otherwise.
pw_getvmax() returns the maximum number of kernel threads that can be posted with a single call to pw_postv().
pw_getukid() sets errno to one of the following values if it fails:
pw_wait() sets errno to one of the following values if it fails:
pw_post() sets errno to one of the following values if it fails:
pw_postv() sets errno to one of the following values if it fails: