Enable sleeping threads to run.
CS_RETCODE srv_wakeup(sleepeventp, wakeflags, reserved1, reserved2)
CS_VOID *sleepeventp; CS_INT wakeflags; CS_VOID *reserved1; CS_VOID *reserved2;
A generic void pointer to the operating system event on which the threads are sleeping.
A bit mask that modifies the way that srv_wakeup behaves. If no bits are set, the default action is to wake up all threads sleeping on the event.The bits can be OR’d together. Table 3-153 describes the legal values for wakeflags:
Value |
Description |
---|---|
SRV_M_WAKE_INTR |
The call to srv_wakeup is from interrupt level code. Failure to use this flag when calling srv_wakeup from interrupt level code can cause the Open Server application to behave erratically. Using this flag at non-interrupt level will cause the Open Server application to behave erratically. |
SRV_M_WAKE_FIRST |
Only the first thread sleeping on the event is made runnable. |
SRV_M_WAKE_ALL |
Wake up all threads sleeping on the event. |
This parameter is not used. It must be set to (CS_VOID*)0.
This parameter is not used. It must be set to (CS_VOID*)0.
srv_wakeup returns CS_FAIL if no sleeping threads were found for the event or if any parameters were in error. If one or more sleeping threads were found, srv_wakeup returns CS_SUCCEED.
Returns |
To indicate |
---|---|
CS_SUCCEED |
One or more sleeping threads were found and enabled to run. |
CS_FAIL |
The routine failed, or no sleeping threads were found. |
#include <ospublic.h>
/*
** Local Prototype.
*/
CS_RETCODE ex_srv_wakeup PROTOTYPE((
CS_VOID *sep
));
/*
** EX_SRV_WAKEUP
**
** Example routine using srv_wakeup to make all Open Server
** threads, which were previously sleeping on the specified
** sleep event, runnable again.
**
** Arguments:
** sep A generic void pointer, which was used previously in
** calls to srv_sleep to suspend threads.
**
** Returns:
** CS_SUCCEED Threads sleeping on the specified sleep event
** are runnable again.
** CS_FAIL An error was detected.
*/
CS_RETCODE ex_srv_wakeup(sep)
CS_VOID *sep;
{
/*
** Wake up threads for the specified sleep event, passing
** zero for reserved fields.
*/
if (srv_wakeup(sep, (CS_INT)SRV_M_WAKE_ALL,
(CS_VOID*)0, (CS_VOID*)0) != CS_SUCCEED)
{
return(CS_FAIL);
}
return(CS_SUCCEED);
}
srv_wakeup wakes threads that are sleeping on sleepevent.
When srv_wakeup is called from interrupt level code, the actual wakeup is deferred until the scheduler next executes.
srv_wakeup cannot be used in a SRV_START handler.
When writing preemptive mode programs with Open Server, srv_wakeup and srv_sleep must use platform-dependent mutexes. See the Open Client and Open Server Programmers Supplement for your platform for an example of preemptive scheduling.