void ObChunkServerMain::print_version() { fprintf(stderr, "chunkserver (%s %s)\n", PACKAGE_STRING, RELEASEID); fprintf(stderr, "SVN_VERSION: %s\n", svn_version()); fprintf(stderr, "BUILD_TIME: %s %s\n\n", build_date(), build_time()); fprintf(stderr, "Copyright (c) 2007-2011 Taobao Inc.\n"); }
rtems_task Init( rtems_task_argument argument ) { rtems_time_of_day time; rtems_status_code status; puts( "\n\n*** TEST STACK CHECKER ***" ); build_time( &time, 12, 31, 1988, 9, 0, 0, 0 ); status = rtems_clock_set( &time ); directive_failed( status, "rtems_clock_set" ); Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' ); Task_name[ 2 ] = rtems_build_name( 'T', 'A', '2', ' ' ); Task_name[ 3 ] = rtems_build_name( 'T', 'A', '3', ' ' ); status = rtems_task_create( Task_name[ 1 ], 1, TASK_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] ); directive_failed( status, "rtems_task_create of TA1" ); status = rtems_task_create( Task_name[ 2 ], 1, TASK_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 2 ] ); directive_failed( status, "rtems_task_create of TA2" ); status = rtems_task_create( Task_name[ 3 ], 1, TASK_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 3 ] ); directive_failed( status, "rtems_task_create of TA3" ); status = rtems_task_start( Task_id[ 1 ], Task_1_through_3, 0 ); directive_failed( status, "rtems_task_start of TA1" ); status = rtems_task_start( Task_id[ 2 ], Task_1_through_3, 0 ); directive_failed( status, "rtems_task_start of TA2" ); status = rtems_task_start( Task_id[ 3 ], Task_1_through_3, 0 ); directive_failed( status, "rtems_task_start of TA3" ); status = rtems_task_delete( RTEMS_SELF ); directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); }
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); }
int so_main() { printf(INTRODUCTION); printf("SVN Revision: %s\n", svn_version()); printf("SO Build Time: %s %s\n", build_date(), build_time()); printf("GCC Version: %s\n", __VERSION__); printf("\n"); exit(0); }
rtems_task Init( rtems_task_argument argument ) { rtems_time_of_day time; uint32_t index; rtems_status_code status; puts( "\n\n*** TEST 30 ***" ); build_time( &time, 12, 31, 1988, 9, 0, 0, 0 ); status = rtems_clock_set( &time ); directive_failed( status, "rtems_clock_set" ); status = rtems_timer_initiate_server( RTEMS_TIMER_SERVER_DEFAULT_PRIORITY, RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_ATTRIBUTES ); directive_failed( status, "rtems_timer_initiate_server" ); Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' ); Task_name[ 2 ] = rtems_build_name( 'T', 'A', '2', ' ' ); Task_name[ 3 ] = rtems_build_name( 'T', 'A', '3', ' ' ); Timer_name[ 1 ] = rtems_build_name( 'T', 'M', '1', ' ' ); Timer_name[ 2 ] = rtems_build_name( 'T', 'M', '2', ' ' ); Timer_name[ 3 ] = rtems_build_name( 'T', 'M', '3', ' ' ); for ( index = 1 ; index <= 3 ; index++ ) { status = rtems_task_create( Task_name[ index ], 1, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ index ] ); directive_failed( status, "rtems_task_create loop" ); status = rtems_timer_create( Timer_name[ index ], &Timer_id[ index ] ); directive_failed( status, "rtems_timer_create loop" ); } for ( index = 1 ; index <= 3 ; index++ ) { status = rtems_task_start( Task_id[ index ], Task_1_through_3, index ); directive_failed( status, "rtems_task_start loop" ); } status = rtems_task_delete( RTEMS_SELF ); directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); }
void ObUpdateServerMain::print_version() { fprintf(stderr, "updateserver (%s %s)\n", PACKAGE_STRING, RELEASEID); fprintf(stderr, "SVN_VERSION: %s\n", svn_version()); fprintf(stderr, "BUILD_TIME: %s %s\n", build_date(), build_time()); fprintf(stderr, "BUILD_FLAGS: %s\n\n", build_flags()); #ifdef _BTREE_ENGINE_ fprintf(stderr, "Using Btree Key-Value Engine.\n"); #else fprintf(stderr, "Using Hash Key-Value Engine.\n"); #endif fprintf(stderr, "Copyright (c) 2007-2011 Taobao Inc.\n"); }
rtems_task Init( rtems_task_argument argument ) { rtems_time_of_day time; rtems_status_code status; puts( "\n\n*** TEST 31 ***" ); build_time( &time, 12, 31, 1988, 9, 0, 0, 0 ); status = rtems_clock_set( &time ); directive_failed( status, "rtems_clock_set" ); status = rtems_timer_initiate_server( RTEMS_TIMER_SERVER_DEFAULT_PRIORITY, RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_ATTRIBUTES ); directive_failed( status, "rtems_timer_initiate_server" ); Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' ); Timer_name[ 1 ] = rtems_build_name( 'T', 'M', '1', ' ' ); Timer_name[ 2 ] = rtems_build_name( 'T', 'M', '2', ' ' ); status = rtems_task_create( Task_name[ 1 ], 1, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] ); directive_failed( status, "rtems_task_create of TA1" ); status = rtems_task_start( Task_id[ 1 ], Task_1, 0 ); directive_failed( status, "rtems_task_start of TA1" ); puts( "INIT - rtems_timer_create - creating timer 1" ); status = rtems_timer_create( Timer_name[ 1 ], &Timer_id[ 1 ] ); directive_failed( status, "rtems_timer_create" ); printf( "INIT - timer 1 has id (0x%" PRIxrtems_id ")\n", Timer_id[ 1 ] ); puts( "INIT - rtems_timer_create - creating timer 2" ); status = rtems_timer_create( Timer_name[ 2 ], &Timer_id[ 2 ] ); directive_failed( status, "rtems_timer_create" ); printf( "INIT - timer 2 has id (0x%" PRIxrtems_id ")\n", Timer_id[ 2 ] ); status = rtems_task_delete( RTEMS_SELF ); directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); }
rtems_task Init( rtems_task_argument argument ) { rtems_time_of_day time; rtems_status_code status; Chain_Control empty; puts( "\n*** RTEMS WATCHDOG ***" ); puts( "INIT - report on empty watchdog chain" ); _Chain_Initialize_empty( &empty ); _Watchdog_Report_chain( "Empty Chain", &empty ); build_time( &time, 12, 31, 1988, 9, 0, 0, 0 ); status = rtems_clock_set( &time ); directive_failed( status, "rtems_clock_set" ); Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' ); Timer_name[ 1 ] = rtems_build_name( 'T', 'M', '1', ' ' ); status = rtems_task_create( Task_name[ 1 ], 1, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] ); directive_failed( status, "rtems_task_create of TA1" ); status = rtems_task_start( Task_id[ 1 ], Task_1, 0 ); directive_failed( status, "rtems_task_start of TA1" ); puts( "INIT - rtems_timer_create - creating timer 1" ); status = rtems_timer_create( Timer_name[ 1 ], &Timer_id[ 1 ] ); directive_failed( status, "rtems_timer_create" ); printf( "INIT - timer 1 has id (0x%" PRIxrtems_id ")\n", Timer_id[ 1 ] ); status = rtems_task_delete( RTEMS_SELF ); directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); rtems_test_exit( 0 ); }
rtems_task Init( rtems_task_argument argument ) { rtems_time_of_day time; rtems_status_code status; TEST_BEGIN(); test_watchdog_static_init(); build_time( &time, 12, 31, 1988, 9, 0, 0, 0 ); status = rtems_clock_set( &time ); directive_failed( status, "rtems_clock_set" ); Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' ); Timer_name[ 1 ] = rtems_build_name( 'T', 'M', '1', ' ' ); status = rtems_task_create( Task_name[ 1 ], 1, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] ); directive_failed( status, "rtems_task_create of TA1" ); status = rtems_task_start( Task_id[ 1 ], Task_1, 0 ); directive_failed( status, "rtems_task_start of TA1" ); puts( "INIT - rtems_timer_create - creating timer 1" ); status = rtems_timer_create( Timer_name[ 1 ], &Timer_id[ 1 ] ); directive_failed( status, "rtems_timer_create" ); printf( "INIT - timer 1 has id (0x%" PRIxrtems_id ")\n", Timer_id[ 1 ] ); status = rtems_task_delete( RTEMS_SELF ); directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); rtems_test_exit( 0 ); }
rtems_task First_FP_task( rtems_task_argument argument ) { rtems_status_code status; rtems_id tid; rtems_time_of_day time; uint32_t task_index; INTEGER_DECLARE; FP_DECLARE; status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid ); directive_failed( status, "rtems_task_ident" ); task_index = task_number( tid ); INTEGER_LOAD( INTEGER_factors[ task_index ] ); FP_LOAD( FP_factors[ task_index ] ); put_name( Task_name[ task_index ], FALSE ); printf( " - integer base = (0x%" PRIx32 ")\n", INTEGER_factors[ task_index ] ); put_name( Task_name[ task_index ], FALSE ); #if ( RTEMS_HAS_HARDWARE_FP == 1 ) printf( " - float base = (%g)\n", FP_factors[ task_index ] ); #else printf( " - float base = (NA)\n" ); #endif if ( argument == 0 ) { status = rtems_task_restart( RTEMS_SELF, 1 ); directive_failed( status, "rtems_task_restart of RTEMS_SELF" ); } else { build_time( &time, 12, 31, 1988, 9, 0, 0, 0 ); status = rtems_clock_set( &time ); directive_failed( status, "rtems_clock_set" ); status = rtems_task_delete( RTEMS_SELF ); directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); } }
rtems_task Task_1( rtems_task_argument argument ) { rtems_status_code status; rtems_time_of_day time; rtems_name name; status = rtems_object_get_classic_name( rtems_task_self(), &name ); directive_failed( status, "rtems_object_get_classic_name" ); build_time( &time, 12, 31, 1988, 9, 15, 0, 0 ); status = rtems_clock_set( &time ); directive_failed( status, "rtems_clock_set" ); put_name( name, FALSE ); print_time( " sets clock: ", &time, "\n" ); while( FOREVER ) { status = rtems_clock_get_tod( &time ); directive_failed( status, "rtems_clock_get_tod" ); put_name( name, FALSE ); print_time( " going to sleep: ", &time, "\n" ); time.second += 5; time.minute += ( time.second / 60 ); time.second %= 60; time.hour += ( time.minute / 60 ); time.minute %= 60; time.hour %= 24; status = rtems_task_wake_when( &time ); directive_failed( status, "rtems_task_wake_when" ); put_name( name, FALSE ); print_time( " awakened: ", &time, "\n" ); } }
rtems_task Init( rtems_task_argument argument ) { rtems_time_of_day time; rtems_status_code status; puts( "\n\n*** TIMEZONE TEST ***" ); build_time( &time, 3, 14, 2007, 15, 9, 26, 5 ); status = rtems_clock_set( &time ); directive_failed( status, "rtems_clock_set" ); setenv( "TZ", "CST6CDT,M 3.2.0,M 11.1.0", 1 ); tzset(); tztester(); puts( "*** END OF TIMEZONE TEST ***" ); exit(0); }
rtems_task Init( rtems_task_argument argument ) { puts( "\n\n*** TEST SPCLOCK_ERR02 ***" ); rtems_time_of_day time; rtems_status_code status; status = rtems_io_close( 0xffff, 0x0000, NULL); fatal_directive_status( status, RTEMS_INVALID_NUMBER, "rtems_io_close with bad major number" ); puts( "TA1 - rtems_io_close - RTEMS_INVALID_NUMBER" ); status = rtems_io_control( 0xffff, 0x00000, NULL); fatal_directive_status( status, RTEMS_INVALID_NUMBER, "rtems_io_close with bad major number" ); puts( "TA1 - rtems_io_control - RTEMS_INVALID_NUMBER" ); status = rtems_io_initialize( 0xffff, 0x00000, NULL); fatal_directive_status( status, RTEMS_INVALID_NUMBER, "rtems_io_initialize with bad major number" ); puts( "TA1 - rtems_io_initialize - RTEMS_INVALID_NUMBER" ); status = rtems_io_open( 0xffff, 0x00000, NULL); fatal_directive_status( status, RTEMS_INVALID_NUMBER, "rtems_io_open with bad major number" ); puts( "TA1 - rtems_io_open - RTEMS_INVALID_NUMBER" ); status = rtems_io_read( 0xffff, 0x00000, NULL); fatal_directive_status( status, RTEMS_INVALID_NUMBER, "rtems_io_read with bad major number" ); puts( "TA1 - rtems_io_read - RTEMS_INVALID_NUMBER" ); status = rtems_io_write( 0xffff, 0x0ffff, NULL); fatal_directive_status( status, RTEMS_INVALID_NUMBER, "rtems_io_write with bad major number" ); puts( "TA1 - rtems_io_write - RTEMS_INVALID_NUMBER" ); build_time( &time, 12, 31, 2000, 23, 59, 59, 0 ); status = rtems_clock_set( &time ); directive_failed( status, "rtems_clock_set" ); print_time( "TA1 - rtems_clock_set - ", &time, " - RTEMS_SUCCESSFUL\n" ); status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() ); status = rtems_clock_get_tod( &time ); directive_failed( status, "rtems_clock_set" ); print_time( "TA1 - rtems_clock_get_tod - ", &time, " - RTEMS_SUCCESSFUL\n" ); build_time( &time, 12, 31, 1999, 23, 59, 59, 0 ); status = rtems_clock_set( &time ); directive_failed( status, "rtems_clock_set" ); print_time( "TA1 - rtems_clock_set - ", &time, " - RTEMS_SUCCESSFUL\n" ); status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() ); status = rtems_clock_get_tod( &time ); directive_failed( status, "rtems_clock_get_tod" ); print_time( "TA1 - rtems_clock_get_tod - ", &time, " - RTEMS_SUCCESSFUL\n" ); build_time( &time, 12, 31, 2100, 23, 59, 59, 0 ); status = rtems_clock_set( &time ); directive_failed( status, "rtems_clock_set" ); print_time( "TA1 - rtems_clock_set - ", &time, " - RTEMS_SUCCESSFUL\n" ); status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() ); status = rtems_clock_get_tod( &time ); directive_failed( status, "rtems_clock_set" ); print_time( "TA1 - rtems_clock_get_tod - ", &time, " - RTEMS_SUCCESSFUL\n" ); build_time( &time, 12, 31, 2099, 23, 59, 59, 0 ); status = rtems_clock_set( &time ); directive_failed( status, "rtems_clock_set" ); print_time( "TA1 - rtems_clock_set - ", &time, " - RTEMS_SUCCESSFUL\n" ); status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() ); status = rtems_clock_get_tod( &time ); directive_failed( status, "rtems_clock_set" ); print_time( "TA1 - rtems_clock_get_tod - ", &time, " - RTEMS_SUCCESSFUL\n" ); build_time( &time, 12, 31, 1991, 23, 59, 59, 0 ); status = rtems_clock_set( &time ); directive_failed( status, "rtems_clock_set" ); print_time( "TA1 - rtems_clock_set - ", &time, " - RTEMS_SUCCESSFUL\n" ); status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() ); status = rtems_clock_get_tod( &time ); directive_failed( status, "rtems_clock_set" ); print_time( "TA1 - rtems_clock_get_tod - ", &time, " - RTEMS_SUCCESSFUL\n" ); puts( "*** END OF TEST SPCLOCK_ERR02 ***" ); }
rtems_task Init( rtems_task_argument argument ) { rtems_status_code status; rtems_time_of_day time; char c; printf( "\n\n*** TEST 1 -- NODE %" PRIu32 " ***\n", Multiprocessing_configuration.node ); if ( Multiprocessing_configuration.node != 1 ) c = 'S'; else c = 'M'; Task_name[ 1 ] = rtems_build_name( c, 'A', '1', ' ' ); Task_name[ 2 ] = rtems_build_name( c, 'A', '2', ' ' ); Task_name[ 3 ] = rtems_build_name( c, 'A', '3', ' ' ); build_time( &time, 12, 31, 1988, 9, 0, 0, 0 ); status = rtems_clock_set( &time ); directive_failed( status, "rtems_clock_set" ); puts( "Creating task 1 (Global)" ); status = rtems_task_create( Task_name[ 1 ], 1, RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_GLOBAL, &Task_id[ 1 ] ); directive_failed( status, "rtems_task_create of Task 1" ); puts( "Creating task 2 (Global)" ); status = rtems_task_create( Task_name[ 2 ], 1, RTEMS_MINIMUM_STACK_SIZE, RTEMS_TIMESLICE, RTEMS_GLOBAL, &Task_id[ 2 ] ); directive_failed( status, "rtems_task_create of Task 2" ); puts( "Creating task 3 (Local)" ); status = rtems_task_create( Task_name[ 3 ], 1, RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 3 ] ); directive_failed( status, "rtems_task_create of Task 3" ); status = rtems_task_start( Task_id[ 1 ], Test_task, 0 ); directive_failed( status, "rtems_task_start of Task 1" ); status = rtems_task_start( Task_id[ 2 ], Test_task, 0 ); directive_failed( status, "rtems_task_start of Task 2" ); status = rtems_task_start( Task_id[ 3 ], Test_task, 0 ); directive_failed( status, "rtems_task_start of Task 3" ); status = rtems_task_delete( RTEMS_SELF ); directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); }
rtems_task test_task( rtems_task_argument argument ) { rtems_status_code status; uint32_t index; rtems_task_priority old_priority; rtems_time_of_day time; uint32_t old_note; uint32_t old_mode; 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_task_set_priority( Test_task_id, RTEMS_CURRENT_PRIORITY, &old_priority ); end_time = benchmark_timer_read(); put_time( "rtems_task_set_priority: obtain current priority", end_time, OPERATION_COUNT, overhead, CALLING_OVERHEAD_TASK_SET_PRIORITY ); benchmark_timer_initialize(); for ( index=1 ; index <= OPERATION_COUNT ; index++ ) (void) rtems_task_set_priority( Test_task_id, RTEMS_MAXIMUM_PRIORITY - 2u, &old_priority ); end_time = benchmark_timer_read(); put_time( "rtems_task_set_priority: returns to caller", end_time, OPERATION_COUNT, overhead, CALLING_OVERHEAD_TASK_SET_PRIORITY ); benchmark_timer_initialize(); for ( index=1 ; index <= OPERATION_COUNT ; index++ ) (void) rtems_task_mode( RTEMS_CURRENT_MODE, RTEMS_CURRENT_MODE, &old_mode ); end_time = benchmark_timer_read(); put_time( "rtems_task_mode: obtain current mode", end_time, OPERATION_COUNT, overhead, CALLING_OVERHEAD_TASK_MODE ); benchmark_timer_initialize(); for ( index=1 ; index <= OPERATION_COUNT ; index++ ) { (void) rtems_task_mode( RTEMS_INTERRUPT_LEVEL(1), RTEMS_INTERRUPT_MASK, &old_mode ); (void) rtems_task_mode( RTEMS_INTERRUPT_LEVEL(0), RTEMS_INTERRUPT_MASK, &old_mode ); } end_time = benchmark_timer_read(); put_time( "rtems_task_mode: no reschedule", end_time, OPERATION_COUNT * 2, overhead, CALLING_OVERHEAD_TASK_MODE ); benchmark_timer_initialize(); /* must be one host */ (void) rtems_task_mode( RTEMS_NO_ASR, RTEMS_ASR_MASK, &old_mode ); end_time = benchmark_timer_read(); put_time( "rtems_task_mode: reschedule -- returns to caller", end_time, 1, 0, CALLING_OVERHEAD_TASK_MODE ); status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &old_mode ); directive_failed( status, "rtems_task_mode" ); status = rtems_task_set_priority( Test_task_id, 1, &old_priority ); directive_failed( status, "rtems_task_set_priority" ); /* preempted by test_task1 */ benchmark_timer_initialize(); (void) rtems_task_mode( RTEMS_PREEMPT, RTEMS_PREEMPT_MASK, &old_mode ); benchmark_timer_initialize(); for ( index=1 ; index <= OPERATION_COUNT ; index++ ) (void) rtems_task_set_note( Test_task_id, 8, 10 ); end_time = benchmark_timer_read(); put_time( "rtems_task_set_note", end_time, OPERATION_COUNT, overhead, CALLING_OVERHEAD_TASK_SET_NOTE ); benchmark_timer_initialize(); for ( index=1 ; index <= OPERATION_COUNT ; index++ ) (void) rtems_task_get_note( Test_task_id, 8, &old_note ); end_time = benchmark_timer_read(); put_time( "rtems_task_get_note", end_time, OPERATION_COUNT, overhead, CALLING_OVERHEAD_TASK_GET_NOTE ); build_time( &time, 1, 1, 1988, 0, 0, 0, 0 ); benchmark_timer_initialize(); for ( index=1 ; index <= OPERATION_COUNT ; index++ ) (void) rtems_clock_set( &time ); end_time = benchmark_timer_read(); put_time( "rtems_clock_set", end_time, OPERATION_COUNT, overhead, CALLING_OVERHEAD_CLOCK_SET ); benchmark_timer_initialize(); for ( index=1 ; index <= OPERATION_COUNT ; index++ ) (void) rtems_clock_get_tod( &time ); end_time = benchmark_timer_read(); put_time( "rtems_clock_get_tod", end_time, OPERATION_COUNT, overhead, CALLING_OVERHEAD_CLOCK_GET ); puts( "*** END OF TEST 8 ***" ); rtems_test_exit( 0 ); }
void Screen4() { rtems_event_set event_out; rtems_time_of_day time; struct timeval tv; time_t seconds; rtems_status_code status; status = rtems_event_receive( RTEMS_EVENT_16, RTEMS_NO_WAIT, RTEMS_NO_TIMEOUT, NULL ); fatal_directive_status( status, RTEMS_INVALID_ADDRESS, "rtems_event_receive NULL param" ); puts( "TA1 - rtems_event_receive - NULL param - RTEMS_INVALID_ADDRESS" ); status = rtems_event_receive( RTEMS_EVENT_16, RTEMS_NO_WAIT, RTEMS_NO_TIMEOUT, &event_out ); fatal_directive_status( status, RTEMS_UNSATISFIED, "rtems_event_receive unsatisfied (ALL)" ); puts( "TA1 - rtems_event_receive - RTEMS_UNSATISFIED ( all conditions )" ); status = rtems_event_receive( RTEMS_EVENT_16, RTEMS_EVENT_ANY | RTEMS_NO_WAIT, RTEMS_NO_TIMEOUT, &event_out ); fatal_directive_status( status, RTEMS_UNSATISFIED, "rtems_event_receive unsatisfied (ANY)" ); puts( "TA1 - rtems_event_receive - RTEMS_UNSATISFIED ( any condition )" ); puts( "TA1 - rtems_event_receive - timeout in 3 seconds" ); status = rtems_event_receive( RTEMS_EVENT_16, RTEMS_DEFAULT_OPTIONS, 3 * rtems_clock_get_ticks_per_second(), &event_out ); fatal_directive_status( status, RTEMS_TIMEOUT, "rtems_event_receive" ); puts( "TA1 - rtems_event_receive - woke up with RTEMS_TIMEOUT" ); status = rtems_event_send( 100, RTEMS_EVENT_16 ); fatal_directive_status( status, RTEMS_INVALID_ID, "rtems_event_send with illegal id" ); puts( "TA1 - rtems_event_send - RTEMS_INVALID_ID" ); puts( "TA1 - rtems_task_wake_after - sleep 1 second - RTEMS_SUCCESSFUL" ); status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() ); directive_failed( status, "rtems_task_wake_after" ); build_time( &time, 2, 5, 1988, 8, 30, 45, 0 ); print_time( "TA1 - rtems_clock_set - ", &time, "" ); status = rtems_clock_set( &time ); directive_failed( status, "rtems_clock_set" ); puts( " - RTEMS_SUCCESSFUL" ); status = rtems_clock_get_tod_timeval( &tv ); directive_failed( status, "clock_get_tod_timeval OK" ); seconds = tv.tv_sec; printf( "TA1 - current time - %s\n", ctime(&seconds) ); }
rtems_task Init( rtems_task_argument argument ) { rtems_status_code status; rtems_id timer_id; rtems_name timer_name; rtems_time_of_day global_time; rtems_time_of_day time_to_fire; puts( "\n\n*** TEST " TEST_NUMBER " ***" ); /* build timer name*/ timer_name = rtems_build_name('T', 'M', '1', ' '); /* create Timer */ status = rtems_timer_create(timer_name, &timer_id); directive_failed( status, "rtems_timer_create" ); #if defined(USE_TIMER_SERVER) /* initiate timer server */ status = rtems_timer_initiate_server( RTEMS_MINIMUM_PRIORITY, RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_ATTRIBUTES ); directive_failed( status, "rtems_timer_initiate_server" ); #endif /* Set system clock */ build_time(&global_time, 6, 8, 2009, 16, 5, INITIAL_SECOND, 0); status = rtems_clock_set(&global_time); directive_failed( status, "rtems_clock_set" ); /* Set Timer to Fire */ /* build fire times */ time_to_fire = global_time; /* only diferent second */ time_to_fire.second = INITIAL_SECOND + 5; status = FIRE_WHEN( timer_id, &time_to_fire, TIMER_service_routine, (void*) NULL ); directive_failed( status, FIRE_WHEN_STRING ); /* Set system clock FORWARD */ global_time.second = INITIAL_SECOND + 10; status = rtems_clock_set(&global_time); if (!_timer_passage) { puts( TSR_MODE " Timer FAILED to fire after setting time forward"); rtems_test_exit(0); } puts( TSR_MODE " Timer fired after setting time forward -- OK"); puts( "*** END OF TEST " TEST_NUMBER " ***" ); rtems_test_exit(0); }
epos_task Init( epos_task_argument argument ) { epos_status_code status; epos_time_of_day time; printk( "\n\n*** TEST 4 ***" ); build_time( &time, 12, 31, 1988, 9, 15, 0, 0 ); status = epos_clock_set( &time ); directive_failed( status, "epos_clock_set" ); Extension_name[ 1 ] = epos_build_name( 'E', 'X', 'T', ' ' ); status = epos_extension_create( Extension_name[ 1 ], &Extensions, &Extension_id[ 1 ] ); directive_failed( status, "epos_extension_create" ); Task_name[ 1 ] = epos_build_name( 'T', 'A', '1', ' ' ); Task_name[ 2 ] = epos_build_name( 'T', 'A', '2', ' ' ); Task_name[ 3 ] = epos_build_name( 'T', 'A', '3', ' ' ); Run_count[ 1 ] = 0; Run_count[ 2 ] = 0; Run_count[ 3 ] = 0; status = epos_task_create( Task_name[ 1 ], 1, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_TIMESLICE, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] ); directive_failed( status, "epos_task_create of TA1" ); status = epos_task_create( Task_name[ 2 ], 1, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_TIMESLICE, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 2 ] ); directive_failed( status, "epos_task_create of TA2" ); status = epos_task_create( Task_name[ 3 ], 1, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_TIMESLICE, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 3 ] ); directive_failed( status, "epos_task_create of TA3" ); status = epos_task_start( Task_id[ 1 ], Task_1, 0 ); directive_failed( status, "epos_task_start of TA1" ); status = epos_task_start( Task_id[ 2 ], Task_2, 0 ); directive_failed( status, "epos_task_start of TA2" ); status = epos_task_start( Task_id[ 3 ], Task_3, 0 ); directive_failed( status, "epos_task_start of TA3" ); status = epos_task_delete( RTEMS_SELF ); directive_failed( status, "epos_task_delete of RTEMS_SELF" ); }
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" ); }
rtems_task Init( rtems_task_argument ignored ) { rtems_status_code sc; rtems_time_of_day time; rtems_interval interval; struct timeval timev; puts( "\n\n*** TEST LEGACY RTEMS_CLOCK_GET ***" ); puts( "Init - clock_set_time" ); build_time( &time, 12, 31, 1988, 9, 0, 0, 0 ); sc = rtems_clock_set( &time ); directive_failed( sc, "rtems_clock_set" ); /* NULL parameter */ sc = rtems_clock_get( RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, NULL ); fatal_directive_status( sc, RTEMS_INVALID_ADDRESS, "null pointer" ); puts( "TA1 - rtems_clock_get - RTEMS_INVALID_ADDRESS" ); /* arbitrary bad value for switch */ sc = rtems_clock_get( 0xff, &timev ); fatal_directive_status( sc, RTEMS_INVALID_NUMBER, "bad case" ); puts( "TA1 - rtems_clock_get - RTEMS_INVALID_NUMBER" ); sc = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time ); directive_failed( sc, "rtems_clock_get -- TOD" ); print_time( "Init - rtems_clock_get - ", &time, "\n" ); sc = rtems_clock_get( RTEMS_CLOCK_GET_SECONDS_SINCE_EPOCH, &interval ); directive_failed( sc, "rtems_clock_get -- Seconds Since Epoch" ); printf( "Init - rtems_clock_get - Seconds Since Epoch = %" PRIdrtems_interval "\n", interval ); sc = rtems_clock_get( RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &interval ); directive_failed( sc, "rtems_clock_get -- Ticks Since Boot" ); printf( "Init - rtems_clock_get - Ticks Since Boot = %" PRIdrtems_interval "\n", interval ); sc = rtems_clock_get( RTEMS_CLOCK_GET_TICKS_PER_SECOND, &interval ); directive_failed( sc, "rtems_clock_get -- Ticks Per Second" ); printf( "Init - rtems_clock_get - Ticks Per Second = %" PRIdrtems_interval "\n", interval ); sc = rtems_clock_get( RTEMS_CLOCK_GET_TIME_VALUE, &timev ); directive_failed( sc, "rtems_clock_get -- Time Value" ); printf( "Init - rtems_clock_get - Time Value = %" PRIdtime_t "\n", timev.tv_sec ); puts( "*** END OF TEST LEGACY RTEMS_CLOCK_GET ***" ); rtems_test_exit(0); }
rtems_task Init( rtems_task_argument argument ) { rtems_status_code status; rtems_time_of_day time; puts( "\n\n*** CPU USAGE LIBRARY TEST ***" ); build_time( &time, 12, 31, 1988, 9, 15, 0, 0 ); status = rtems_clock_set( &time ); directive_failed( status, "rtems_clock_set" ); Extension_name[ 1 ] = rtems_build_name( 'E', 'X', 'T', ' ' ); status = rtems_extension_create( Extension_name[ 1 ], &Extensions, &Extension_id[ 1 ] ); directive_failed( status, "rtems_extension_create" ); Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' ); Task_name[ 2 ] = rtems_build_name( 'T', 'A', '2', ' ' ); Task_name[ 3 ] = rtems_build_name( 'T', 'A', '3', ' ' ); Run_count[ 1 ] = 0; Run_count[ 2 ] = 0; Run_count[ 3 ] = 0; status = rtems_task_create( Task_name[ 1 ], 1, RTEMS_MINIMUM_STACK_SIZE, RTEMS_TIMESLICE, RTEMS_FLOATING_POINT, &Task_id[ 1 ] ); directive_failed( status, "rtems_task_create of TA1" ); status = rtems_task_create( Task_name[ 2 ], 1, RTEMS_MINIMUM_STACK_SIZE, RTEMS_TIMESLICE, RTEMS_FLOATING_POINT, &Task_id[ 2 ] ); directive_failed( status, "rtems_task_create of TA2" ); status = rtems_task_create( Task_name[ 3 ], 1, RTEMS_MINIMUM_STACK_SIZE, RTEMS_TIMESLICE, RTEMS_FLOATING_POINT, &Task_id[ 3 ] ); directive_failed( status, "rtems_task_create of TA3" ); status = rtems_task_start( Task_id[ 1 ], Task_1, 0 ); directive_failed( status, "rtems_task_start of TA1" ); status = rtems_task_start( Task_id[ 2 ], Task_2, 0 ); directive_failed( status, "rtems_task_start of TA2" ); status = rtems_task_start( Task_id[ 3 ], Task_3, 0 ); directive_failed( status, "rtems_task_start of TA3" ); /* * We suspend the Init task rather than delete it so it still * shows up in CPU Usage Report. If we don't, the CPU Usage * times will not add up to the time since last CPU Usage Reset. */ status = rtems_task_suspend( RTEMS_SELF ); directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); }
rtems_task Init( rtems_task_argument argument ) { rtems_time_of_day time; uint32_t index; rtems_status_code status; puts( "\n\n*** TEST 30 ***" ); build_time( &time, 12, 31, 1988, 9, 0, 0, 0 ); status = rtems_clock_set( &time ); directive_failed( status, "rtems_clock_set" ); /* initiate with bad priority */ puts( "timer_initiate_server -- INVALID_PRIORITY" ); status = rtems_timer_initiate_server( 1000, RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_ATTRIBUTES ); fatal_directive_status( status, RTEMS_INVALID_PRIORITY, "rtems_timer_initiate_server bad priority" ); puts( "timer_initiate_server -- OK" ); status = rtems_timer_initiate_server( RTEMS_TIMER_SERVER_DEFAULT_PRIORITY, RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_ATTRIBUTES ); directive_failed( status, "rtems_timer_initiate_server" ); puts( "timer_initiate_server -- already started" ); status = rtems_timer_initiate_server( RTEMS_TIMER_SERVER_DEFAULT_PRIORITY, RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_ATTRIBUTES ); fatal_directive_status( status, RTEMS_INCORRECT_STATE, "rtems_timer_initiate_server already started" ); /* * Create test tasks */ Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' ); Task_name[ 2 ] = rtems_build_name( 'T', 'A', '2', ' ' ); Task_name[ 3 ] = rtems_build_name( 'T', 'A', '3', ' ' ); Timer_name[ 1 ] = rtems_build_name( 'T', 'M', '1', ' ' ); Timer_name[ 2 ] = rtems_build_name( 'T', 'M', '2', ' ' ); Timer_name[ 3 ] = rtems_build_name( 'T', 'M', '3', ' ' ); for ( index = 1 ; index <= 3 ; index++ ) { status = rtems_task_create( Task_name[ index ], 1, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ index ] ); directive_failed( status, "rtems_task_create loop" ); status = rtems_timer_create( Timer_name[ index ], &Timer_id[ index ] ); directive_failed( status, "rtems_timer_create loop" ); } for ( index = 1 ; index <= 3 ; index++ ) { status = rtems_task_start( Task_id[ index ], Task_1_through_3, index ); directive_failed( status, "rtems_task_start loop" ); } status = rtems_task_delete( RTEMS_SELF ); directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); }
rtems_task Task_1( rtems_task_argument argument ) { rtems_event_set eventout; rtems_time_of_day time; rtems_status_code status; uint32_t index; puts( "TA1 - rtems_event_send - send RTEMS_EVENT_16 to TA2" ); status = rtems_event_send( Task_id[ 2 ], RTEMS_EVENT_16 ); directive_failed( status, "rtems_event_send" ); puts( "TA1 - rtems_event_receive - waiting forever on " "RTEMS_EVENT_14 and RTEMS_EVENT_15" ); status = rtems_event_receive( RTEMS_EVENT_14 | RTEMS_EVENT_15, RTEMS_DEFAULT_OPTIONS, RTEMS_NO_TIMEOUT, &eventout ); directive_failed( status, "rtems_event_receive" ); printf( "TA1 - RTEMS_EVENT_14 and RTEMS_EVENT_15 received - " "eventout => %08" PRIxrtems_event_set "\n", eventout ); puts( "TA1 - rtems_event_send - send RTEMS_EVENT_18 to TA2" ); status = rtems_event_send( Task_id[ 2 ], RTEMS_EVENT_18 ); directive_failed( status, "rtems_event_send" ); puts( "TA1 - rtems_event_receive - waiting with 10 second timeout " "on RTEMS_EVENT_14" ); status = rtems_event_receive( RTEMS_EVENT_14, RTEMS_DEFAULT_OPTIONS, 10 * rtems_clock_get_ticks_per_second(), &eventout ); directive_failed( status, "rtems_event_receive" ); printf( "TA1 - RTEMS_EVENT_14 received - eventout => " "%08" PRIxrtems_event_set "\n", eventout ); puts( "TA1 - rtems_event_send - send RTEMS_EVENT_19 to TA2" ); status = rtems_event_send( Task_id[ 2 ], RTEMS_EVENT_19 ); directive_failed( status, "rtems_event_send" ); status = rtems_clock_get_tod( &time ); directive_failed( status, "rtems_clock_get_tod" ); print_time( "TA1 - rtems_clock_get_tod - ", &time, "\n" ); rtems_test_pause(); puts( "TA1 - rtems_event_send - send RTEMS_EVENT_18 to self after 5 seconds"); status = rtems_timer_fire_after( Timer_id[ 1 ], 5 * rtems_clock_get_ticks_per_second(), TA1_send_18_to_self_5_seconds, NULL ); directive_failed( status, "rtems_timer_fire_after 5 seconds" ); puts( "TA1 - rtems_event_receive - waiting forever on RTEMS_EVENT_18" ); status = rtems_event_receive( RTEMS_EVENT_18, RTEMS_DEFAULT_OPTIONS, RTEMS_NO_TIMEOUT, &eventout ); directive_failed( status, "rtems_event_receive of 18" ); printf( "TA1 - RTEMS_EVENT_18 received - eventout => %08" PRIxrtems_event_set "\n", eventout ); status = rtems_clock_get_tod( &time ); directive_failed( status, "TA1 rtems_clock_get_tod" ); print_time( "TA1 - rtems_clock_get_tod - ", &time, "\n" ); puts( "TA1 - rtems_event_send - send RTEMS_EVENT_3 to self" ); status = rtems_event_send( RTEMS_SELF, RTEMS_EVENT_3 ); directive_failed( status, "rtems_event_send" ); puts( "TA1 - rtems_event_receive - RTEMS_EVENT_3 or " "RTEMS_EVENT_22 - NO_WAIT and ANY" ); status = rtems_event_receive( RTEMS_EVENT_3 | RTEMS_EVENT_22, RTEMS_NO_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &eventout ); directive_failed( status, "rtems_event_receive of 3 and 22" ); printf( "TA1 - RTEMS_EVENT_3 received - eventout => %08" PRIxrtems_event_set "\n", eventout ); puts( "TA1 - rtems_event_send - send RTEMS_EVENT_4 to self" ); status = rtems_event_send( RTEMS_SELF, RTEMS_EVENT_4 ); directive_failed( status, "rtems_event_send" ); puts ( "TA1 - rtems_event_receive - RTEMS_EVENT_4 or " "RTEMS_EVENT_5 - forever and ANY" ); status = rtems_event_receive( RTEMS_EVENT_4 | RTEMS_EVENT_5, RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &eventout ); directive_failed( status, "rtems_event_receive" ); printf( "TA1 - RTEMS_EVENT_4 received - eventout => %08" PRIxrtems_event_set "\n", eventout ); rtems_test_pause(); puts( "TA1 - rtems_event_send - send RTEMS_EVENT_18 to self after 5 seconds"); status = rtems_timer_fire_after( Timer_id[ 1 ], 5 * rtems_clock_get_ticks_per_second(), TA1_send_18_to_self_5_seconds, NULL ); directive_failed( status, "rtems_timer_fire_after 5 seconds" ); puts( "TA1 - rtems_timer_cancel - cancelling timer for event RTEMS_EVENT_18"); status = rtems_timer_cancel( Timer_id[ 1 ] ); directive_failed( status, "rtems_timer_cancel" ); puts( "TA1 - rtems_event_send - send RTEMS_EVENT_8 to self after 60 seconds"); status = rtems_timer_fire_after( Timer_id[ 1 ], 60 * rtems_clock_get_ticks_per_second(), TA1_send_8_to_self_60_seconds, NULL ); directive_failed( status, "rtems_timer_fire_after 60 seconds" ); puts( "TA1 - rtems_event_send - send RTEMS_EVENT_9 to self after 60 seconds"); status = rtems_timer_fire_after( Timer_id[ 2 ], 60 * rtems_clock_get_ticks_per_second(), TA1_send_9_to_self_60_seconds, NULL ); directive_failed( status, "rtems_timer_fire_after 60 seconds" ); puts( "TA1 - rtems_event_send - send RTEMS_EVENT_10 to self after 60 seconds" ); status = rtems_timer_fire_after( Timer_id[ 3 ], 60 * rtems_clock_get_ticks_per_second(), TA1_send_10_to_self, NULL ); directive_failed( status, "rtems_timer_fire_after 60 seconds" ); puts( "TA1 - rtems_timer_cancel - cancelling timer for event RTEMS_EVENT_8" ); status = rtems_timer_cancel( Timer_id[ 1 ] ); directive_failed( status, "rtems_timer_cancel" ); build_time( &time, 2, 12, 1988, 8, 15, 0, 0 ); print_time( "TA1 - rtems_clock_set - ", &time, "\n" ); status = rtems_clock_set( &time ); directive_failed( status, "rtems_clock_set" ); puts( "TA1 - rtems_event_send - send RTEMS_EVENT_1 every second" ); status = rtems_timer_fire_after( Timer_id[ 1 ], rtems_clock_get_ticks_per_second(), TA1_send_1_to_self_every_second, NULL ); directive_failed( status, "rtems_timer_fire_after 1 second" ); for ( index = 0; index < 3; index++ ) { status = rtems_event_receive( RTEMS_EVENT_1, RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &eventout ); directive_failed( status, "rtems_event_receive" ); status = rtems_clock_get_tod( &time ); directive_failed( status, "rtems_clock_get_tod" ); printf( "TA1 - RTEMS_EVENT_1 received - eventout => %08" PRIxrtems_event_set " - ", eventout ); print_time( "at ", &time, "\n" ); if ( index < 2 ) { status = rtems_timer_reset( Timer_id[ 1 ] ); directive_failed( status, "rtems_timer_reset" ); }; } puts( "TA1 - rtems_timer_cancel - cancelling timer for event RTEMS_EVENT_1" ); status = rtems_timer_cancel( Timer_id[ 1 ] ); directive_failed( status, "rtems_timer_cancel" ); rtems_test_pause(); time.day = 13; puts( "TA1 - rtems_event_send - sending RTEMS_EVENT_11 to self in 1 day" ); status = rtems_timer_fire_when( Timer_id[ 1 ], &time, TA1_send_11_to_self, NULL ); directive_failed( status, "rtems_timer_fire_when 1 day" ); time.hour = 7; puts( "TA1 - rtems_event_send - sending RTEMS_EVENT_11 to self in 1 day" ); status = rtems_timer_fire_when( Timer_id[ 2 ], &time, TA1_send_11_to_self, NULL ); directive_failed( status, "rtems_timer_fire_when 1 day" ); time.hour = 8; /* so code below has correct time/date */ time.day = 14; puts( "TA1 - rtems_event_send - sending RTEMS_EVENT_11 to self in 2 days" ); status = rtems_timer_fire_when( Timer_id[ 3 ], &time, TA1_send_11_to_self, NULL ); directive_failed( status, "rtems_timer_fire_when 2 days" ); puts("TA1 - rtems_timer_cancel - cancelling RTEMS_EVENT_11 to self in 1 day"); status = rtems_timer_cancel( Timer_id[ 1 ] ); directive_failed( status, "rtems_timer_cancel" ); puts( "TA1 - rtems_timer_cancel - cancelling RTEMS_EVENT_11 to self in 2 days" ); status = rtems_timer_cancel( Timer_id[ 3 ] ); directive_failed( status, "rtems_timer_cancel" ); puts( "TA1 - rtems_event_send - resending RTEMS_EVENT_11 to self in 2 days" ); status = rtems_timer_fire_when( Timer_id[ 3 ], &time, TA1_send_11_to_self, NULL ); directive_failed( status, "rtems_timer_fire_when 2 days" ); time.day = 15; print_time( "TA1 - rtems_clock_set - ", &time, "\n" ); status = rtems_clock_set( &time ); directive_failed( status, "TA1 rtems_clock_set" ); puts( "TA1 - rtems_event_receive - waiting forever on RTEMS_EVENT_11" ); status = rtems_event_receive( RTEMS_EVENT_11, RTEMS_DEFAULT_OPTIONS, RTEMS_NO_TIMEOUT, &eventout ); directive_failed( status, "rtems_event_receive" ); printf( "TA1 - RTEMS_EVENT_11 received - eventout => %08" PRIxrtems_event_set "\n", eventout ); rtems_test_pause(); puts( "TA1 - rtems_event_send/rtems_event_receive combination" ); status = rtems_timer_fire_after( Timer_id[ 1 ], 10, TA1_send_11_to_self, NULL ); directive_failed( status, "rtems_timer_fire_after 10 ticks" ); status = rtems_event_receive( RTEMS_EVENT_11, RTEMS_DEFAULT_OPTIONS, RTEMS_NO_TIMEOUT, &eventout ); directive_failed( status, "rtems_event_receive" ); build_time( &time, 2, 12, 1988, 8, 15, 0, 0 ); print_time( "TA1 - rtems_clock_set - ", &time, "\n" ); status = rtems_clock_set( &time ); directive_failed( status, "rtems_clock_set" ); time.day = 13; puts( "TA1 - rtems_event_receive all outstanding events" ); status = rtems_event_receive( RTEMS_ALL_EVENTS, RTEMS_NO_WAIT | RTEMS_EVENT_ANY, 0, &eventout ); fatal_directive_status( status, RTEMS_UNSATISFIED, "rtems_event_receive all events" ); puts( "TA1 - rtems_event_send - sending RTEMS_EVENT_10 to self in 1 day" ); status = rtems_timer_fire_when( Timer_id[ 1 ], &time, TA1_send_10_to_self, NULL ); directive_failed( status, "rtems_timer_fire_when 1 day" ); time.day = 14; puts( "TA1 - rtems_event_send - sending RTEMS_EVENT_11 to self in 2 days" ); status = rtems_timer_fire_when( Timer_id[ 2 ], &time, TA1_send_11_to_self, NULL ); directive_failed( status, "rtems_timer_fire_when 2 days" ); build_time( &time, 2, 12, 1988, 7, 15, 0, 0 ); print_time( "TA1 - rtems_clock_set - ", &time, "\n" ); puts( "TA1 - set time backwards" ); status = rtems_clock_set( &time ); directive_failed( status, "rtems_clock_set" ); status = rtems_event_receive( RTEMS_ALL_EVENTS, RTEMS_NO_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &eventout ); if ( eventout ) printf( "ERROR -0x%08" PRIxrtems_event_set " events received\n", eventout ); else puts( "TA1 - no events received" ); fatal_directive_status( status, RTEMS_UNSATISFIED, "rtems_event_receive all events" ); build_time( &time, 2, 14, 1988, 7, 15, 0, 0 ); print_time( "TA1 - rtems_clock_set - ", &time, "\n" ); puts( "TA1 - set time forwards (leave a timer)" ); status = rtems_clock_set( &time ); directive_failed( status, "rtems_clock_set" ); status = rtems_event_receive( RTEMS_ALL_EVENTS, RTEMS_NO_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &eventout ); if ( eventout == RTEMS_EVENT_10 ) puts( "TA1 - RTEMS_EVENT_10 received" ); else printf( "ERROR -0x%08" PRIxrtems_event_set " events received\n", eventout ); directive_failed( status, "rtems_event_receive all events" ); puts( "TA1 - rtems_event_send - sending RTEMS_EVENT_11 to self in 100 ticks"); status = rtems_timer_fire_after( Timer_id[ 1 ], 100, TA1_send_11_to_self, NULL ); directive_failed( status, "rtems_timer_fire_after 100 ticks" ); puts( "TA1 - rtems_event_send - sending RTEMS_EVENT_11 to self in 200 ticks"); status = rtems_timer_fire_after( Timer_id[ 1 ], 200, TA1_send_11_to_self, NULL ); directive_failed( status, "rtems_timer_fire_after 200 ticks" ); /***** *****/ puts( "TA1 - rtems_event_send - send RTEMS_EVENT_4 to self" ); status = rtems_event_send( RTEMS_SELF, RTEMS_EVENT_4 ); directive_failed( status, "rtems_event_send" ); eventout = 0; puts( "TA1 - rtems_event_receive - RTEMS_EVENT_4 AND RTEMS_EVENT_5 - UNSATISFIED" ); status = rtems_event_receive( RTEMS_EVENT_4 | RTEMS_EVENT_5, RTEMS_NO_WAIT | RTEMS_EVENT_ALL, RTEMS_NO_TIMEOUT, &eventout ); fatal_directive_status( status, RTEMS_UNSATISFIED, "rtems_event_receive" ); /***** *****/ puts( "*** END OF TEST 11 ***" ); rtems_test_exit( 0 ); }
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 ); }
epos_task Init( epos_task_argument argument ) { epos_time_of_day time; epos_status_code status; epos_interrupt_level level; bool in_isr; epos_id timer; int i; printk( "\n\n*** TEST 37 ***" ); build_time( &time, 12, 31, 1988, 9, 0, 0, 0 ); status = epos_clock_set( &time ); directive_failed( status, "epos_clock_set" ); /* * Timer used in multiple ways */ status = epos_timer_create( 1, &timer ); directive_failed( status, "epos_timer_create" ); /* * Test clock tick from outside ISR */ status = epos_clock_tick(); directive_failed( status, "epos_clock_tick" ); printk( "clock_tick from task level" ); /* * Now do a dispatch directly out of a clock tick that is * called from a task. We need to create a task that will * block so we have one to unblock. Then we schedule a TSR * to run in the clock tick but it has to be careful to * make sure it is not called from an ISR and that the * dispatching critical section is managed properly to * make the dispatch happen. */ blocked_task_status = -1; status = epos_task_create( epos_build_name( 'T', 'A', '1', ' ' ), 1, RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &blocked_task_id ); directive_failed( status, "epos_task_create" ); status = epos_task_start( blocked_task_id, blocked_task, 0 ); directive_failed( status, "epos_task_start" ); status = epos_task_wake_after( 10 ); directive_failed( status, "epos_task_wake_after" ); status = epos_timer_fire_after( timer, 1, test_unblock_task, NULL ); directive_failed( status, "timer_fire_after failed" ); /* we expect to be preempted from this call */ for ( i=0 ; i<100 && blocked_task_status != 3 ; i++ ) { status = epos_clock_tick(); directive_failed( status, "epos_clock_tick" ); } switch ( blocked_task_status ) { case -1: printk( "clock_tick with task preempt -- task blocked, timer did not fire" ); epos_test_exit(0); break; case 1: printk( "clock_tick with task preempt -- timer fired case 1" ); epos_test_exit(0); break; case 2: printk( "clock_tick with task preempt -- timer fired case 2" ); epos_test_exit(0); break; case 3: printk( "clock_tick from task level with preempt -- OK" ); break; } /* * Test interrupt inline versions */ test_interrupt_inline(); /* * Test interrupt bodies */ printk( "interrupt is in progress (use body)" ); in_isr = epos_interrupt_is_in_progress(); if ( in_isr ) { printk( "interrupt reported to be is in progress (body)" ); epos_test_exit( 0 ); } printk( "interrupt disable (use body)" ); level = epos_interrupt_disable(); printk( "interrupt disable (use body)" ); level = epos_interrupt_disable(); printk( "interrupt flash (use body)" ); epos_interrupt_flash( level ); printk( "interrupt enable (use body)" ); epos_interrupt_enable( level ); /* * Test ISR in progress from actual ISR */ isr_in_progress_body = -1; isr_in_progress_inline = -1; status = epos_timer_fire_after( timer, 10, test_isr_in_progress, NULL ); directive_failed( status, "timer_fire_after failed" ); status = epos_task_wake_after( 100 ); directive_failed( status, "wake_after failed" ); check_isr_worked( "inline", isr_in_progress_body ); check_isr_worked( "body", isr_in_progress_body ); printk( "*** END OF TEST 37 ***" ); epos_test_exit( 0 ); }
void get_package_and_svn(char* server_version, int64_t buf_len) { const char* server_version_template = "%s_%s(%s %s)"; snprintf(server_version, buf_len, server_version_template, PACKAGE_VERSION, svn_version(), build_date(), build_time()); }
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 ); }
void print_build_time() { printf(BUILD_TIME_FMT "%s %s\n", build_date(), build_time()); }
rtems_task Init( rtems_task_argument argument ) { void *p1; rtems_time_of_day time; rtems_status_code status; TEST_BEGIN(); build_time( &time, 12, 31, 1988, 9, 0, 0, 0 ); status = rtems_clock_set( &time ); directive_failed( status, "rtems_clock_set" ); /* * Verify case where block is too large to calloc. */ p1 = calloc( 1, SIZE_MAX ); if (p1) { printf("ERROR on attempt to calloc SIZE_MAX block expected failure."); free( p1 ); } /* * Verify error case where malloc of size 0. */ p1 = malloc( 0 ); if (p1) { printf("ERROR on attempt to malloc size 0 block expected failure."); free( p1 ); } test_heap_initialize(); test_heap_block_allocate(); test_heap_allocate(); test_heap_free(); test_heap_resize_block(); test_realloc(); test_heap_cases_1(); test_heap_extend(); test_heap_extend_allocation_order(); test_heap_extend_allocation_order_with_empty_heap(); test_heap_no_extend(); test_heap_info(); test_heap_size_with_overhead(); test_protected_heap_info(); test_rtems_heap_allocate_aligned_with_boundary(); test_greedy_allocate(); test_posix_memalign(); Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' ); Task_name[ 2 ] = rtems_build_name( 'T', 'A', '2', ' ' ); Task_name[ 3 ] = rtems_build_name( 'T', 'A', '3', ' ' ); Task_name[ 4 ] = rtems_build_name( 'T', 'A', '4', ' ' ); Task_name[ 5 ] = rtems_build_name( 'T', 'A', '5', ' ' ); status = rtems_task_create( Task_name[ 1 ], 1, TASK_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[ 1 ] ); directive_failed( status, "rtems_task_create of TA1" ); status = rtems_task_create( Task_name[ 2 ], 1, TASK_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[ 2 ] ); directive_failed( status, "rtems_task_create of TA2" ); status = rtems_task_create( Task_name[ 3 ], 1, TASK_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[ 3 ] ); directive_failed( status, "rtems_task_create of TA3" ); status = rtems_task_create( Task_name[ 4 ], 1, TASK_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[ 4 ] ); directive_failed( status, "rtems_task_create of TA4" ); status = rtems_task_create( Task_name[ 5 ], 1, TASK_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[ 5 ] ); directive_failed( status, "rtems_task_create of TA5" ); status = rtems_task_start( Task_id[ 1 ], Task_1_through_5, 0 ); directive_failed( status, "rtems_task_start of TA1" ); status = rtems_task_start( Task_id[ 2 ], Task_1_through_5, 0 ); directive_failed( status, "rtems_task_start of TA2" ); status = rtems_task_start( Task_id[ 3 ], Task_1_through_5, 0 ); directive_failed( status, "rtems_task_start of TA3" ); status = rtems_task_start( Task_id[ 4 ], Task_1_through_5, 0 ); directive_failed( status, "rtems_task_start of TA4" ); status = rtems_task_start( Task_id[ 5 ], Task_1_through_5, 0 ); directive_failed( status, "rtems_task_start of TA5" ); status = rtems_task_delete( RTEMS_SELF ); directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); }
rtems_task Task_2( rtems_task_argument argument ) { rtems_event_set eventout; rtems_time_of_day time; rtems_status_code status; status = rtems_task_wake_after( 1*TICKS_PER_SECOND ); directive_failed( status, "rtems_task_wake_after" ); puts( "TA2 - rtems_event_receive - waiting forever on RTEMS_EVENT_16" ); status = rtems_event_receive( RTEMS_EVENT_16, RTEMS_DEFAULT_OPTIONS, RTEMS_NO_TIMEOUT, &eventout ); directive_failed( status, "rtems_event_receive" ); printf( "TA2 - RTEMS_EVENT_16 received - eventout => %08x\n", eventout ); puts( "TA2 - rtems_event_send - send RTEMS_EVENT_14 and RTEMS_EVENT_15 to TA1" ); status = rtems_event_send( Task_id[ 1 ], RTEMS_EVENT_14 | RTEMS_EVENT_15 ); directive_failed( status, "rtems_event_send" ); puts( "TA2 - rtems_event_receive - RTEMS_EVENT_17 or " "RTEMS_EVENT_18 - forever and ANY" ); status = rtems_event_receive( RTEMS_EVENT_17 | RTEMS_EVENT_18, RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &eventout ); directive_failed( status, "rtems_event_receive" ); printf( "TA2 - RTEMS_EVENT_17 or RTEMS_EVENT_18 received - eventout => %08x\n", eventout ); puts( "TA2 - rtems_event_send - send RTEMS_EVENT_14 to TA1" ); status = rtems_event_send( Task_id[ 1 ], RTEMS_EVENT_14 ); directive_failed( status, "rtems_event_send" ); build_time( &time, 2, 12, 1988, 8, 15, 0, 0 ); print_time( "TA2 - rtems_clock_set - ", &time, "\n" ); status = rtems_clock_set( &time ); directive_failed( status, "TA2 rtems_clock_set" ); time.second += 4; puts( "TA2 - rtems_event_send - sending RTEMS_EVENT_10 to self after 4 seconds" ); status = rtems_timer_fire_when( Timer_id[ 5 ], &time, TA2_send_10_to_self, NULL ); directive_failed( status, "rtems_timer_fire_when after 4 seconds" ); puts( "TA2 - rtems_event_receive - waiting forever on RTEMS_EVENT_10" ); status = rtems_event_receive( RTEMS_EVENT_10, RTEMS_DEFAULT_OPTIONS, RTEMS_NO_TIMEOUT, &eventout ); directive_failed( status, "rtems_event_receive" ); status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time ); directive_failed( status, "rtems_clock_get" ); printf( "TA2 - RTEMS_EVENT_10 received - eventout => %08x\n", eventout ); print_time( "TA2 - rtems_clock_get - ", &time, "\n" ); puts( "TA2 - rtems_event_receive - RTEMS_PENDING_EVENTS" ); status = rtems_event_receive( RTEMS_PENDING_EVENTS, RTEMS_DEFAULT_OPTIONS, RTEMS_NO_TIMEOUT, &eventout ); directive_failed( status, "rtems_event_receive" ); printf( "TA2 - eventout => %08x\n", eventout ); puts( "TA2 - rtems_event_receive - RTEMS_EVENT_19 - RTEMS_NO_WAIT" ); status = rtems_event_receive( RTEMS_EVENT_19, RTEMS_NO_WAIT, RTEMS_NO_TIMEOUT, &eventout ); directive_failed( status, "rtems_event_receive" ); printf( "TA2 - RTEMS_EVENT_19 received - eventout => %08x\n", eventout ); puts( "TA2 - rtems_task_delete - deletes self" ); status = rtems_task_delete( Task_id[ 2 ] ); directive_failed( status, "rtems_task_delete of TA2" ); }