4 . Timers, Periodic Checks, and Conditions

This module provides functions that allow users to insert hooks, i.e. user-supplied functions, that are called by the system at as specific conditions arise. These conditions differ from UNIX signals in that they are raised synchronously, via a regular function call; and that a single condition can call several different functions.

The system-defined conditions are:

CcdPROCESSOR_BEGIN_IDLE
Raised when the scheduler first finds it has no messages to execute. That is, this condition is raised at the trailing edge of the processor utilization graph.
CcdPROCESSOR_STILL_IDLE
Raised when the scheduler subsequently finds it still has no messages to execute. That is, this condition is raised while the processor utilization graph is flat.
CcdPROCESSOR_BEGIN_BUSY
Raised when a message first arrives on an idle processor. That is, raised on the rising edge of the processor utilization graph.
CcdPERIODIC
The scheduler attempts to raise this condition every few milliseconds. The scheduling for this and the other periodic conditions is nonpreemptive, and hence may be delayed until the current entry point is finished.
CcdPERIODIC_10ms
Raised every 10ms (at 100Hz).
CcdPERIODIC_100ms
Raised every 100ms (at 10Hz).
CcdPERIODIC_1second
Raised once per second.
CcdPERIODIC_10second
Raised once every 10 seconds.
CcdPERIODIC_1minute
Raised once per minute.
CcdPERIODIC_10minute
Raised once every 10 minutes.
CcdPERIODIC_1hour
Raised once every hour.
CcdPERIODIC_12hour
Raised once every twelve hours.
CcdPERIODIC_1day
Raised once every day.

CcdQUIESCENCE
Raised when the quiescence detection system has determined that the system is quiescent.
CcdSIGUSR1
Raised when the system receives the UNIX signal SIGUSR1. Be aware that this condition is thus raised asynchronously, from within a signal handler, and all the usual signal handler restrictions apply.
CcdSIGUSR2
Raised when the system receives the UNIX signal SIGUSR2.
CcdUSER
The system never raises this or any larger conditions. They can be used by the user for application-specific use. All conditions from CcdUSER to CcdUSER+256 are so available.

int CcdCallOnCondition(condnum,fnp,arg)
int condnum;
CcdVoidFn fnp;
void *arg;

This call instructs the system to call the function indicated by the function pointer fnp , with the specified argument arg , when the condition indicated by condnum is raised next. Multiple functions may be registered for the same condition number.

int CcdCallOnConditionKeep(condnum,fnp,arg)
As above, but the association is permanent- the given function will be called again whenever this condition is raised.

Returns an index that may be used to cancel the association later.

void CcdCancelCallOnCondition(int condnum, int idx)
void CcdCancelCallOnConditionKeep(int condnum, int idx)
Delete the given index from the list of callbacks for the given condition. The corresponding function will no longer be called when the condition is raised. Note that it is illegal to call these two functions to cancel callbacks from within ccd callbacks.

void CcdRaiseCondition(condNum)
int condNum;

When this function is called, it invokes all the functions whose pointers were registered for the condNum via a prior call to CcdCallOnCondition or CcdCallOnConditionKeep .

void CcdCallFnAfter(fnp, arg, msLater)
CcdVoidFn fnp;
void *arg;
unsigned int msLater;

This call registers a function via a pointer to it, fnp , that will be called at least msLater milliseconds later. The registered function fnp is actually called the first time the scheduler gets control after deltaT milliseconds have elapsed.