void _Timer_Routine_adaptor( Watchdog_Control *the_watchdog ) { Timer_Control *the_timer; Per_CPU_Control *cpu; the_timer = RTEMS_CONTAINER_OF( the_watchdog, Timer_Control, Ticker ); cpu = _Watchdog_Get_CPU( &the_timer->Ticker ); the_timer->stop_time = _Timer_Get_CPU_ticks( cpu ); ( *the_timer->routine )( the_timer->Object.id, the_timer->user_data ); }
unsigned int alarm( unsigned int seconds ) { unsigned int remaining; Watchdog_Control *the_watchdog; ISR_lock_Context lock_context; ISR_lock_Context lock_context2; Per_CPU_Control *cpu; uint64_t now; uint32_t ticks_per_second; uint32_t ticks; the_watchdog = &_POSIX_signals_Alarm_watchdog; ticks_per_second = TOD_TICKS_PER_SECOND; ticks = seconds * ticks_per_second; _ISR_lock_ISR_disable_and_acquire( &_POSIX_signals_Alarm_lock, &lock_context ); cpu = _Watchdog_Get_CPU( the_watchdog ); _Watchdog_Per_CPU_acquire_critical( cpu, &lock_context2 ); now = cpu->Watchdog.ticks; remaining = (unsigned long) _Watchdog_Cancel( &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ], the_watchdog, now ); if ( ticks != 0 ) { cpu = _Per_CPU_Get(); _Watchdog_Set_CPU( the_watchdog, cpu ); _Watchdog_Insert( &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ], the_watchdog, now + ticks ); } _Watchdog_Per_CPU_release_critical( cpu, &lock_context2 ); _ISR_lock_Release_and_ISR_enable( &_POSIX_signals_Alarm_lock, &lock_context ); return ( remaining + ticks_per_second - 1 ) / ticks_per_second; }