src/ssx/ssx/ssx_timer_core.c
/// Schedule a timer in absolute time.
///
/// \param timer The SsxTimer to schedule.
///
/// \param timeout The timer will be scheduled to time out at this absolute
/// time.  Note that if the \a timeout is less than the current time then the
/// timer will be scheduled at a minimum timeout in the future and the
/// callback will be executed in an interrupt context.
///
/// \param period If non-0, then when the timer times out it will rescheduled
/// to time out again at the absolute time equal to the last timeout time plus
/// the \a period.  By convention a \a period of 0 indicates a one-shot
/// timer that is not rescheduled.
///
/// Once created with ssx_timer_create() a timer can be \e scheduled, which
/// queues the timer in the kernel time queue.  It is not an error to call
/// ssx_timer_schedule() on a timer that is already scheduled in the time
/// queue - the timer is simply rescheduled with the new characteristics.
///
/// Return values other than SSX_OK (0) are errors; see \ref ssx_errors
///
/// \retval 0 Successful completion
///
/// \retval -SSX_INVALID_TIMER_AT_SCHEDULE A a null (0) pointer was provided as
/// the \a timer argument.
///
/// \retval -SSX_ILLEGAL_CONTEXT_TIMER The call was made from a critical
/// interrupt context.
Schedule a timer in absolute time.
\param timer The SsxTimer to schedule.

\param timeout The timer will be scheduled to time out at this absolute
time.  Note that if the \a timeout is less than the current time then the
timer will be scheduled at a minimum timeout in the future and the
callback will be executed in an interrupt context.

\param period If non-0, then when the timer times out it will rescheduled
to time out again at the absolute time equal to the last timeout time plus
the \a period.  By convention a \a period of 0 indicates a one-shot
timer that is not rescheduled.

Once created with ssx_timer_create() a timer can be \e scheduled, which
queues the timer in the kernel time queue.  It is not an error to call
ssx_timer_schedule() on a timer that is already scheduled in the time
queue - the timer is simply rescheduled with the new characteristics.

Return values other than SSX_OK (0) are errors; see \ref ssx_errors

\retval 0 Successful completion

\retval -SSX_INVALID_TIMER_AT_SCHEDULE A a null (0) pointer was provided as
the \a timer argument.

\retval -SSX_ILLEGAL_CONTEXT_TIMER The call was made from a critical
interrupt context.
Schedule a timer in absolute time . \ param timer The SsxTimer to schedule . \ param timeout The timer will be scheduled to time out at this absolute time . Note that if the \ a timeout is less than the current time then the timer will be scheduled at a minimum timeout in the future and the callback will be executed in an interrupt context . \ param period If non - 0 then when the timer times out it will rescheduled to time out again at the absolute time equal to the last timeout time plus the \ a period . By convention a \ a period of 0 indicates a one - shot timer that is not rescheduled . Once created with ssx_timer_create () a timer can be \ e scheduled which queues the timer in the kernel time queue . It is not an error to call ssx_timer_schedule () on a timer that is already scheduled in the time queue - the timer is simply rescheduled with the new characteristics . Return values other than SSX_OK ( 0 ) are errors ; see \ ref ssx_errors \ retval 0 Successful completion \ retval - SSX_INVALID_TIMER_AT_SCHEDULE A a null ( 0 ) pointer was provided as the \ a timer argument . \ retval - SSX_ILLEGAL_CONTEXT_TIMER The call was made from a critical interrupt context .
int
ssx_timer_schedule_absolute(SsxTimer*    timer,
                            SsxTimebase timeout,
                            SsxInterval period)
{
    SsxMachineContext ctx;
    ssx_critical_section_enter(SSX_NONCRITICAL, &ctx);
    if (SSX_ERROR_CHECK_API)
    {
        SSX_ERROR_IF(timer == 0, SSX_INVALID_TIMER_AT_SCHEDULE);
        SSX_ERROR_IF(__ssx_kernel_context_critical_interrupt(),
                     SSX_ILLEGAL_CONTEXT_TIMER);
    }
    timer->timeout = timeout;
    timer->period  = period;
    __ssx_timer_schedule(timer);
    ssx_critical_section_exit(&ctx);
    return SSX_OK;
}
int ssx_timer_schedule_absolute ( SsxTimer * timer , SsxTimebase timeout , SsxInterval period ) { SsxMachineContext ctx ; ssx_critical_section_enter ( SSX_NONCRITICAL , & ctx ) ; if ( SSX_ERROR_CHECK_API ) { SSX_ERROR_IF ( timer == 0 , SSX_INVALID_TIMER_AT_SCHEDULE ) ; SSX_ERROR_IF ( __ssx_kernel_context_critical_interrupt ( ) , SSX_ILLEGAL_CONTEXT_TIMER ) ; } timer -> timeout = timeout ; timer -> period = period ; __ssx_timer_schedule ( timer ) ; ssx_critical_section_exit ( & ctx ) ; return SSX_OK ; }
Schedule a timer in absolute time.
Schedule a timer in absolute time .