/*--------------------------------------------------------------------- * Get a timer instance from the inanimate list, provide the * expiration time and insert it into its proper location among * the currently ticking timers. *-------------------------------------------------------------------*/ static ETimer_t * timer_start( const ETimer_time_t duration, Escher_xtUMLEvent_t * const event ) { ETimer_t * t; #ifdef ESCHER_TASKING_SystemC Escher_mutex_lock( SEMAPHORE_FLAVOR_TIMER ); #endif t = inanimate; if ( t != 0 ) { inanimate = inanimate->next; t->event = event; /*---------------------------------------------------------------*/ /* Calculate the timer expiration time. */ /* Note: Add one to the duration to make sure that delay is */ /* at least as long as duration. */ /*---------------------------------------------------------------*/ t->expiration = ETimer_msec_time() + duration + 1UL; timer_insert_sorted( t ); } #ifdef ESCHER_TASKING_SystemC Escher_mutex_unlock( SEMAPHORE_FLAVOR_TIMER ); Escher_nonbusy_wake( 0 ); /* Wake default task to service timers. */ #endif return ( t ); }
/*--------------------------------------------------------------------- * Generate delayed event to the application. * Deactivate fired timer. *-------------------------------------------------------------------*/ static void timer_fire( ETimer_t * const t ) { t->expiration = ( t->recurrence == 0 ) ? 0 : t->expiration + t->recurrence; Escher_SendEvent( t->event ); if ( 0 != t->recurrence ) { Escher_xtUMLEvent_t * e = Escher_AllocatextUMLEvent(); Escher_memmove( e, t->event, sizeof( Escher_xtUMLEvent_t ) ); t->event = e; #ifdef ESCHER_TASKING_POSIX Escher_mutex_lock( SEMAPHORE_FLAVOR_TIMER ); #endif animate = animate->next; /* Remove from front of list. */ timer_insert_sorted( t ); #ifdef ESCHER_TASKING_POSIX Escher_mutex_unlock( SEMAPHORE_FLAVOR_TIMER ); #endif } else { #ifdef ESCHER_TASKING_POSIX Escher_mutex_lock( SEMAPHORE_FLAVOR_TIMER ); #endif animate = animate->next; /* Remove from active list. */ t->next = inanimate; /* Connect to inactive list. */ inanimate = t; #ifdef ESCHER_TASKING_POSIX Escher_mutex_unlock( SEMAPHORE_FLAVOR_TIMER ); #endif } }
/*--------------------------------------------------------------------- * Generate delayed event to the application. * Deactivate fired timer. *-------------------------------------------------------------------*/ static void timer_fire( ETimer_t * const t ) { t->expiration = ( t->recurrence == 0 ) ? 0 : t->expiration + t->recurrence; Escher_SendEvent( t->event ); if ( 0 != t->recurrence ) { Escher_xtUMLEvent_t * e = Escher_AllocatextUMLEvent(); Escher_memmove( e, t->event, sizeof( Escher_xtUMLEvent_t ) ); t->event = e; animate = animate->next; /* Remove from front of list. */ timer_insert_sorted( t ); } else { animate = animate->next; /* Remove from active list. */ t->next = inanimate; /* Connect to inactive list. */ inanimate = t; } }
/*--------------------------------------------------------------------- * Get a timer instance from the inanimate list, provide the * expiration time and insert it into its proper location among * the currently ticking timers. *-------------------------------------------------------------------*/ ETimer_t * TIM::start( const ETimer_time_t duration, Escher_xtUMLEvent_t * const event ) { ETimer_t * t; t = inanimate; if ( t != 0 ) { inanimate = inanimate->next; t->event = event; /*---------------------------------------------------------------*/ /* Calculate the timer expiration time. */ /*---------------------------------------------------------------*/ t->expiration = ETimer_msec_time() + duration; timer_insert_sorted( t ); sc_xtuml_timer_event->notify( animate->expiration - ETimer_msec_time(), SC_MS ); } return ( t ); }
/*--------------------------------------------------------------------- * Get a timer instance from the inanimate list, provide the * expiration time and insert it into its proper location among * the currently ticking timers. *-------------------------------------------------------------------*/ static ETimer_t * timer_start( const ETimer_time_t duration, Escher_xtUMLEvent_t * const event ) { ETimer_t * t; t = inanimate; if ( t != 0 ) { inanimate = inanimate->next; t->event = event; /*---------------------------------------------------------------*/ /* Calculate the timer expiration time. */ /* Note: Add one to the duration to make sure that delay is */ /* at least as long as duration. */ /*---------------------------------------------------------------*/ t->expiration = ETimer_msec_time() + duration + 1UL; timer_insert_sorted( t ); } return ( t ); }
/*--------------------------------------------------------------------- * Generate delayed event to the application. * Deactivate fired timer. *-------------------------------------------------------------------*/ void TIM::timer_fire( ETimer_t * const t ) { ((sys_events*) t->event->thismodule)->Escher_SendEvent( t->event ); t->expiration = ( t->recurrence == 0 ) ? 0 : t->expiration + t->recurrence; if ( 0 != t->recurrence ) { Escher_xtUMLEvent_t * e = ((sys_events*) t->event->thismodule)->Escher_AllocatextUMLEvent(); ((sys_sets*) t->event->thismodule)->Escher_memmove( e, t->event, sizeof( Escher_xtUMLEvent_t ) ); t->event = e; animate = animate->next; /* Remove from front of list. */ timer_insert_sorted( t ); } else { animate = animate->next; /* Remove from active list. */ t->next = inanimate; /* Connect to inactive list. */ inanimate = t; } if ( animate != 0 ) { sc_xtuml_timer_event->notify( animate->expiration - ETimer_msec_time(), SC_MS ); } }