This is Unofficial EPICS BASE Doxygen Site
osdEvent.c File Reference
#include <vxWorks.h>
#include <semLib.h>
#include <time.h>
#include <objLib.h>
#include <sysLib.h>
#include <limits.h>
#include "epicsEvent.h"
+ Include dependency graph for osdEvent.c:

Go to the source code of this file.

Functions

int sysClkRateGet (void)
 
epicsEventId epicsEventCreate (epicsEventInitialState initialState)
 Create an epicsEvent for use from C code, or return NULL. More...
 
void epicsEventDestroy (epicsEventId id)
 Destroy an epicsEvent and any resources it holds. More...
 
epicsEventStatus epicsEventWaitWithTimeout (epicsEventId id, double timeOut)
 Wait an the event or until the specified timeout period is over. More...
 
epicsEventStatus epicsEventTryWait (epicsEventId id)
 Similar to wait() except that if the event is currenly empty the call will return immediately with status epicsEventWaitTimeout. More...
 
void epicsEventShow (epicsEventId id, unsigned int level)
 Display information about the semaphore. More...
 

Function Documentation

epicsEventId epicsEventCreate ( epicsEventInitialState  initialState)

Create an epicsEvent for use from C code, or return NULL.

Parameters
initialStateStarting state, epicsEventEmpty or epicsEventFull.
Returns
An identifier for the new event, or NULL if one not be created.

Definition at line 25 of file osdEvent.c.

26 {
27  return (epicsEventId) semBCreate(SEM_Q_FIFO,
28  (initialState == epicsEventEmpty) ? SEM_EMPTY : SEM_FULL);
29 }
void epicsEventDestroy ( epicsEventId  id)

Destroy an epicsEvent and any resources it holds.

No calls to any epicsEventWait routines can be active when this call is made.

Parameters
idThe event identifier.

Definition at line 31 of file osdEvent.c.

32 {
33  semDelete((SEM_ID)id);
34 }
void epicsEventShow ( epicsEventId  id,
unsigned int  level 
)

Display information about the semaphore.

Note
The information displayed is architecture dependant.
Parameters
idThe event identifier.
levelAn unsigned int for the level of information to be displayed.

Definition at line 71 of file osdEvent.c.

72 {
73  semShow((SEM_ID)id,level);
74 }
epicsEventStatus epicsEventTryWait ( epicsEventId  id)

Similar to wait() except that if the event is currenly empty the call will return immediately with status epicsEventWaitTimeout.

Parameters
idThe event identifier.
Returns
Status indicator, epicsEventWaitTimeout when the event is empty.

Definition at line 60 of file osdEvent.c.

61 {
62  int status = semTake((SEM_ID)id, NO_WAIT);
63 
64  if (status == OK)
65  return epicsEventOK;
66  if (errno == S_objLib_OBJ_UNAVAILABLE)
67  return epicsEventWaitTimeout;
68  return epicsEventError;
69 }
pvd::Status status
epicsEventStatus epicsEventWaitWithTimeout ( epicsEventId  id,
double  timeOut 
)

Wait an the event or until the specified timeout period is over.

Note
Blocks until full or timeout.
Parameters
idThe event identifier.
timeOutThe timeout delay in seconds.
Returns
Status indicator.

Definition at line 36 of file osdEvent.c.

37 {
38  int rate = sysClkRateGet();
39  int status;
40  int ticks;
41 
42  if (timeOut <= 0.0) {
43  ticks = 0;
44  } else if (timeOut >= (double) INT_MAX / rate) {
45  ticks = WAIT_FOREVER;
46  } else {
47  ticks = timeOut * rate;
48  if (ticks <= 0)
49  ticks = 1;
50  }
51  status = semTake((SEM_ID)id, ticks);
52  if (status == OK)
53  return epicsEventOK;
54  if (errno == S_objLib_OBJ_TIMEOUT ||
55  (errno == S_objLib_OBJ_UNAVAILABLE && ticks == 0))
56  return epicsEventWaitTimeout;
57  return epicsEventError;
58 }
int sysClkRateGet(void)
pvd::Status status
int sysClkRateGet ( void  )