STREAMS-UX Programmer's Guide (February 2007)
STREAMS Utilities Supported by HP-UX
Appendix B
212
NAME
streams_mpsleep () – Suspend process execution pending occurrence of an event.
SYNOPSIS
#include <sys/stream.h>
#include <sys/strenv.h>
int streams_mpsleep(caddr_t event, int pri, caddr_t mesg, int tmo, void *lockp, int flags);
PARAMETERS
event
Kernel address signifying an event for which the caller wishes to wait.
pri
Priority value the caller wishes to sleep at.
mesg
Not used, provided for portability.
tmo
Number of ticks after which the process executing needs to be resumed.
lockp
A pointer to the lock if held by the driver/module using spinlock() API’s during this call.
flags
Not used, provided for portability.
DESCRIPTION
streams_mpsleep() must be used by the drivers or modules in their open and close routines to sleep instead
of the native HP-UX sleep primitive. This function suspends the execution of a process to await the
occurrence of an event. The process that called streams_mpsleep() can be resumed by a call to wakeup()
with the same event specified as that used to call streams_mpsleep().
The address event, has no significance except that the same address must be passed to:
— streams_get_sleep_lock() to acquire the sleep lock before sleeping. (streams_mpsleep() will verify and
acquire the sleep lock if not already acquired by the driver or module when a call to this function is made.)
— wakeup() to resume the sleeping process
The value of the priority argument determines whether the sleep may be interrupted by signals. If the value
of priority is less than or equal to the value of the constant PZERO (defined in <sys/param.h>), the sleeping
process will not be awakened by a signal. If the value of priority is greater than PZERO, the process will wake
up prematurely (without a call to wakeup) upon receipt of a non-ignored, non-held signal and will normally
return 1 to the calling code.
Unlike the native HP-UX sleep, the caller can provide the duration of time in ticks (tmo) for which the process
execution needs to be suspended through this function.
If the lock specified by lockp is held by the caller on entry, it will be released in streams_mpsleep(), before
suspending the execution of the process. When the streams_mpsleep() returns to the caller, this lock will not
be held.
RETURN VALUES
streams_mpsleep() returns:
0 — if the caller woke up because of a call to wakeup ()
1 — if a priority value greater than PZERO is specified and the process was interrupted and woken up
prematurely.