/****************************************************************************** ** Function: OS_TimerDelete ** ** Purpose: ** ** Arguments: ** (none) ** ** Return: ** (none) */ int32 OS_TimerDelete(uint32 timer_id) { 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; } OS_timer_table[timer_id].free = TRUE; /* ** Cancel the timer */ status = rtems_timer_cancel(OS_timer_table[timer_id].host_timerid); if ( status != RTEMS_SUCCESSFUL ) { return ( OS_TIMER_ERR_INTERNAL); } /* ** Delete the timer */ status = rtems_timer_delete(OS_timer_table[timer_id].host_timerid); if ( status != RTEMS_SUCCESSFUL ) { return ( OS_TIMER_ERR_INTERNAL); } return OS_SUCCESS; }
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 destroyTimer(rtems_id timerID) { rtems_status_code rc; rc = rtems_timer_delete(timerID); if(rc != RTEMS_SUCCESSFUL) { syslog(LOG_INFO, "rtems_timer_delete(): %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 ); }
static void test( test_context *self, bool task_0_fpu, bool task_1_fpu, bool task_2_fpu ) { rtems_status_code sc; uintptr_t pattern_0 = (uintptr_t) 0xaaaaaaaaaaaaaaaaU; uintptr_t pattern_1 = (uintptr_t) 0x5555555555555555U; uintptr_t pattern_2 = (uintptr_t) 0x0000000000000000U; memset(self, 0, sizeof(*self)); self->control_task = rtems_task_self(); start_validate_task( &self->validate_tasks[0], pattern_0, PRIORITY_HIGH, task_0_fpu ); start_validate_task( &self->validate_tasks[1], pattern_1, PRIORITY_LOW, task_1_fpu ); start_validate_task( &self->validate_tasks[2], pattern_2, PRIORITY_LOW, task_2_fpu ); start_timer(self); wait_for_finish(); sc = rtems_task_delete(self->validate_tasks[0]); rtems_test_assert(sc == RTEMS_SUCCESSFUL); sc = rtems_task_delete(self->validate_tasks[1]); rtems_test_assert(sc == RTEMS_SUCCESSFUL); sc = rtems_task_delete(self->validate_tasks[2]); rtems_test_assert(sc == RTEMS_SUCCESSFUL); sc = rtems_timer_delete(self->timer); rtems_test_assert(sc == RTEMS_SUCCESSFUL); }
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 Task_1( rtems_task_argument argument ) { rtems_id tmid; rtems_id tmid2; rtems_time_of_day time; rtems_status_code status; rtems_timer_information info; /* Get id */ puts( "TA1 - rtems_timer_ident - identing timer 1" ); status = rtems_timer_ident( Timer_name[ 1 ], &tmid ); directive_failed( status, "rtems_timer_ident" ); printf( "TA1 - timer 1 has id (0x%" PRIxrtems_id ")\n", tmid ); puts( "TA1 - rtems_timer_ident - identing timer 2" ); status = rtems_timer_ident( Timer_name[ 2 ], &tmid2 ); directive_failed( status, "rtems_timer_ident" ); printf( "TA1 - timer 2 has id (0x%" PRIxrtems_id ")\n", tmid2 ); /* make sure insertion does not unintentionally fire a timer per PR147 */ TSR_fired = 0; puts( "TA1 - rtems_timer_server_fire_after - 1 second" ); status = rtems_timer_server_fire_after( tmid, rtems_clock_get_ticks_per_second(), Should_not_fire_TSR, NULL ); directive_failed( status, "rtems_timer_server_fire_after" ); puts( "TA1 - rtems_task_wake_after - 1/2 second" ); status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() / 2 ); directive_failed( status, "rtems_timer_server_fire_after" ); directive_failed( status, "rtems_timer_server_fire_after" ); puts( "TA1 - rtems_timer_server_fire_after - timer 2 in 1/2 second" ); status = rtems_timer_server_fire_after( tmid2, rtems_clock_get_ticks_per_second() / 2, Should_not_fire_TSR, NULL ); directive_failed( status, "rtems_timer_server_fire_after" ); if ( TSR_fired ) { puts( "TA1 - TSR fired and should not have!" ); rtems_test_exit(1); } puts( "TA1 - rtems_timer_cancel - timer 1" ); status = rtems_timer_cancel( tmid ); directive_failed( status, "rtems_timer_cancel" ); puts( "TA1 - rtems_timer_cancel - timer 2" ); status = rtems_timer_cancel( tmid2 ); directive_failed( status, "rtems_timer_cancel" ); /* now check that rescheduling an active timer works OK. */ puts( "TA1 - rtems_timer_server_fire_after - timer 1 in 30 seconds" ); status = rtems_timer_server_fire_after( tmid, 30 * rtems_clock_get_ticks_per_second(), Delayed_resume, NULL ); directive_failed( status, "rtems_timer_server_fire_after" ); puts( "TA1 - rtems_timer_server_fire_after - timer 2 in 60 seconds" ); status = rtems_timer_server_fire_after( tmid2, 60 * rtems_clock_get_ticks_per_second(), Delayed_resume, NULL ); directive_failed( status, "rtems_timer_server_fire_after" ); status = rtems_timer_get_information( tmid, &info ); printf( "Timer 1 scheduled for %" PRIdWatchdog_Interval " ticks since boot\n", info.start_time + info.initial ); printf( "Timer Server scheduled for %" PRIdWatchdog_Interval " ticks since boot\n", schedule_time() ); puts( "TA1 - rtems_task_wake_after - 1 second" ); status = rtems_task_wake_after( 1 * rtems_clock_get_ticks_per_second() ); directive_failed( status, "rtems_timer_wake_after" ); puts( "TA1 - rtems_timer_server_fire_after - timer 2 in 60 seconds" ); status = rtems_timer_server_fire_after( tmid2, 60 * rtems_clock_get_ticks_per_second(), Delayed_resume, NULL ); directive_failed( status, "rtems_timer_server_fire_after" ); status = rtems_timer_get_information( tmid, &info ); directive_failed( status, "rtems_timer_get_information" ); printf( "Timer 1 scheduled for %" PRIdWatchdog_Interval " ticks since boot\n", info.start_time + info.initial ); printf( "Timer Server scheduled for %" PRIdWatchdog_Interval " ticks since boot\n", schedule_time() ); rtems_test_assert( (info.start_time + info.initial) == schedule_time() ); puts( "TA1 - rtems_task_wake_after - 1 second" ); status = rtems_task_wake_after( 1 * rtems_clock_get_ticks_per_second() ); directive_failed( status, "rtems_timer_wake_after" ); puts( "TA1 - rtems_timer_server_fire_after - timer 2 in 60 seconds" ); status = rtems_timer_server_fire_after( tmid2, 60 * rtems_clock_get_ticks_per_second(), Delayed_resume, NULL ); directive_failed( status, "rtems_timer_server_fire_after" ); status = rtems_timer_get_information( tmid, &info ); directive_failed( status, "rtems_timer_get_information" ); printf( "Timer 1 scheduled for %" PRIdWatchdog_Interval " ticks since boot\n", info.start_time + info.initial ); printf( "Timer Server scheduled for %" PRIdWatchdog_Interval " ticks since boot\n", schedule_time() ); rtems_test_assert( (info.start_time + info.initial) == schedule_time() ); puts( "TA1 - rtems_timer_cancel - timer 1" ); status = rtems_timer_cancel( tmid ); directive_failed( status, "rtems_timer_cancel" ); puts( "TA1 - rtems_timer_cancel - timer 2" ); status = rtems_timer_cancel( tmid2 ); directive_failed( status, "rtems_timer_cancel" ); /* after which is allowed to fire */ Print_time(); puts( "TA1 - rtems_timer_server_fire_after - timer 1 in 3 seconds" ); status = rtems_timer_server_fire_after( tmid, 3 * rtems_clock_get_ticks_per_second(), Delayed_resume, NULL ); directive_failed( status, "rtems_timer_server_fire_after" ); puts( "TA1 - rtems_task_suspend( RTEMS_SELF )" ); status = rtems_task_suspend( RTEMS_SELF ); directive_failed( status, "rtems_task_suspend" ); Print_time(); /* after which is reset and allowed to fire */ puts( "TA1 - rtems_timer_server_fire_after - timer 1 in 3 seconds" ); status = rtems_timer_server_fire_after( tmid, 3 * rtems_clock_get_ticks_per_second(), Delayed_resume, NULL ); directive_failed( status, "rtems_timer_server_fire_after" ); puts( "TA1 - rtems_task_wake_after - 1 second" ); status = rtems_task_wake_after( 1 * rtems_clock_get_ticks_per_second() ); directive_failed( status, "rtems_task_wake_after" ); Print_time(); puts( "TA1 - rtems_timer_reset - timer 1" ); status = rtems_timer_reset( tmid ); directive_failed( status, "rtems_timer_reset" ); puts( "TA1 - rtems_task_suspend( RTEMS_SELF )" ); status = rtems_task_suspend( RTEMS_SELF ); directive_failed( status, "rtems_task_suspend" ); Print_time(); rtems_test_pause(); /* * Reset the time since we do not know how long the user waited * before pressing <cr> at the pause. This insures that the * actual output matches the screen. */ build_time( &time, 12, 31, 1988, 9, 0, 7, 0 ); status = rtems_clock_set( &time ); directive_failed( status, "rtems_clock_set" ); /* after which is canceled */ puts( "TA1 - rtems_timer_server_fire_after - timer 1 in 3 seconds" ); status = rtems_timer_server_fire_after( tmid, 3 * rtems_clock_get_ticks_per_second(), Delayed_resume, NULL ); directive_failed( status, "rtems_timer_server_fire_after" ); puts( "TA1 - rtems_timer_cancel - timer 1" ); status = rtems_timer_cancel( tmid ); directive_failed( status, "rtems_timer_cancel" ); /* when which is allowed to fire */ Print_time(); status = rtems_clock_get_tod( &time ); directive_failed( status, "rtems_clock_get_tod" ); time.second += 3; puts( "TA1 - rtems_timer_server_fire_when - timer 1 in 3 seconds" ); status = rtems_timer_server_fire_when( tmid, &time, Delayed_resume, NULL ); directive_failed( status, "rtems_timer_server_fire_when" ); puts( "TA1 - rtems_task_suspend( RTEMS_SELF )" ); status = rtems_task_suspend( RTEMS_SELF ); directive_failed( status, "rtems_task_suspend" ); Print_time(); /* when which is canceled */ status = rtems_clock_get_tod( &time ); directive_failed( status, "rtems_clock_get_tod" ); time.second += 3; puts( "TA1 - rtems_timer_server_fire_when - timer 1 in 3 seconds" ); status = rtems_timer_server_fire_when( tmid, &time, Delayed_resume, NULL ); directive_failed( status, "rtems_timer_server_fire_when" ); puts( "TA1 - rtems_task_wake_after - 1 second" ); status = rtems_task_wake_after( 1 * rtems_clock_get_ticks_per_second() ); directive_failed( status, "rtems_task_wake_after" ); Print_time(); puts( "TA1 - rtems_timer_cancel - timer 1" ); status = rtems_timer_cancel( tmid ); directive_failed( status, "rtems_timer_cancel" ); /* TOD timer insert with non empty TOD timer chain */ status = rtems_clock_get_tod( &time ); directive_failed( status, "rtems_clock_get_tod" ); time.second += 3; puts( "TA1 - rtems_timer_server_fire_when - timer 1 in 3 seconds" ); status = rtems_timer_server_fire_when( tmid, &time, Do_nothing, NULL ); directive_failed( status, "rtems_timer_server_fire_when" ); puts( "TA1 - rtems_timer_server_fire_when - timer 2 in 3 seconds" ); status = rtems_timer_server_fire_when( tmid2, &time, Do_nothing, NULL ); directive_failed( status, "rtems_timer_server_fire_when" ); puts( "TA1 - rtems_task_wake_after - 1 second" ); status = rtems_task_wake_after( 1 * rtems_clock_get_ticks_per_second() ); directive_failed( status, "rtems_task_wake_after" ); puts( "TA1 - rtems_timer_server_fire_when - timer 2 in 3 seconds" ); status = rtems_timer_server_fire_when( tmid2, &time, Do_nothing, NULL ); directive_failed( status, "rtems_timer_server_fire_when" ); puts( "TA1 - rtems_timer_cancel - timer 1" ); status = rtems_timer_cancel( tmid ); directive_failed( status, "rtems_timer_cancel" ); puts( "TA1 - rtems_timer_cancel - timer 2" ); status = rtems_timer_cancel( tmid2 ); directive_failed( status, "rtems_timer_cancel" ); /* TOD chain processing with time wrap */ time.second = 30; status = rtems_clock_set( &time ); directive_failed( status, "rtems_clock_set" ); time.second = 31; puts( "TA1 - rtems_timer_server_fire_when - timer 1 in 1 seconds" ); status = rtems_timer_server_fire_when( tmid, &time, Do_nothing, NULL ); directive_failed( status, "rtems_timer_server_fire_when" ); time.second = 29; status = rtems_clock_set( &time ); directive_failed( status, "rtems_clock_set" ); puts( "TA1 - rtems_timer_server_fire_after - timer 2 in 1 tick" ); status = rtems_timer_server_fire_after( tmid2, 1, Do_nothing, NULL ); directive_failed( status, "rtems_timer_server_fire_after" ); puts( "TA1 - rtems_task_wake_after - 1 tick" ); status = rtems_task_wake_after( 1 ); directive_failed( status, "rtems_task_wake_after" ); puts( "TA1 - rtems_timer_cancel - timer 1" ); status = rtems_timer_cancel( tmid ); directive_failed( status, "rtems_timer_cancel" ); /* delete */ puts( "TA1 - rtems_task_wake_after - YIELD (only task at priority)" ); status = rtems_task_wake_after( RTEMS_YIELD_PROCESSOR ); directive_failed( status, "rtems_task_wake_after" ); puts( "TA1 - timer_deleting - timer 1" ); status = rtems_timer_delete( tmid ); directive_failed( status, "rtems_timer_delete" ); puts( "*** END OF TEST 31 *** " ); rtems_test_exit( 0 ); }
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 ); }
rtems_task Task_1( rtems_task_argument argument ) { rtems_id tmid; rtems_status_code status; /* Get id */ puts( "TA1 - rtems_timer_ident - identing timer 1" ); status = rtems_timer_ident( Timer_name[ 1 ], &tmid ); directive_failed( status, "rtems_timer_ident" ); printf( "TA1 - timer 1 has id (0x%" PRIxrtems_id ")\n", tmid ); /* after which is allowed to fire */ Print_time(); puts( "TA1 - rtems_timer_fire_after - timer 1 in 3 seconds" ); status = rtems_timer_fire_after( tmid, 3 * rtems_clock_get_ticks_per_second(), Delayed_resume, NULL ); directive_failed( status, "rtems_timer_fire_after" ); puts( "TA1 - rtems_task_suspend( RTEMS_SELF )" ); status = rtems_task_suspend( RTEMS_SELF ); directive_failed( status, "rtems_task_suspend" ); Print_time(); /* after which is reset and allowed to fire */ puts( "TA1 - rtems_timer_fire_after - timer 1 in 3 seconds" ); status = rtems_timer_fire_after( tmid, 3 * rtems_clock_get_ticks_per_second(), Delayed_resume, NULL ); directive_failed( status, "rtems_timer_fire_after" ); puts( "TA1 - rtems_task_wake_after - 1 second" ); status = rtems_task_wake_after( 1 * rtems_clock_get_ticks_per_second() ); directive_failed( status, "rtems_task_wake_after" ); Print_time(); puts( "TA1 - rtems_timer_reset - timer 1" ); status = rtems_timer_reset( tmid ); directive_failed( status, "rtems_timer_reset" ); puts( "TA1 - _Watchdog_Report_chain - with name" ); _Watchdog_Report_chain( "_Watchdog_Ticks_chain", & _Watchdog_Ticks_chain ); puts( "TA1 - _Watchdog_Report_chain - no name" ); _Watchdog_Report_chain( NULL, & _Watchdog_Ticks_chain); puts( "TA1 - _Watchdog_Report - with name" ); _Watchdog_Report("first", (Watchdog_Control *)(_Watchdog_Ticks_chain.first)); puts( "TA1 - _Watchdog_Report - no name" ); _Watchdog_Report( NULL, (Watchdog_Control *)(_Watchdog_Ticks_chain.first) ); puts( "TA1 - timer_deleting - timer 1" ); status = rtems_timer_delete( tmid ); directive_failed( status, "rtems_timer_delete" ); puts( "*** END OF RTEMS WATCHDOG PROGRAM ***" ); rtems_test_exit( 0 ); }
void Screen14() { rtems_status_code status; rtems_time_of_day time; rtems_timer_information timer_info; bool skipUnsatisfied; /* NULL Id */ status = rtems_timer_create( Timer_name[ 1 ], NULL ); fatal_directive_status( status, RTEMS_INVALID_ADDRESS, "rtems_timer_create NULL param" ); puts( "TA1 - rtems_timer_create - RTEMS_INVALID_ADDRESS" ); /* bad name */ status = rtems_timer_create( 0, &Junk_id ); fatal_directive_status( status, RTEMS_INVALID_NAME, "rtems_timer_create with illegal name" ); puts( "TA1 - rtems_timer_create - RTEMS_INVALID_NAME" ); /* OK */ status = rtems_timer_create( Timer_name[ 1 ], &Timer_id[ 1 ] ); directive_failed( status, "rtems_timer_create" ); puts( "TA1 - rtems_timer_create - 1 - RTEMS_SUCCESSFUL" ); status = rtems_timer_create( 2, &Junk_id ); fatal_directive_status( status, RTEMS_TOO_MANY, "rtems_timer_create for too many" ); puts( "TA1 - rtems_timer_create - 2 - RTEMS_TOO_MANY" ); status = rtems_timer_delete( 100 ); fatal_directive_status( status, RTEMS_INVALID_ID, "rtems_timer_delete with illegal id" ); puts( "TA1 - rtems_timer_delete - local RTEMS_INVALID_ID" ); status = rtems_timer_delete( rtems_build_id( 1, 1, 1, 256 ) ); fatal_directive_status( status, RTEMS_INVALID_ID, "rtems_timer_delete with illegal id" ); puts( "TA1 - rtems_timer_delete - global RTEMS_INVALID_ID" ); status = rtems_timer_ident( 0, &Junk_id ); fatal_directive_status( status, RTEMS_INVALID_NAME, "rtems_timer_ident with illegal name" ); puts( "TA1 - rtems_timer_ident - RTEMS_INVALID_NAME" ); status = rtems_timer_cancel( rtems_build_id( 1, 1, 1, 256 ) ); fatal_directive_status( status, RTEMS_INVALID_ID, "rtems_timer_cancel with illegal id" ); puts( "TA1 - rtems_timer_cancel - RTEMS_INVALID_ID" ); status = rtems_timer_reset( rtems_build_id( 1, 1, 1, 256 ) ); fatal_directive_status( status, RTEMS_INVALID_ID, "rtems_timer_reset with illegal id" ); puts( "TA1 - rtems_timer_reset - RTEMS_INVALID_ID" ); status = rtems_timer_reset( Timer_id[ 1 ] ); fatal_directive_status( status, RTEMS_NOT_DEFINED, "rtems_timer_reset before initiated" ); puts( "TA1 - rtems_timer_reset - RTEMS_NOT_DEFINED" ); /* bad id */ status = rtems_timer_fire_after( rtems_build_id( 1, 1, 1, 256 ), 5 * rtems_clock_get_ticks_per_second(), Delayed_routine, NULL ); fatal_directive_status( status, RTEMS_INVALID_ID, "rtems_timer_fire_after illegal id" ); puts( "TA1 - rtems_timer_fire_after - RTEMS_INVALID_ID" ); /* bad id */ build_time( &time, 12, 31, 1994, 9, 0, 0, 0 ); status = rtems_timer_fire_when( rtems_build_id( 1, 1, 1, 256 ), &time, Delayed_routine, NULL ); fatal_directive_status( status, RTEMS_INVALID_ID, "rtems_timer_fire_when with illegal id" ); puts( "TA1 - rtems_timer_fire_when - RTEMS_INVALID_ID" ); /* NULL routine */ status = rtems_timer_fire_after( Timer_id[ 1 ], 1, NULL, NULL ); fatal_directive_status( status, RTEMS_INVALID_ADDRESS, "rtems_timer_fire_after with NULL handler" ); puts( "TA1 - rtems_timer_fire_after - RTEMS_INVALID_ADDRESS" ); /* 0 ticks */ status = rtems_timer_fire_after( Timer_id[ 1 ], 0, Delayed_routine, NULL ); fatal_directive_status( status, RTEMS_INVALID_NUMBER, "rtems_timer_fire_after with 0 ticks" ); puts( "TA1 - rtems_timer_fire_after - RTEMS_INVALID_NUMBER" ); /* NULL routine */ status = rtems_timer_fire_when( Timer_id[ 1 ], &time, NULL, NULL ); fatal_directive_status( status, RTEMS_INVALID_ADDRESS, "rtems_timer_fire_when with NULL handler" ); puts( "TA1 - rtems_timer_fire_when - RTEMS_INVALID_ADDRESS" ); /* invalid time -- before RTEMS epoch */ build_time( &time, 2, 5, 1987, 8, 30, 45, 0 ); status = rtems_timer_fire_when( Timer_id[ 1 ], &time, Delayed_routine, NULL ); fatal_directive_status( status, RTEMS_INVALID_CLOCK, "rtems_timer_fire_when with illegal time" ); print_time( "TA1 - rtems_timer_fire_when - ", &time, " - RTEMS_INVALID_CLOCK\n" ); status = rtems_clock_get_tod( &time ); directive_failed( status, "rtems_clock_get_tod" ); print_time( "TA1 - rtems_clock_get_tod - ", &time, "\n" ); build_time( &time, 2, 5, 1990, 8, 30, 45, 0 ); status = rtems_timer_fire_when( Timer_id[ 1 ], &time, Delayed_routine, NULL ); fatal_directive_status( status, RTEMS_INVALID_CLOCK, "rtems_timer_fire_when before current time" ); print_time( "TA1 - rtems_timer_fire_when - ", &time, " - before RTEMS_INVALID_CLOCK\n" ); /* null param */ status = rtems_timer_get_information( Timer_id[ 1 ], NULL ); fatal_directive_status( status, RTEMS_INVALID_ADDRESS, "rtems_timer_get_information with NULL param" ); puts( "TA1 - rtems_timer_get_information - RTEMS_INVALID_ADDRESS" ); /* invalid id */ status = rtems_timer_get_information( 100, &timer_info ); fatal_directive_status( status, RTEMS_INVALID_ID, "rtems_timer_get_information with illegal id" ); puts( "TA1 - rtems_timer_get_information - RTEMS_INVALID_ID" ); /* timer server interface routines */ /* incorrect state */ status = rtems_timer_server_fire_after( 0, 5, NULL, NULL ); fatal_directive_status( status, RTEMS_INCORRECT_STATE, "rtems_timer_server_fire_after incorrect state" ); puts( "TA1 - rtems_timer_server_fire_after - RTEMS_INCORRECT_STATE" ); /* incorrect state */ status = rtems_timer_server_fire_when( 0, &time, NULL, NULL ); fatal_directive_status( status, RTEMS_INCORRECT_STATE, "rtems_timer_server_fire_when incorrect state" ); puts( "TA1 - rtems_timer_server_fire_when - RTEMS_INCORRECT_STATE" ); /* invalid priority */ status = rtems_timer_initiate_server( 0, 0, 0 ); fatal_directive_status( status, RTEMS_INVALID_PRIORITY, "rtems_timer_initiate_server invalid priority" ); puts( "TA1 - rtems_timer_initiate_server - RTEMS_INVALID_PRIORITY" ); skipUnsatisfied = false; #if defined(__m32c__) skipUnsatisfied = true; #endif if (skipUnsatisfied) { puts( "TA1 - rtems_timer_initiate_server - RTEMS_UNSATISFIED -- SKIPPED" ); } else { status = rtems_timer_initiate_server( RTEMS_TIMER_SERVER_DEFAULT_PRIORITY, 0x10000000, 0 ); fatal_directive_status( status, RTEMS_UNSATISFIED, "rtems_timer_initiate_server too much stack " ); puts( "TA1 - rtems_timer_initiate_server - RTEMS_UNSATISFIED" ); } status = rtems_timer_initiate_server( RTEMS_TIMER_SERVER_DEFAULT_PRIORITY, 0, 0 ); directive_failed( status, "rtems_timer_initiate_server" ); puts( "TA1 - rtems_timer_initiate_server - SUCCESSFUL" ); /* NULL routine */ status = rtems_timer_server_fire_after( Timer_id[ 1 ], 1, NULL, NULL ); fatal_directive_status( status, RTEMS_INVALID_ADDRESS, "rtems_timer_server_fire_after NULL routine" ); puts( "TA1 - rtems_timer_server_fire_after - RTEMS_INVALID_ADDRESS" ); /* bad Id */ status = rtems_timer_server_fire_after( rtems_build_id( 1, 1, 1, 256 ), 5 * rtems_clock_get_ticks_per_second(), Delayed_routine, NULL ); fatal_directive_status( status, RTEMS_INVALID_ID, "rtems_timer_server_fire_after illegal id" ); puts( "TA1 - rtems_timer_server_fire_after - RTEMS_INVALID_ID" ); /* bad id */ build_time( &time, 12, 31, 1994, 9, 0, 0, 0 ); status = rtems_timer_server_fire_when( rtems_build_id( 1, 1, 1, 256 ), &time, Delayed_routine, NULL ); fatal_directive_status( status, RTEMS_INVALID_ID, "rtems_timer_server_fire_when with illegal id" ); puts( "TA1 - rtems_timer_server_fire_when - RTEMS_INVALID_ID" ); /* NULL routine */ status = rtems_timer_server_fire_after( Timer_id[ 1 ], 1, NULL, NULL ); fatal_directive_status( status, RTEMS_INVALID_ADDRESS, "rtems_timer_server_fire_after NULL routine" ); puts( "TA1 - rtems_timer_server_fire_after - RTEMS_INVALID_ADDRESS" ); /* 0 ticks */ status = rtems_timer_server_fire_after( Timer_id[ 1 ], 0, Delayed_routine, NULL ); fatal_directive_status( status, RTEMS_INVALID_NUMBER, "rtems_timer_server_fire_after with 0 ticks" ); puts( "TA1 - rtems_timer_server_fire_after - RTEMS_INVALID_NUMBER" ); /* illegal time */ build_time( &time, 2, 5, 1987, 8, 30, 45, 0 ); status = rtems_timer_server_fire_when( Timer_id[ 1 ], &time, Delayed_routine, NULL ); fatal_directive_status( status, RTEMS_INVALID_CLOCK, "rtems_timer_server_fire_when with illegal time" ); print_time( "TA1 - rtems_timer_server_fire_when - ", &time, " - RTEMS_INVALID_CLOCK\n" ); status = rtems_clock_get_tod( &time ); directive_failed( status, "rtems_clock_get_tod" ); print_time( "TA1 - rtems_clock_get_tod - ", &time, "\n" ); /* when NULL routine */ status = rtems_timer_server_fire_when( Timer_id[ 1 ], &time, NULL, NULL ); fatal_directive_status( status, RTEMS_INVALID_ADDRESS, "rtems_timer_server_fire_when NULL routine" ); puts( "TA1 - rtems_timer_server_fire_when - RTEMS_INVALID_ADDRESS" ); /* before current time */ build_time( &time, 2, 5, 1990, 8, 30, 45, 0 ); status = rtems_timer_server_fire_when( Timer_id[ 1 ], &time, Delayed_routine, NULL ); fatal_directive_status( status, RTEMS_INVALID_CLOCK, "rtems_timer_server_fire_when before current time" ); print_time( "TA1 - rtems_timer_server_fire_when - ", &time, " - before RTEMS_INVALID_CLOCK\n" ); }
void rtems_test_parallel( rtems_test_parallel_context *ctx, rtems_test_parallel_worker_setup worker_setup, const rtems_test_parallel_job *jobs, size_t job_count ) { rtems_status_code sc; size_t worker_index; rtems_task_priority worker_priority; _Atomic_Init_ulong(&ctx->stop, 0); _SMP_barrier_Control_initialize(&ctx->barrier); ctx->worker_count = rtems_get_processor_count(); ctx->worker_ids[0] = rtems_task_self(); if (RTEMS_ARRAY_SIZE(ctx->worker_ids) < ctx->worker_count) { rtems_fatal_error_occurred(0xdeadbeef); } sc = rtems_task_set_priority( RTEMS_SELF, RTEMS_CURRENT_PRIORITY, &worker_priority ); if (sc != RTEMS_SUCCESSFUL) { rtems_fatal_error_occurred(0xdeadbeef); } sc = rtems_timer_create( rtems_build_name('S', 'T', 'O', 'P'), &ctx->stop_worker_timer_id ); if (sc != RTEMS_SUCCESSFUL) { rtems_fatal_error_occurred(0xdeadbeef); } for (worker_index = 1; worker_index < ctx->worker_count; ++worker_index) { worker_arg warg = { .ctx = ctx, .jobs = jobs, .job_count = job_count, .worker_index = worker_index }; rtems_id worker_id; sc = rtems_task_create( rtems_build_name( 'W', digit(worker_index, 100), digit(worker_index, 10), digit(worker_index, 1) ), worker_priority, RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &worker_id ); if (sc != RTEMS_SUCCESSFUL) { rtems_fatal_error_occurred(0xdeadbeef); } ctx->worker_ids[worker_index] = worker_id; if (worker_setup != NULL) { (*worker_setup)(ctx, worker_index, worker_id); } sc = rtems_task_start(worker_id, worker_task, (rtems_task_argument) &warg); _Assert(sc == RTEMS_SUCCESSFUL); sc = rtems_event_transient_receive(RTEMS_WAIT, RTEMS_NO_TIMEOUT); _Assert(sc == RTEMS_SUCCESSFUL); } run_tests(ctx, jobs, job_count, 0); for (worker_index = 1; worker_index < ctx->worker_count; ++worker_index) { sc = rtems_task_delete(ctx->worker_ids[worker_index]); _Assert(sc == RTEMS_SUCCESSFUL); } sc = rtems_timer_delete(ctx->stop_worker_timer_id); _Assert(sc == RTEMS_SUCCESSFUL); }
rtems_task High_task( rtems_task_argument argument ) { uint32_t index; rtems_status_code status; int i; benchmark_timer_initialize(); for ( index=1 ; index <= OPERATION_COUNT ; index++ ) (void) benchmark_timer_empty_function(); overhead = benchmark_timer_read(); benchmark_timer_initialize(); for ( index=1 ; index <= OPERATION_COUNT ; index++ ) (void) rtems_timer_create( index, &Timer_id[ index ] ); end_time = benchmark_timer_read(); put_time( "rtems_timer_create: only case", end_time, OPERATION_COUNT, overhead, CALLING_OVERHEAD_TIMER_CREATE ); benchmark_timer_initialize(); for ( index=1 ; index <= OPERATION_COUNT ; index++ ) (void) rtems_timer_fire_after( Timer_id[ index ], 500, null_delay, NULL ); end_time = benchmark_timer_read(); put_time( "rtems_timer_fire_after: inactive", end_time, OPERATION_COUNT, overhead, CALLING_OVERHEAD_TIMER_FIRE_AFTER ); benchmark_timer_initialize(); for ( index=1 ; index <= OPERATION_COUNT ; index++ ) (void) rtems_timer_fire_after( Timer_id[ index ], 500, null_delay, NULL ); end_time = benchmark_timer_read(); put_time( "rtems_timer_fire_after: active", end_time, OPERATION_COUNT, overhead, CALLING_OVERHEAD_TIMER_FIRE_AFTER ); benchmark_timer_initialize(); for ( index=1 ; index <= OPERATION_COUNT ; index++ ) (void) rtems_timer_cancel( Timer_id[ index ] ); end_time = benchmark_timer_read(); put_time( "rtems_timer_cancel: active", end_time, OPERATION_COUNT, overhead, CALLING_OVERHEAD_TIMER_CANCEL ); for ( benchmark_timer_initialize(), i=0 ; i<OPERATION_COUNT ; i++ ) benchmark_timer_initialize(); for ( index=1 ; index <= OPERATION_COUNT ; index++ ) (void) rtems_timer_cancel( Timer_id[ index ] ); end_time = benchmark_timer_read(); put_time( "rtems_timer_cancel: inactive", end_time, OPERATION_COUNT, overhead, CALLING_OVERHEAD_TIMER_CANCEL ); for ( benchmark_timer_initialize(), i=0 ; i<OPERATION_COUNT ; i++ ) benchmark_timer_initialize(); for ( index=1 ; index <= OPERATION_COUNT ; index++ ) (void) rtems_timer_reset( Timer_id[ index ] ); end_time = benchmark_timer_read(); put_time( "rtems_timer_reset: inactive", end_time, OPERATION_COUNT, overhead, CALLING_OVERHEAD_TIMER_RESET ); benchmark_timer_initialize(); for ( index=1 ; index <= OPERATION_COUNT ; index++ ) (void) rtems_timer_reset( Timer_id[ index ] ); end_time = benchmark_timer_read(); put_time( "rtems_timer_reset: active", end_time, OPERATION_COUNT, overhead, CALLING_OVERHEAD_TIMER_RESET ); for ( index=1 ; index <= OPERATION_COUNT ; index++ ) (void) rtems_timer_reset( Timer_id[ index ] ); build_time( &time_of_day, 12, 31, 1988, 9, 0, 0, 0 ); status = rtems_clock_set( &time_of_day ); directive_failed( status, "rtems_clock_set" ); time_of_day.year = 1989; benchmark_timer_initialize(); for ( index=1 ; index <= OPERATION_COUNT ; index++ ) (void) rtems_timer_fire_when( Timer_id[ index ], &time_of_day, null_delay, NULL ); end_time = benchmark_timer_read(); put_time( "rtems_timer_fire_when: inactive", end_time, OPERATION_COUNT, overhead, CALLING_OVERHEAD_TIMER_FIRE_WHEN ); benchmark_timer_initialize(); for ( index=1 ; index <= OPERATION_COUNT ; index++ ) (void) rtems_timer_fire_when( Timer_id[ index ], &time_of_day, null_delay, NULL ); end_time = benchmark_timer_read(); put_time( "rtems_timer_fire_when: active", end_time, OPERATION_COUNT, overhead, CALLING_OVERHEAD_TIMER_FIRE_WHEN ); benchmark_timer_initialize(); for ( index=1 ; index <= OPERATION_COUNT ; index++ ) (void) rtems_timer_delete( Timer_id[ index ] ); end_time = benchmark_timer_read(); put_time( "rtems_timer_delete: active", end_time, OPERATION_COUNT, overhead, CALLING_OVERHEAD_TIMER_DELETE ); benchmark_timer_initialize(); for ( index=1 ; index <= OPERATION_COUNT ; index++ ) { status = rtems_timer_create( index, &Timer_id[ index ] ); directive_failed( status, "rtems_timer_create" ); status = rtems_timer_fire_after( Timer_id[ index ], 500, null_delay, NULL ); directive_failed( status, "rtems_timer_fire_after" ); status = rtems_timer_cancel( Timer_id[ index ] ); directive_failed( status, "rtems_timer_cancel" ); } benchmark_timer_initialize(); for ( index=1 ; index <= OPERATION_COUNT ; index++ ) (void) rtems_timer_delete( Timer_id[ index ] ); end_time = benchmark_timer_read(); put_time( "rtems_timer_delete: inactive", end_time, OPERATION_COUNT, overhead, CALLING_OVERHEAD_TIMER_DELETE ); benchmark_timer_initialize(); (void) rtems_task_wake_when( &time_of_day ); }