srv_wakeup

Description

Enable sleeping threads to run.

Syntax

CS_RETCODE srv_wakeup(sleepeventp, wakeflags,
                   reserved1, reserved2)
CS_VOID          *sleepeventp;
CS_INT             wakeflags;
CS_VOID          *reserved1;
CS_VOID          *reserved2;

Parameters

sleepeventp

A generic void pointer to the operating system event on which the threads are sleeping.

wakeflags

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-150 describes the legal values for wakeflags:

Table 3-150:  Values for wakeflags (srv_wakeup)

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.

reserved1

This parameter is not used. It must be set to (CS_VOID*)0.

reserved2

This parameter is not used. It must be set to (CS_VOID*)0.

Returns

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.

Table 3-151:  Return values (srv_wakeup)

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.

Examples

Example 1

#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);
}

Usage

See also

srv_sleep