/* * Timer Service Routine * * If we are in an ISR, then this is a normal clock tick. * If we are not, then it is the test case. */ rtems_timer_service_routine test_unblock_task( rtems_id timer, void *arg ) { bool in_isr; rtems_status_code status; in_isr = rtems_interrupt_is_in_progress(); status = rtems_task_is_suspended( blocked_task_id ); if ( in_isr ) { status = rtems_timer_fire_after( timer, 1, test_unblock_task, NULL ); directive_failed( status, "timer_fire_after failed" ); return; } if ( (status != RTEMS_ALREADY_SUSPENDED) ) { status = rtems_timer_fire_after( timer, 1, test_unblock_task, NULL ); directive_failed( status, "timer_fire_after failed" ); return; } blocked_task_status = 2; _Thread_Disable_dispatch(); status = rtems_task_resume( blocked_task_id ); _Thread_Unnest_dispatch(); #if defined( RTEMS_SMP ) directive_failed_with_level( status, "rtems_task_resume", 1 ); #else directive_failed( status, "rtems_task_resume" ); #endif }
rtems_task Test_task( rtems_task_argument argument ) { rtems_id tid; rtems_status_code status; status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid ); directive_failed( status, "rtems_task_ident" ); puts( "Getting TID of remote task" ); remote_node = (Multiprocessing_configuration.node == 1) ? 2 : 1; printf( "Remote task's name is : " ); put_name( Task_name[ remote_node ], TRUE ); do { status = rtems_task_ident( Task_name[ remote_node ], RTEMS_SEARCH_ALL_NODES, &remote_tid ); } while ( status != RTEMS_SUCCESSFUL ); directive_failed( status, "rtems_task_ident" ); status = rtems_timer_fire_after( Timer_id[ 1 ], 5 * rtems_clock_get_ticks_per_second(), Delayed_send_event, NULL ); directive_failed( status, "rtems_timer_fire_after" ); Test_Task_Support( 1 ); status = rtems_timer_fire_after( Timer_id[ 1 ], 5 * rtems_clock_get_ticks_per_second(), Delayed_send_event, NULL ); directive_failed( status, "rtems_timer_fire_after" ); if ( Multiprocessing_configuration.node == 1 ) { status = rtems_task_wake_after( 2 * rtems_clock_get_ticks_per_second() ); directive_failed( status, "rtems_task_wake_after" ); } Test_Task_Support( 2 ); puts( "*** END OF TEST 3 ***" ); rtems_test_exit( 0 ); }
rtems_task Task_1_through_3( rtems_task_argument argument ) { rtems_id tid; rtems_time_of_day time; rtems_status_code status; status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid ); directive_failed( status, "rtems_task_ident of self" ); while ( FOREVER ) { status = rtems_timer_fire_after( Timer_id[ argument ], task_number( tid ) * 5 * TICKS_PER_SECOND, Resume_task, NULL ); directive_failed( status, "tm_fire_after failed" ); status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time ); directive_failed( status, "rtems_clock_get failed" ); if ( time.second >= 35 ) { puts( "*** END OF TEST 24 ***" ); rtems_test_exit( 0 ); } put_name( Task_name[ task_number( tid ) ], FALSE ); print_time( " - rtems_clock_get - ", &time, "\n" ); status = rtems_task_suspend( RTEMS_SELF ); directive_failed( status, "rtems_task_suspend" ); } }
static void timer_task(rtems_task_argument arg) { test_context *ctx = (test_context *) arg; rtems_status_code sc; rtems_id timer_id; rtems_test_assert(rtems_get_current_processor() == 1); sc = rtems_timer_create(SCHEDULER_B, &timer_id); rtems_test_assert(sc == RTEMS_SUCCESSFUL); /* (A) */ wait(ctx, &ctx->timer_barrier_state); sc = rtems_timer_fire_after(timer_id, 1, timer_isr, ctx); rtems_test_assert(sc == RTEMS_SUCCESSFUL); sc = rtems_task_wake_after(1); rtems_test_assert(sc == RTEMS_SUCCESSFUL); sc = rtems_timer_delete(timer_id); rtems_test_assert(sc == RTEMS_SUCCESSFUL); /* (C) */ wait(ctx, &ctx->timer_barrier_state); while (true) { /* Wait for deletion */ } }
static void test_timeout_before_all_satisfy(test_context *ctx) { rtems_status_code sc; puts( "Init - Trying to generate timeout before all satisfied " "while blocking on event" ); ctx->hit = false; sc = rtems_timer_fire_after(ctx->timer, 1, timeout_before_satisfied, ctx); rtems_test_assert(sc == RTEMS_SUCCESSFUL); interrupt_critical_section_test( test_body_timeout_before_all_satisfy, ctx, NULL ); sc = rtems_timer_cancel(ctx->timer); rtems_test_assert(sc == RTEMS_SUCCESSFUL); rtems_test_assert(ctx->hit); }
/* ** Timer Signal Handler. ** The purpose of this function is to convert the POSIX signal number to the ** OSAL signal number and pass it to the User defined signal handler. */ rtems_timer_service_routine OS_TimerSignalHandler(rtems_id rtems_timer_id, void *user_data) { rtems_status_code status; uint32 osal_timer_id; rtems_interval timeout; osal_timer_id = ( uint32 )user_data; if ( osal_timer_id < OS_MAX_TIMERS ) { if ( OS_timer_table[osal_timer_id].free == FALSE ) { /* ** Call the user function */ (OS_timer_table[osal_timer_id].callback_ptr)(osal_timer_id); /* ** Only re-arm the timer if the interval time is greater than zero. */ if ( OS_timer_table[osal_timer_id].interval_time > 0 ) { /* ** Reprogram the timer with the interval time */ OS_UsecsToTicks(OS_timer_table[osal_timer_id].interval_time, &timeout); status = rtems_timer_fire_after(OS_timer_table[osal_timer_id].host_timerid, timeout, OS_TimerSignalHandler, (void *)osal_timer_id ); } } } }
static void test_any_satisfy_before_timeout(test_context *ctx) { rtems_status_code sc; puts( "Init - Trying to generate any satisfied before timeout " "while blocking on event" ); ctx->hit = false; ctx->thread->Wait.count = 0; sc = rtems_timer_fire_after(ctx->timer, 1, any_satisfy_before_timeout, ctx); rtems_test_assert(sc == RTEMS_SUCCESSFUL); interrupt_critical_section_test( test_body_any_satisfy_before_timeout, ctx, NULL ); sc = rtems_timer_cancel(ctx->timer); rtems_test_assert(sc == RTEMS_SUCCESSFUL); rtems_test_assert(ctx->hit); }
rtems_timer_service_routine test_release_from_isr( rtems_id timer, void *arg ) { (void) rtems_timer_fire_after( Timer, 10, TimerMethod, NULL ); }
void doit( rtems_timer_service_routine (*TSR)(rtems_id, void *), const char *method ) { rtems_interval start; rtems_interval end; rtems_status_code status; printf( "Init: schedule %s from a TSR\n", method ); TSR_occurred = 0; TSR_status = 0; status = rtems_timer_fire_after( timer_id, 10, TSR, NULL ); rtems_test_assert( !status ); start = rtems_clock_get_ticks_since_boot(); do { end = rtems_clock_get_ticks_since_boot(); } while ( !TSR_occurred && ((end - start) <= 800)); if ( !TSR_occurred ) { printf( "%s did not occur\n", method ); rtems_test_exit(0); } if ( TSR_status != EPROTO ) { printf( "%s returned %s\n", method, strerror(TSR_status) ); rtems_test_exit(0); } printf( "%s - from ISR returns EPROTO - OK\n", method ); }
rtems_task Init( rtems_task_argument ignored ) { rtems_status_code sc = RTEMS_SUCCESSFUL; size_t i = 0; puts("\n\n*** TEST INTERRUPT CRITICAL SECTION 17 ***"); build_time(&tod, 4, 12, 2009, 9, 34, 11, 0); sc = rtems_clock_set(&tod); directive_failed(sc, "rtems_clock_set"); ++tod.year; for (i = 0; i < TIMER_COUNT; ++i) { sc = rtems_timer_create( rtems_build_name('T', 'I', 'M', '0' + i), &timer [i] ); directive_failed(sc, "rtems_timer_create"); } sc = rtems_timer_initiate_server( RTEMS_MINIMUM_PRIORITY, RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_ATTRIBUTES ); directive_failed(sc, "rtems_timer_initiate_server"); sc = rtems_timer_server_fire_after( timer [TIMER_NEVER_INTERVAL], 2, never_callback, NULL ); directive_failed(sc, "rtems_timer_server_fire_after"); reset_tod_timer(); sc = rtems_timer_fire_after( timer [TIMER_RESET], 1, reset_callback, NULL ); directive_failed(sc, "rtems_timer_fire_after"); sc = rtems_timer_server_fire_after( timer [TIMER_TRIGGER], 1, trigger_callback, NULL ); directive_failed(sc, "rtems_timer_server_fire_after"); interrupt_critical_section_test_support_initialize(NULL); rtems_task_delete(RTEMS_SELF); }
rtems_timer_service_routine Tx_ISR( rtems_id ignored_id, void *ignored_address ) { rtems_termios_dequeue_characters (Ttyp, 1); (void) rtems_timer_fire_after( Tx_Timer, 10, Tx_ISR, NULL ); }
static void start_timer(test_context *self) { rtems_status_code sc; sc = rtems_timer_create(rtems_build_name('C', 'L', 'S', 'W'), &self->timer); rtems_test_assert(sc == RTEMS_SUCCESSFUL); sc = rtems_timer_fire_after(self->timer, 2, clobber_and_switch_timer, self); rtems_test_assert(sc == RTEMS_SUCCESSFUL); }
ssize_t termios_test_driver_write_helper( int port, const char *buf, size_t len ) { Tx_Buffer[Tx_Index++] = buf[0]; (void) rtems_timer_fire_after( Tx_Timer, 10, Tx_ISR, NULL ); return 1; }
/****************************************************************************** ** Function: OS_TimerSet ** ** Purpose: ** ** Arguments: ** (none) ** ** Return: ** (none) */ int32 OS_TimerSet(uint32 timer_id, uint32 start_time, uint32 interval_time) { rtems_interval timeout; rtems_status_code status; /* ** Check to see if the timer_id given is valid */ if (timer_id >= OS_MAX_TIMERS || OS_timer_table[timer_id].free == TRUE) { return OS_ERR_INVALID_ID; } /* ** Round up the accuracy of the start time and interval times. ** Still want to preserve zero, since that has a special meaning. */ if (( start_time > 0 ) && (start_time < os_clock_accuracy)) { start_time = os_clock_accuracy; } if ((interval_time > 0) && (interval_time < os_clock_accuracy )) { interval_time = os_clock_accuracy; } /* ** Save the start and interval times */ OS_timer_table[timer_id].start_time = start_time; OS_timer_table[timer_id].interval_time = interval_time; /* ** The defined behavior is to not arm the timer if the start time is zero ** If the interval time is zero, then the timer will not be re-armed. */ if ( start_time > 0 ) { /* ** Convert from Microseconds to the timeout */ OS_UsecsToTicks(start_time, &timeout); status = rtems_timer_fire_after(OS_timer_table[timer_id].host_timerid, timeout, OS_TimerSignalHandler, (void *)timer_id ); if ( status != RTEMS_SUCCESSFUL ) { OS_printf("BSP: Error: Cannot setup interval timer to fire.\n"); return ( OS_TIMER_ERR_INTERNAL); } } return OS_SUCCESS; }
static void startTimer(rtems_id timerID, rtems_interval fireWhen, rtems_timer_service_routine_entry userFunc, void* userArg) { rtems_status_code rc; rc = rtems_timer_fire_after(timerID, fireWhen, userFunc, userArg); if(rc != RTEMS_SUCCESSFUL) { syslog(LOG_INFO, "rtems_timer_fire_after(): %s\n", rtems_status_text(rc)); } }
static void test_no_preempt( void ) { rtems_status_code sc; rtems_id id; rtems_test_assert( test_no_preempt_step == 0 ); sc = rtems_task_delete( Task_id[ 2 ] ); rtems_test_assert( sc == RTEMS_SUCCESSFUL ); sc = rtems_task_delete( Task_id[ 3 ] ); rtems_test_assert( sc == RTEMS_SUCCESSFUL ); sc = rtems_task_create( rtems_build_name( 'H', 'I', 'G', 'H' ), 1, RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &high_task_id ); rtems_test_assert( sc == RTEMS_SUCCESSFUL ); sc = rtems_task_create( rtems_build_name( 'L', 'O', 'W', ' ' ), 2, RTEMS_MINIMUM_STACK_SIZE, RTEMS_NO_PREEMPT, RTEMS_DEFAULT_ATTRIBUTES, &low_task_id ); rtems_test_assert( sc == RTEMS_SUCCESSFUL ); sc = rtems_timer_create( rtems_build_name( 'N', 'O', 'P', 'R' ), &id ); rtems_test_assert( sc == RTEMS_SUCCESSFUL ); sc = rtems_timer_fire_after( id, 1, no_preempt_timer, NULL ); rtems_test_assert( sc == RTEMS_SUCCESSFUL ); sc = rtems_event_transient_receive( RTEMS_WAIT, RTEMS_NO_TIMEOUT ); rtems_test_assert( sc == RTEMS_SUCCESSFUL ); sc = rtems_timer_delete( id ); rtems_test_assert( sc == RTEMS_SUCCESSFUL ); sc = rtems_task_delete( high_task_id ); rtems_test_assert( sc == RTEMS_SUCCESSFUL ); sc = rtems_task_delete( low_task_id ); rtems_test_assert( sc == RTEMS_SUCCESSFUL ); rtems_test_assert( test_no_preempt_step == 3 ); }
rtems_task Init( rtems_task_argument argument ) { rtems_status_code status; rtems_id timer; rtems_interval start; rtems_interval now; puts( "\n\n*** TEST 38 ***" ); main_task = rtems_task_self(); /* * Timer used in multiple ways */ status = rtems_timer_create( 1, &timer ); directive_failed( status, "rtems_timer_create" ); /* * Get starting time */ start = rtems_clock_get_ticks_since_boot(); status = rtems_signal_catch( signal_handler, RTEMS_DEFAULT_MODES ); directive_failed( status, "rtems_signal_catch" ); puts( "rtems_signal_catch - handler installed" ); /* * Test Signal from ISR */ signal_sent = FALSE; status = rtems_timer_fire_after( timer, 10, test_signal_from_isr, NULL ); directive_failed( status, "timer_fire_after failed" ); while (1) { now = rtems_clock_get_ticks_since_boot(); if ( (now-start) > 100 ) { puts( "Signal from ISR did not get processed\n" ); rtems_test_exit( 0 ); } if ( signal_processed ) break; } puts( "Signal sent from ISR has been processed" ); puts( "*** END OF TEST 38 ***" ); rtems_test_exit( 0 ); }
void _POSIX_Timer_TSR(Objects_Id timer, void *data) { POSIX_Timer_Control *ptimer; boolean activated; ptimer = (POSIX_Timer_Control *)data; /* Increment the number of expirations. */ ptimer->overrun = ptimer->overrun + 1; /* The timer must be reprogrammed */ if ( ( ptimer->timer_data.it_interval.tv_sec != 0 ) || ( ptimer->timer_data.it_interval.tv_nsec != 0 ) ) { #if 0 status = rtems_timer_fire_after( ptimer->timer_id, ptimer->ticks, _POSIX_Timer_TSR, ptimer ); #endif activated = _Watchdog_Insert_ticks_helper( &ptimer->Timer, ptimer->ticks, ptimer->Object.id, _POSIX_Timer_TSR, ptimer ); if ( !activated ) return; /* Store the time when the timer was started again */ _TOD_Get( &ptimer->time ); /* The state really did not change but just to be safe */ ptimer->state = POSIX_TIMER_STATE_CREATE_RUN; } else { /* Indicates that the timer is stopped */ ptimer->state = POSIX_TIMER_STATE_CREATE_STOP; } /* * The sending of the signal to the process running the handling function * specified for that signal is simulated */ if ( pthread_kill ( ptimer->thread_id, ptimer->inf.sigev_signo ) ) { /* XXX error handling */ } /* After the signal handler returns, the count of expirations of the * timer must be set to 0. */ ptimer->overrun = 0; }
rtems_timer_service_routine Timer_Routine( rtems_id id, void *ignored ) { rtems_status_code status; if ( id == Timer1 ) led_value = 1; else led_value = 2; led_do_print = 1; status = rtems_timer_fire_after( id, 2 * rtems_clock_get_ticks_per_second(), Timer_Routine, NULL ); }
rtems_timer_service_routine Rx_ISR( rtems_id ignored_id, void *ignored_address ) { uint8_t ch; if ( Rx_Index >= Rx_Length ) return; ch = Rx_Buffer[ Rx_Index++ ]; rtems_termios_enqueue_raw_characters (Ttyp, (char *)&ch, 1); #if defined(TASK_DRIVEN) rtems_termios_rxirq_occured(Ttyp); #endif (void) rtems_timer_fire_after( Rx_Timer, 10, Rx_ISR, NULL ); }
static void start_worker_stop_timer( rtems_test_parallel_context *ctx, rtems_interval duration ) { rtems_status_code sc; _Atomic_Store_ulong(&ctx->stop, 0, ATOMIC_ORDER_RELEASE); sc = rtems_timer_fire_after( ctx->stop_worker_timer_id, duration, stop_worker_timer, ctx ); _Assert(sc == RTEMS_SUCCESSFUL); (void) sc; }
static void test(void) { test_context *ctx; rtems_status_code sc; size_t i; ctx = &test_instance; ctx->master_id = rtems_task_self(); for (i = 0; i < TASK_COUNT; ++i) { sc = rtems_task_create( NAME, P(i), RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &ctx->task_ids[i] ); rtems_test_assert(sc == RTEMS_SUCCESSFUL); sc = rtems_task_start(ctx->task_ids[i], do_nothing_task, 0); rtems_test_assert(sc == RTEMS_SUCCESSFUL); } sc = rtems_timer_create(NAME, &ctx->timer_id); rtems_test_assert(sc == RTEMS_SUCCESSFUL); sc = rtems_timer_fire_after(ctx->timer_id, 1, timer, ctx); rtems_test_assert(sc == RTEMS_SUCCESSFUL); sc = rtems_event_transient_receive(RTEMS_WAIT, RTEMS_NO_TIMEOUT); rtems_test_assert(sc == RTEMS_SUCCESSFUL); for (i = 0; i < TASK_COUNT; ++i) { sc = rtems_task_delete(ctx->task_ids[i]); rtems_test_assert(sc == RTEMS_SUCCESSFUL); } sc = rtems_timer_delete(ctx->timer_id); rtems_test_assert(sc == RTEMS_SUCCESSFUL); }
rtems_task Delayed_events_task( rtems_task_argument argument ) { uint32_t count; uint32_t previous_mode; rtems_status_code status; rtems_event_set events; status = rtems_task_mode( RTEMS_PREEMPT | RTEMS_TIMESLICE, RTEMS_PREEMPT_MASK | RTEMS_TIMESLICE_MASK, &previous_mode ); directive_failed( status, "rtems_task_mode" ); status = rtems_timer_create( Timer_name[ 1 ], &Timer_id[ 1 ] ); directive_failed( status, "rtems_timer_create" ); while ( Stop_Test == FALSE ) { for ( count=DELAYED_EVENT_DOT_COUNT; Stop_Test == FALSE && count; count-- ){ status = rtems_timer_fire_after( Timer_id[ 1 ], 1, Delayed_send_event, NULL ); directive_failed( status, "rtems_timer_reset" ); status = rtems_event_receive( RTEMS_EVENT_16, RTEMS_DEFAULT_OPTIONS, RTEMS_NO_TIMEOUT, &events ); directive_failed( status, "rtems_event_receive" ); } put_dot('.'); } Exit_test(); }
void termios_test_driver_set_rx( const void *p, size_t len ) { Rx_Buffer = p; Rx_Length = len; Rx_Index = 0; if ( Rx_EnqueueNow == false) { (void) rtems_timer_fire_after( Rx_Timer, 10, Rx_ISR, NULL ); return; } do { uint8_t ch; ch = Rx_Buffer[ Rx_Index++ ]; rtems_termios_enqueue_raw_characters (Ttyp, (char *)&ch, 1); } while (Rx_Index < Rx_Length ); }
rtems_task Init( rtems_task_argument argument ) { rtems_status_code status; rtems_id timer; rtems_event_set out; int i; int max; uint32_t iterations = 0; puts( "\n\n*** TEST 39 ***" ); main_task = rtems_task_self(); /* * Timer used in multiple ways */ status = rtems_timer_create( 1, &timer ); directive_failed( status, "rtems_timer_create" ); status = rtems_task_create( 0xa5a5a5a5, 1, RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &other_task ); directive_failed( status, "rtems_task_create" ); /* * Test Event send successful from ISR -- receive is forever */ case_hit = FALSE; iterations = 0; max = 1; while (1) { if ( case_hit ) break; status = rtems_timer_fire_after( timer, 1, test_event_from_isr, NULL ); directive_failed( status, "timer_fire_after failed" ); for (i=0 ; i<max ; i++ ) if ( _Event_Sync_state == THREAD_BLOCKING_OPERATION_SATISFIED ) break; status = rtems_event_receive( 0x01, RTEMS_DEFAULT_OPTIONS, 0, &out ); directive_failed( status, "rtems_event_receive" ); if ( case_hit == TRUE ) break; max += 2; /* with our clock tick, this is about 30 seconds */ if ( ++iterations >= 4L * 1000L * 30L) break; } printf( "Event sent from ISR hitting synchronization point has %soccurred\n", (( case_hit == TRUE ) ? "" : "NOT ") ); /* * Test Event send successful from ISR -- receive has timeout */ case_hit = FALSE; iterations = 0; max = 1; while (1) { if ( case_hit ) break; status = rtems_timer_fire_after( timer, 1, test_event_with_timeout_from_isr, NULL ); directive_failed( status, "timer_fire_after failed" ); for (i=0 ; i<max ; i++ ) if ( _Event_Sync_state == THREAD_BLOCKING_OPERATION_SATISFIED ) break; status = rtems_event_receive( 0x01, RTEMS_DEFAULT_OPTIONS, 10, &out ); directive_failed( status, "rtems_event_receive" ); if ( case_hit == TRUE ) break; max += 2; /* with our clock tick, this is about 30 seconds */ if ( ++iterations >= 4L * 1000L * 30L) break; } printf( "Event sent from ISR (with timeout) hitting synchronization " "point has %soccurred\n", (( case_hit == TRUE ) ? "" : "NOT ") ); puts( "*** END OF TEST 39 ***" ); rtems_test_exit( 0 ); }
static void test_case(enum resource_type rt) { rtems_status_code sc = RTEMS_SUCCESSFUL; printf("test case: %s\n", resource_type_desc [rt]); resource_type = rt; test_reset(); sc = rtems_timer_server_fire_after( timer [OBTAIN], T1 - T0, obtain_callback, NULL ); directive_failed(sc, "rtems_timer_server_fire_after"); sc = rtems_timer_fire_after( timer [INTERRUPT], T2 - T0, interrupt_callback, NULL ); directive_failed(sc, "rtems_timer_fire_after"); sc = rtems_timer_server_fire_after( timer [DELAYED], T3 - T0, delayed_callback, NULL ); directive_failed(sc, "rtems_timer_server_fire_after"); if (resource_type != REGION) { sc = rtems_timer_fire_after( timer [RELEASE], T4 - T0, release_callback, NULL ); directive_failed(sc, "rtems_timer_fire_after"); assert_time(T0); sc = rtems_task_wake_after(T6 - T0); directive_failed(sc, "task_wake_after"); } else { sc = rtems_task_wake_after(T4 - T0); directive_failed(sc, "task_wake_after"); assert_time(T4); rtems_test_assert( obtain_try && interrupt_happened && !delayed_happened && !interrupt_triggered_happened && !server_triggered_happened ); sc = rtems_region_return_segment(region, region_item); directive_failed(sc, "rtems_region_return_segment"); release_happened = true; sc = rtems_task_wake_after(T6 - T4); directive_failed(sc, "task_wake_after"); } assert_time(T6); rtems_test_assert( obtain_done && interrupt_happened && release_happened && delayed_happened && interrupt_triggered_happened && server_triggered_happened ); }
rtems_task Task_1( rtems_task_argument argument ) { rtems_name name RTEMS_GCC_NOWARN_UNUSED; uint32_t index RTEMS_GCC_NOWARN_UNUSED; rtems_id id RTEMS_GCC_NOWARN_UNUSED; rtems_task_priority in_priority RTEMS_GCC_NOWARN_UNUSED; rtems_task_priority out_priority RTEMS_GCC_NOWARN_UNUSED; rtems_mode in_mode RTEMS_GCC_NOWARN_UNUSED; rtems_mode mask RTEMS_GCC_NOWARN_UNUSED; rtems_mode out_mode RTEMS_GCC_NOWARN_UNUSED; rtems_time_of_day time RTEMS_GCC_NOWARN_UNUSED; rtems_interval timeout RTEMS_GCC_NOWARN_UNUSED; rtems_signal_set signals RTEMS_GCC_NOWARN_UNUSED; void *address_1 RTEMS_GCC_NOWARN_UNUSED; rtems_event_set events RTEMS_GCC_NOWARN_UNUSED; long buffer[ 4 ] RTEMS_GCC_NOWARN_UNUSED; uint32_t count RTEMS_GCC_NOWARN_UNUSED; rtems_device_major_number major RTEMS_GCC_NOWARN_UNUSED; rtems_device_minor_number minor RTEMS_GCC_NOWARN_UNUSED; uint32_t io_result RTEMS_GCC_NOWARN_UNUSED; uint32_t error RTEMS_GCC_NOWARN_UNUSED; rtems_clock_get_options options RTEMS_GCC_NOWARN_UNUSED; name = rtems_build_name( 'N', 'A', 'M', 'E' ); in_priority = 250; in_mode = RTEMS_NO_PREEMPT; mask = RTEMS_PREEMPT_MASK; timeout = 100; signals = RTEMS_SIGNAL_1 | RTEMS_SIGNAL_3; major = 10; minor = 0; error = 100; options = 0; /* rtems_shutdown_executive */ benchmark_timer_initialize(); for ( index=1 ; index <= OPERATION_COUNT ; index++ ) (void) rtems_shutdown_executive( error ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_shutdown_executive", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_task_create */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_task_create( name, in_priority, RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &id ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_task_create", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_task_ident */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_task_ident( name, RTEMS_SEARCH_ALL_NODES, id ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_task_ident", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_task_start */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_task_start( id, Task_1, 0 ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_task_start", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_task_restart */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_task_restart( id, 0 ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_task_restart", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_task_delete */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_task_delete( id ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_task_delete", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_task_suspend */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_task_suspend( id ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_task_suspend", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_task_resume */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_task_resume( id ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_task_resume", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_task_set_priority */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_task_set_priority( id, in_priority, &out_priority ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_task_set_priority", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_task_mode */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_task_mode( in_mode, mask, &out_mode ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_task_mode", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_task_wake_when */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_task_wake_when( time ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_task_wake_when", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_task_wake_after */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_task_wake_after( timeout ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_task_wake_after", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_interrupt_catch */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_interrupt_catch( Isr_handler, 5, address_1 ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_interrupt_catch", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_clock_get */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_clock_get( options, time ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_clock_get", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_clock_set */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_clock_set( time ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_clock_set", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_clock_tick */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_clock_tick(); end_time = benchmark_timer_read(); put_time( "overhead: rtems_clock_tick", end_time, OPERATION_COUNT, overhead, 0 ); rtems_test_pause(); /* rtems_timer_create */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_timer_create( name, &id ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_timer_create", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_timer_delete */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_timer_delete( id ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_timer_delete", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_timer_ident */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_timer_ident( name, id ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_timer_ident", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_timer_fire_after */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_timer_fire_after( id, timeout, Timer_handler, NULL ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_timer_fire_after", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_timer_fire_when */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_timer_fire_when( id, time, Timer_handler, NULL ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_timer_fire_when", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_timer_reset */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_timer_reset( id ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_timer_reset", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_timer_cancel */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_timer_cancel( id ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_timer_cancel", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_semaphore_create */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_semaphore_create( name, 128, RTEMS_DEFAULT_ATTRIBUTES, RTEMS_NO_PRIORITY, &id ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_semaphore_create", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_semaphore_delete */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_semaphore_delete( id ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_semaphore_delete", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_semaphore_ident */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_semaphore_ident( name, RTEMS_SEARCH_ALL_NODES, id ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_semaphore_ident", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_semaphore_obtain */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_semaphore_obtain( id, RTEMS_DEFAULT_OPTIONS, timeout ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_semaphore_obtain", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_semaphore_release */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_semaphore_release( id ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_semaphore_release", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_message_queue_create */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_message_queue_create( name, 128, RTEMS_DEFAULT_ATTRIBUTES, &id ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_message_queue_create", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_message_queue_ident */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_message_queue_ident( name, RTEMS_SEARCH_ALL_NODES, id ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_message_queue_ident", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_message_queue_delete */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_message_queue_delete( id ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_message_queue_delete", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_message_queue_send */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_message_queue_send( id, (long (*)[4])buffer ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_message_queue_send", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_message_queue_urgent */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_message_queue_urgent( id, (long (*)[4])buffer ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_message_queue_urgent", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_message_queue_broadcast */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_message_queue_broadcast( id, (long (*)[4])buffer, &count ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_message_queue_broadcast", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_message_queue_receive */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_message_queue_receive( id, (long (*)[4])buffer, RTEMS_DEFAULT_OPTIONS, timeout ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_message_queue_receive", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_message_queue_flush */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_message_queue_flush( id, &count ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_message_queue_flush", end_time, OPERATION_COUNT, overhead, 0 ); rtems_test_pause(); /* rtems_event_send */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_event_send( id, events ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_event_send", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_event_receive */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_event_receive( RTEMS_EVENT_16, RTEMS_DEFAULT_OPTIONS, timeout, &events ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_event_receive", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_signal_catch */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_signal_catch( Asr_handler, RTEMS_DEFAULT_MODES ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_signal_catch", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_signal_send */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_signal_send( id, signals ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_signal_send", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_partition_create */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_partition_create( name, Memory_area, 2048, 128, RTEMS_DEFAULT_ATTRIBUTES, &id ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_partition_create", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_partition_ident */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_partition_ident( name, RTEMS_SEARCH_ALL_NODES, id ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_partition_ident", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_partition_delete */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_partition_delete( id ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_partition_delete", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_partition_get_buffer */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_partition_get_buffer( id, address_1 ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_partition_get_buffer", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_partition_return_buffer */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_partition_return_buffer( id, address_1 ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_partition_return_buffer", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_region_create */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_region_create( name, Memory_area, 2048, 128, RTEMS_DEFAULT_ATTRIBUTES, &id ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_region_create", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_region_ident */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_region_ident( name, id ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_region_ident", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_region_delete */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_region_delete( id ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_region_delete", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_region_get_segment */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_region_get_segment( id, 243, RTEMS_DEFAULT_OPTIONS, timeout, &address_1 ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_region_get_segment", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_region_return_segment */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_region_return_segment( id, address_1 ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_region_return_segment", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_port_create */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_port_create( name, Internal_port_area, External_port_area, 0xff, &id ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_port_create", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_port_ident */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_port_ident( name, id ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_port_ident", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_port_delete */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_port_delete( id ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_port_delete", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_port_external_to_internal */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_port_external_to_internal( id, &External_port_area[ 7 ], address_1 ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_port_external_to_internal", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_port_internal_to_external */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_port_internal_to_external( id, &Internal_port_area[ 7 ], address_1 ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_port_internal_to_external", end_time, OPERATION_COUNT, overhead, 0 ); rtems_test_pause(); /* rtems_io_initialize */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_io_initialize( major, minor, address_1, &io_result ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_io_initialize", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_io_open */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_io_open( major, minor, address_1, &io_result ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_io_open", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_io_close */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_io_close( major, minor, address_1, &io_result ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_io_close", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_io_read */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_io_read( major, minor, address_1, &io_result ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_io_read", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_io_write */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_io_write( major, minor, address_1, &io_result ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_io_write", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_io_control */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_io_control( major, minor, address_1, &io_result ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_io_control", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_fatal_error_occurred */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_fatal_error_occurred( error ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_fatal_error_occurred", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_rate_monotonic_create */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_rate_monotonic_create( name, &id ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_rate_monotonic_create", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_rate_monotonic_ident */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_rate_monotonic_ident( name, id ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_rate_monotonic_ident", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_rate_monotonic_delete */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_rate_monotonic_delete( id ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_rate_monotonic_delete", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_rate_monotonic_cancel */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_rate_monotonic_cancel( id ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_rate_monotonic_cancel", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_rate_monotonic_period */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_rate_monotonic_period( id, timeout ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_rate_monotonic_period", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_multiprocessing_announce */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_multiprocessing_announce(); end_time = benchmark_timer_read(); put_time( "overhead: rtems_multiprocessing_announce", end_time, OPERATION_COUNT, overhead, 0 ); TEST_END(); rtems_test_exit( 0 ); }
void CFE_PSP_Main( int ModeId, char *StartupFilePath ) { uint32 reset_type; uint32 reset_subtype; rtems_status_code RtemsStatus; rtems_name RtemsTimerName; /* ** Initialize the OS API */ OS_API_Init(); /* ** Create an interval timer for the 1hz */ RtemsTimerName = rtems_build_name('1',' ','H','Z'); RtemsStatus = rtems_timer_create(RtemsTimerName, &RtemsTimerId); if ( RtemsStatus != RTEMS_SUCCESSFUL ) { printf("CFE_PSP: Error: Cannot create RTEMS 1hz interval timer\n"); } /* ** Allocate memory for the cFE memory. Note that this is malloced on ** the COTS board, but will be a static location in the ETU. */ printf("Sizeof BSP reserved memory = %d bytes\n",sizeof(CFE_PSP_ReservedMemory_t)); CFE_PSP_ReservedMemoryPtr = malloc(sizeof(CFE_PSP_ReservedMemory_t)); if ( CFE_PSP_ReservedMemoryPtr == NULL ) { printf("CFE_PSP: Error: Cannot malloc BSP reserved memory!\n"); } else { printf("CFE_PSP: Allocated %d bytes for PSP reserved memory at: 0x%08X\n", sizeof(CFE_PSP_ReservedMemory_t), (int)CFE_PSP_ReservedMemoryPtr); } /* ** Determine Reset type by reading the hardware reset register. */ reset_type = CFE_ES_POWERON_RESET; reset_subtype = CFE_ES_POWER_CYCLE; /* ** Initialize the reserved memory */ CFE_PSP_InitProcessorReservedMemory(reset_type); /* ** Call cFE entry point. This will return when cFE startup ** is complete. */ CFE_ES_Main(reset_type,reset_subtype, 1, (uint8 *)StartupFilePath); /* ** Setup the timer to fire at 1hz */ /* CLOCK TICK */ RtemsStatus = rtems_timer_fire_after(RtemsTimerId, 100, CFE_PSP_1hzTimer, NULL ); if ( RtemsStatus != RTEMS_SUCCESSFUL ) { printf("CFE_PSP: Error: Cannot setup interval timer to fire at 1hz\n"); } /* ** Return to the shell/monitor */ return; }
rtems_task Init( rtems_task_argument argument ) { int cpu_num; rtems_id id; rtems_status_code status; rtems_interval per_second; rtems_interval then; rtems_id Timer; locked_print_initialize(); rtems_test_begin_with_plugin(locked_printf_plugin, NULL); if ( rtems_get_processor_count() == 1 ) { success(); } /* Create/verify semaphore */ status = rtems_semaphore_create( rtems_build_name ('S', 'E', 'M', '1'), 1, RTEMS_LOCAL | RTEMS_SIMPLE_BINARY_SEMAPHORE | RTEMS_PRIORITY, 1, &Semaphore ); directive_failed( status, "rtems_semaphore_create" ); /* Lock semaphore */ status = rtems_semaphore_obtain( Semaphore, RTEMS_WAIT, 0); directive_failed( status,"rtems_semaphore_obtain of SEM1\n"); /* Create and Start test task. */ status = rtems_task_create( rtems_build_name( 'T', 'A', '1', ' ' ), 1, RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &id ); directive_failed( status, "task create" ); cpu_num = rtems_get_current_processor(); locked_printf(" CPU %d start task TA1\n", cpu_num ); status = rtems_task_start( id, Test_task, 1 ); directive_failed( status, "task start" ); /* Create and start TSR */ locked_printf(" CPU %d create and start timer\n", cpu_num ); status = rtems_timer_create( rtems_build_name( 'T', 'M', 'R', '1' ), &Timer); directive_failed( status, "rtems_timer_create" ); per_second = rtems_clock_get_ticks_per_second(); status = rtems_timer_fire_after( Timer, 2 * per_second, TimerMethod, NULL ); directive_failed( status, "rtems_timer_fire_after"); /* * Wait long enough that TSR should have fired. * * Spin so CPU 0 is consumed. This forces task to run on CPU 1. */ then = rtems_clock_get_ticks_since_boot() + 4 * per_second; while (1) { if ( rtems_clock_get_ticks_since_boot() > then ) break; if ( TSRFired && TaskRan ) break; }; /* Validate the timer fired and that the task ran */ if ( !TSRFired ) locked_printf( "*** ERROR TSR DID NOT FIRE ***" ); if ( !TaskRan ) { locked_printf( "*** ERROR TASK DID NOT RUN ***" ); rtems_test_exit(0); } /* End the program */ success(); }
rtems_task Init( rtems_task_argument argument ) { rtems_status_code status; rtems_task_priority previous_priority; printf( "\n\n*** TEST 14 -- NODE %" PRId32 " ***\n", Multiprocessing_configuration.node ); Stop_Test = false; status = rtems_timer_create( rtems_build_name('S', 'T', 'O', 'P'), &timer_id ); directive_failed( status, "rtems_timer_create" ); status = rtems_timer_fire_after( timer_id, MAX_LONG_TEST_DURATION * rtems_clock_get_ticks_per_second(), Stop_Test_TSR, NULL ); directive_failed( status, "rtems_timer_fire_after" ); Task_name[ 1 ] = rtems_build_name( '1', '1', '1', ' ' ); Task_name[ 2 ] = rtems_build_name( '2', '2', '2', ' ' ); Queue_task_name[ 1 ] = rtems_build_name( 'M', 'T', '1', ' ' ); Queue_task_name[ 2 ] = rtems_build_name( 'M', 'T', '2', ' ' ); Partition_task_name[ 1 ] = rtems_build_name( 'P', 'T', '1', ' ' ); Partition_task_name[ 2 ] = rtems_build_name( 'P', 'T', '2', ' ' ); Semaphore_task_name[ 1 ] = rtems_build_name( 'S', 'M', '1', ' ' ); Semaphore_task_name[ 2 ] = rtems_build_name( 'S', 'M', '2', ' ' ); Semaphore_name[ 1 ] = rtems_build_name( 'S', 'E', 'M', ' ' ); Queue_name[ 1 ] = rtems_build_name( 'M', 'S', 'G', ' ' ); Partition_name[ 1 ] = rtems_build_name( 'P', 'A', 'R', ' ' ); Timer_name[ 1 ] = rtems_build_name( 'T', 'M', 'R', ' ' ); if ( Multiprocessing_configuration.node == 1 ) { puts( "Creating Semaphore (Global)" ); status = rtems_semaphore_create( Semaphore_name[ 1 ], 1, RTEMS_GLOBAL, RTEMS_NO_PRIORITY, &Semaphore_id[ 1 ] ); directive_failed( status, "rtems_semaphore_create" ); puts( "Creating Message Queue (Global)" ); status = rtems_message_queue_create( Queue_name[ 1 ], 1, 16, RTEMS_GLOBAL, &Queue_id[ 1 ] ); directive_failed( status, "rtems_message_queue_create" ); puts( "Creating Partition (Global)" ); status = rtems_partition_create( Partition_name[ 1 ], (void *)my_partition, 0x8000, 0x3800, RTEMS_GLOBAL, &Partition_id[ 1 ] ); directive_failed( status, "rtems_partition_create" ); } puts( "Creating Event task (Global)" ); status = rtems_task_create( Task_name[ Multiprocessing_configuration.node ], 2, RTEMS_MINIMUM_STACK_SIZE, RTEMS_TIMESLICE, RTEMS_GLOBAL, &Event_task_id[ 1 ] ); directive_failed( status, "rtems_task_create" ); puts( "Starting Event task (Global)" ); status = rtems_task_start( Event_task_id[ 1 ], Test_task, 0 ); directive_failed( status, "rtems_task_start" ); puts( "Creating Semaphore task (Global)" ); status = rtems_task_create( Semaphore_task_name[ Multiprocessing_configuration.node ], 2, RTEMS_MINIMUM_STACK_SIZE, RTEMS_TIMESLICE, RTEMS_GLOBAL, &Semaphore_task_id[ 1 ] ); directive_failed( status, "rtems_task_create" ); puts( "Starting Semaphore task (Global)" ); status = rtems_task_start( Semaphore_task_id[ 1 ], Semaphore_task, 0 ); directive_failed( status, "rtems_task_start" ); puts( "Creating Message Queue task (Global)" ); status = rtems_task_create( Queue_task_name[ Multiprocessing_configuration.node ], 2, RTEMS_MINIMUM_STACK_SIZE, RTEMS_TIMESLICE, RTEMS_GLOBAL, &Queue_task_id[ 1 ] ); directive_failed( status, "rtems_task_create" ); /* argument is index into Buffers */ puts( "Starting Message Queue task (Global)" ); status = rtems_task_start( Queue_task_id[ 1 ], Message_queue_task, 1 ); directive_failed( status, "rtems_task_start" ); puts( "Creating Partition task (Global)" ); status = rtems_task_create( Partition_task_name[ Multiprocessing_configuration.node ], 2, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_TIMESLICE, RTEMS_GLOBAL, &Partition_task_id[ 1 ] ); directive_failed( status, "rtems_task_create" ); puts( "Starting Partition task (Global)" ); status = rtems_task_start( Partition_task_id[ 1 ], Partition_task, 0 ); directive_failed( status, "rtems_task_start" ); status = rtems_task_set_priority( RTEMS_SELF, 2, &previous_priority ); directive_failed( status, "rtems_task_set_priority" ); status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &Task_id[ 1 ] ); directive_failed( status, "rtems_task_ident" ); Delayed_events_task( 1 ); }