rtems_task Test_task( rtems_task_argument argument ) { rtems_status_code status; rtems_id tid; rtems_time_of_day time; status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid ); directive_failed( status, "rtems_task_ident" ); status = rtems_clock_get_tod( &time ); directive_failed( status, "rtems_clock_get_tod" ); put_name( Task_name[ task_number( tid ) ], FALSE ); print_time( " - rtems_clock_get_tod - ", &time, "\n" ); status = rtems_task_wake_after( task_number( tid ) * 1 * rtems_clock_get_ticks_per_second() ); directive_failed( status, "rtems_task_wake_after" ); status = rtems_clock_get_tod( &time ); directive_failed( status, "rtems_clock_get_tod" ); put_name( Task_name[ task_number( tid ) ], FALSE ); print_time( " - rtems_clock_get_tod - ", &time, "\n" ); if ( task_number(tid) == 1 ) { /* TASK 1 */ put_name( Task_name[ 1 ], FALSE ); printf( " - deleting self\n" ); status = rtems_task_delete( RTEMS_SELF ); directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); } else if ( task_number(tid) == 2 ) { /* TASK 2 */ put_name( Task_name[ 2 ], FALSE ); printf( " - waiting to be deleted by " ); put_name( Task_name[ 3 ], TRUE ); while ( FOREVER ); } else { /* TASK 3 */ put_name( Task_name[ 3 ], FALSE ); printf( " - getting TID of " ); put_name( Task_name[ 2 ], TRUE ); do { status = rtems_task_ident( Task_name[ 2 ], RTEMS_SEARCH_ALL_NODES, &tid ); } while ( status != RTEMS_SUCCESSFUL ); directive_failed( status, "rtems_task_ident" ); put_name( Task_name[ 3 ], FALSE ); printf( " - deleting " ); put_name( Task_name[ 2 ], TRUE ); status = rtems_task_delete( tid ); directive_failed( status, "rtems_task_delete of Task 2" ); puts( "*** END OF TEST 1 ***" ); rtems_test_exit(0); } }
rtems_task Task_2( 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" ); while( FOREVER ) { status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() ); directive_failed( status, "rtems_task_wake_after" ); status = rtems_clock_get_tod( &time ); directive_failed( status, "rtems_clock_get_tod" ); if ( time.second >= 17 ) { puts( "*** END OF TEST 3 *** " ); rtems_test_exit( 0 ); } put_name( name, FALSE ); print_time( " ", &time, "\n" ); } }
rtems_task Test_task( rtems_task_argument unused ) { rtems_id tid; rtems_time_of_day time; uint32_t task_index; rtems_status_code status; char name[5]; char *p; /* Get the task name */ p = rtems_object_get_name( RTEMS_SELF, 5, name ); rtems_test_assert( p != NULL ); status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid ); rtems_test_assert( status == RTEMS_SUCCESSFUL ); task_index = task_number( tid ); for ( ; ; ) { status = rtems_clock_get_tod( &time ); rtems_test_assert( status == RTEMS_SUCCESSFUL ); if ( time.second >= 35 ) { TEST_END(); rtems_test_exit( 0 ); } PrintTaskInfo( p, &time ); status = rtems_task_wake_after( task_index * 5 * rtems_clock_get_ticks_per_second() ); rtems_test_assert( status == RTEMS_SUCCESSFUL ); } }
rtems_task Test_task( rtems_task_argument unused ) { rtems_id tid; rtems_time_of_day time; uint32_t task_index; rtems_status_code status; int cpu_num; char name[5]; char *p; /* Get the task name */ p = rtems_object_get_name( RTEMS_SELF, 5, name ); rtems_test_assert( p != NULL ); status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid ); task_index = task_number( tid ); for ( ; ; ) { /* Get the CPU Number */ cpu_num = bsp_smp_processor_id(); status = rtems_clock_get_tod( &time ); if ( time.second >= 35 ) { locked_printf( "*** END OF SMP08 TEST ***" ); rtems_test_exit( 0 ); } PrintTaskInfo( p, &time ); status = rtems_task_wake_after( task_index * 5 * rtems_clock_get_ticks_per_second() ); } }
rtems_task Task_1( rtems_task_argument argument ) { rtems_status_code status; rtems_id tid; rtems_time_of_day time; uint32_t task_index; INTEGER_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 ] ); put_name( Task_name[ task_index ], FALSE ); printf( " - integer base = (0x%" PRIx32 ")\n", INTEGER_factors[ task_index ] ); while( FOREVER ) { status = rtems_clock_get_tod( &time ); directive_failed( status, "rtems_clock_get_tod" ); put_name( Task_name[ task_number( tid ) ], FALSE ); print_time( " - rtems_clock_get_tod - ", &time, "\n" ); INTEGER_CHECK( INTEGER_factors[ task_index ] ); status = rtems_task_wake_after( ( task_number( tid ) ) * 5 * rtems_clock_get_ticks_per_second() ); directive_failed( status, "rtems_task_wake_after" ); } }
rtems_task Test_task( rtems_task_argument arg ) { rtems_time_of_day time; uint32_t task_index; rtems_status_code status; task_index = arg; for ( ; ; ) { status = rtems_clock_get_tod( &time ); directive_failed( status, "get tod" ); if ( time.second >= 15 ) { puts( "*** END OF SP73 (YIELD) TEST ***" ); rtems_test_exit( 0 ); } put_name( Task_name[ task_index ], FALSE ); print_time( " - rtems_clock_get_tod - ", &time, "\n" ); status = rtems_task_wake_after( task_index * 5 * rtems_clock_get_ticks_per_second() ); directive_failed( status, "wake after" ); } }
void Task_switch( rtems_tcb *unused, rtems_tcb *heir ) { uint32_t index; rtems_time_of_day time; rtems_status_code status; index = task_number( heir->Object.id ) - task_number( Task_id[1] ) + 1; switch( index ) { case 1: case 2: case 3: Run_count[ index ] += 1; status = rtems_clock_get_tod( &time ); directive_failed_with_level( status, "rtems_clock_get_tod", 1 ); if (taskSwitchLogIndex < (sizeof taskSwitchLog / sizeof taskSwitchLog[0])) { taskSwitchLog[taskSwitchLogIndex].taskIndex = index; taskSwitchLog[taskSwitchLogIndex].when = time; taskSwitchLogIndex++; } if ( time.second >= 16 ) testsFinished = 1; break; case 0: default: break; } }
void Task_2_through_4(void) { ID tid; int tid_index; rtems_time_of_day time; ER status; char name[30]; status = get_tid( &tid ); directive_failed( status, "get_tid"); tid_index = tid - 1; /* account for init tasks */ sprintf(name, "TA%d", tid_index); while( FOREVER ) { status = rtems_clock_get_tod( &time ); directive_failed( status, "rtems_clock_get_tod" ); if ( time.second >= 35 ) { puts( "*** END OF ITRON TASK TEST 1 ***" ); rtems_test_exit( 0 ); } printf(name); print_time( " - rtems_clock_get_tod - ", &time, "\n" ); status = rtems_task_wake_after( tid_index * 5 * rtems_clock_get_ticks_per_second() ); directive_failed( status, "rtems_task_wake_after" ); } }
rtems_task Test_task( rtems_task_argument unused ) { rtems_id tid; rtems_time_of_day time; uint32_t task_index; rtems_status_code status; status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid ); directive_failed( status, "task ident" ); task_index = task_number( tid ); for ( ; ; ) { status = rtems_clock_get_tod( &time ); if ( time.second >= 35 ) { puts( "*** END OF CLOCK TICK TEST ***" ); rtems_test_exit( 0 ); } put_name( Task_name[ task_index ], FALSE ); print_time( " - rtems_clock_get_tod - ", &time, "\n" ); status = rtems_task_wake_after( task_index * 5 * rtems_clock_get_ticks_per_second() ); directive_failed( status, "wake after" ); } }
rtems_task Task_1_through_3( rtems_task_argument index ) { rtems_time_of_day time; rtems_status_code status; rtems_interval ticks; rtems_name name; status = rtems_object_get_classic_name( rtems_task_self(), &name ); directive_failed( status, "rtems_object_get_classic_name" ); ticks = RTEMS_MILLISECONDS_TO_TICKS( index * 5 * 1000 ); while( FOREVER ) { status = rtems_clock_get_tod( &time ); directive_failed( status, "rtems_clock_get_tod" ); if ( time.second >= 35 ) { TEST_END(); rtems_test_exit( 0 ); } put_name( name, FALSE ); print_time( " - rtems_clock_get_tod - ", &time, "\n" ); status = rtems_task_wake_after( ticks ); directive_failed( status, "rtems_task_wake_after" ); } }
rtems_task Task_1_through_3( rtems_task_argument argument ) { rtems_id tid; rtems_time_of_day time; rtems_status_code status; status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid ); directive_failed( status, "rtems_task_ident of self" ); while ( FOREVER ) { status = rtems_timer_server_fire_after( Timer_id[ argument ], (task_number( tid ) - 1) * 5 * rtems_clock_get_ticks_per_second(), Resume_task, (void *) &tid ); directive_failed( status, "rtems_timer_server_fire_after failed" ); status = rtems_clock_get_tod( &time ); directive_failed( status, "rtems_clock_get_tod failed" ); if ( time.second >= 35 ) { puts( "*** END OF TEST 30 ***" ); rtems_test_exit( 0 ); } put_name( Task_name[ task_number( tid ) - 1 ], FALSE ); print_time( " - rtems_clock_get_tod - ", &time, "\n" ); status = rtems_task_suspend( RTEMS_SELF ); directive_failed( status, "rtems_task_suspend" ); } }
rtems_task Task_1_through_3( rtems_task_argument argument ) { rtems_id tid; rtems_time_of_day time; rtems_status_code status; rtems_interval ticks; status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid ); directive_failed( status, "rtems_task_ident" ); /* * Use TOD_MILLISECONDS_TO_TICKS not RTEMS_MILLISECONDS_TO_TICKS to * test C implementation in SuperCore -- not macro version used * everywhere else. */ ticks = TOD_MILLISECONDS_TO_TICKS( task_number( tid ) * 5 * 1000 ); while( FOREVER ) { status = rtems_clock_get_tod( &time ); directive_failed( status, "rtems_clock_get_tod" ); if ( time.second >= 35 ) { puts( "*** END OF CBS SCHEDULER TEST 1 ***" ); rtems_test_exit( 0 ); } put_name( Task_name[ task_number( tid ) ], FALSE ); print_time( " - rtems_clock_get_tod - ", &time, "\n" ); status = rtems_task_wake_after( ticks ); directive_failed( status, "rtems_task_wake_after" ); } }
/* * setRealTimeFromRTEMS * * This routine copies the time from RTEMS to the real time clock */ void setRealTimeFromRTEMS(void) { rtems_time_of_day rtems_tod; if (!RTC_Is_present()) return; rtems_clock_get_tod( &rtems_tod ); RTC_Table[RTC_Minor].pDeviceFns->deviceSetTime(RTC_Minor, &rtems_tod); }
rtems_task Task_1_through_5( rtems_task_argument argument ) { int i; unsigned int passes = 0; rtems_id tid; rtems_time_of_day time; rtems_status_code status; unsigned char *mem_ptr; int mem_amt; status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid ); directive_failed( status, "rtems_task_ident" ); while (TRUE) { bool malloc_walk_ok; if ( passes++ > NUM_PASSES ) { TEST_END(); rtems_test_exit(0); } status = rtems_clock_get_tod( &time ); directive_failed( status, "rtems_clock_get_tod" ); put_name( Task_name[ task_number( tid ) ], FALSE ); print_time( " - rtems_clock_get_tod - ", &time, "\n" ); mem_amt = ((int)((float)rand()*1000.0/(float)RAND_MAX)); while (!(mem_ptr = malloc ( mem_amt))) { printf("out of memory... trying again.\n"); mem_amt = ((int)((float)rand()*1000.0/(float)RAND_MAX)); } printf("mallocing %d bytes\n",mem_amt); memset( mem_ptr, mem_amt, mem_amt ); malloc_report_statistics(); malloc_walk_ok = malloc_walk( 1, false ); rtems_test_assert( malloc_walk_ok ); status = rtems_task_wake_after( task_number( tid ) * 1 * rtems_clock_get_ticks_per_second()/4 ); for (i=0; i < mem_amt; i++) { if ( mem_ptr[i] != (mem_amt & 0xff)) { printf("failed %d, %d, 0x%x, 0x%x\n",i,mem_amt,mem_ptr[i],mem_amt&0xff); rtems_test_exit(1); } } directive_failed( status, "rtems_task_wake_after" ); free( mem_ptr ); } }
void Print_time( void ) { rtems_time_of_day time; rtems_status_code status; status = rtems_clock_get_tod( &time ); directive_failed( status, "rtems_clock_get_tod" ); put_name( Task_name[ 1 ], FALSE ); print_time( "- rtems_clock_get_tod - ", &time, "\n" ); }
static void test_problem_year(void) { #if TEST_APPLICABLE rtems_status_code sc = RTEMS_SUCCESSFUL; time_t zero = 0; time_t one = 1; time_t maybe_negative = zero - one; bool time_t_is_32_bit = sizeof(time_t) == 4; bool time_t_is_signed = maybe_negative < zero; if (time_t_is_32_bit) { const rtems_time_of_day *nearly_problem = NULL; const rtems_time_of_day *problem = NULL; rtems_time_of_day now; if (time_t_is_signed) { nearly_problem = &nearly_problem_2038; problem = &problem_2038; } else { nearly_problem = &nearly_problem_2106; problem = &problem_2106; } sc = rtems_clock_set(nearly_problem); ASSERT_SC(sc); sc = rtems_clock_get_tod(&now); ASSERT_SC(sc); rtems_test_assert(memcmp(&now, nearly_problem, sizeof(now)) == 0); sc = rtems_clock_set(problem); ASSERT_SC(sc); sc = rtems_clock_get_tod(&now); ASSERT_SC(sc); rtems_test_assert(memcmp(&now, problem, sizeof(now)) == 0); } #endif /* TEST_APPLICABLE */ }
/* * checkRealTime * * This routine reads the returns the variance betweent the real time and * RTEMS time. */ int checkRealTime(void) { rtems_time_of_day rtems_tod; rtems_time_of_day rtc_tod; uint32_t rtems_time; uint32_t rtc_time; if (!RTC_Is_present()) return -1; rtems_clock_get_tod( &rtems_tod ); RTC_Table[RTC_Minor].pDeviceFns->deviceGetTime(RTC_Minor, &rtc_tod); rtems_time = _TOD_To_seconds( &rtems_tod ); rtc_time = _TOD_To_seconds( &rtc_tod ); return rtems_time - rtc_time; }
void check_a_tod( rtems_time_of_day *the_tod ) { rtems_status_code status; rtems_time_of_day new_tod; time_t a_time_t; struct timeval tv; struct tm *a_tm; int result; int i = 0; print_time( "rtems_clock_set ", the_tod, "\n" ); status = rtems_clock_set( the_tod ); rtems_test_assert( !status ); do { status = rtems_clock_get_tod( &new_tod ); rtems_test_assert( !status ); print_time( "rtems_clock_get_tod ", &new_tod, "\n" ); /* now do the posix time gets */ result = gettimeofday( &tv, 0 ); rtems_test_assert( result == 0 ); a_time_t = tv.tv_sec; /* ctime() takes a time_t */ printf( "gettimeofday: %s", ctime( &a_time_t) ); a_time_t = time( 0 ); printf( "time: %s", ctime( &a_time_t ) ); a_tm = localtime( &a_time_t ); printf( "localtime: %s", asctime( a_tm ) ); a_tm = gmtime( &a_time_t ); printf( "gmtime: %s\n", asctime( a_tm ) ); status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() ); i++; } while( i <= 3 ); }
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 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 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 FP_task( rtems_task_argument argument ) { rtems_status_code status; rtems_id tid; rtems_time_of_day time; uint32_t task_index; uint32_t previous_seconds; INTEGER_DECLARE; FP_DECLARE; status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid ); directive_failed( status, "rtems_task_ident of self" ); 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 previous_seconds = (uint32_t)-1; while( FOREVER ) { status = rtems_clock_get_tod( &time ); directive_failed( status, "rtems_clock_get_tod" ); if ( time.second >= 16 ) { if ( task_number( tid ) == 4 ) { puts( "TA4 - rtems_task_delete - self" ); status = rtems_task_delete( RTEMS_SELF ); directive_failed( status, "rtems_task_delete of TA4" ); } puts( "TA5 - rtems_task_delete - TA3" ); status = rtems_task_delete( Task_id[ 3 ] ); directive_failed( status, "rtems_task_delete of TA3" ); puts( "*** END OF TEST 19 *** " ); rtems_test_exit( 0 ); } if (previous_seconds != time.second) { put_name( Task_name[ task_index ], FALSE ); print_time( " - rtems_clock_get_tod - ", &time, "\n" ); previous_seconds = time.second; } INTEGER_CHECK( INTEGER_factors[ task_index ] ); FP_CHECK( FP_factors[ task_index ] ); /* for the first 4 seconds we spin as fast as possible * so that we likely are interrupted * After that, we go to sleep for a second at a time */ if (time.second >= 4) { status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() ); directive_failed( status, "rtems_task_wake_after" ); } } }
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_time_of_day tod 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; /* 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_tod */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_clock_get_tod( &tod ); end_time = benchmark_timer_read(); put_time( "overhead: rtems_clock_get_tod", 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 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 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 Task_2( rtems_task_argument argument ) { rtems_event_set eventout; rtems_time_of_day time; rtems_status_code status; status = rtems_task_wake_after( rtems_clock_get_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 => %08" PRIxrtems_event_set "\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 => %08" PRIxrtems_event_set "\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_tod( &time ); directive_failed( status, "rtems_clock_get_tod" ); printf( "TA2 - RTEMS_EVENT_10 received - eventout => %08" PRIxrtems_event_set "\n", eventout ); print_time( "TA2 - rtems_clock_get_tod - ", &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 => %08" PRIxrtems_event_set "\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 => %08" PRIxrtems_event_set "\n", eventout ); puts( "TA2 - rtems_task_delete - deletes self" ); status = rtems_task_delete( Task_id[ 2 ] ); directive_failed( status, "rtems_task_delete of TA2" ); }
rtems_task Task_1( rtems_task_argument argument ) { uint32_t seconds; uint32_t old_seconds; rtems_mode previous_mode; rtems_time_of_day time; rtems_status_code status; uint32_t start_time; uint32_t end_time; puts( "TA1 - rtems_task_suspend - on Task 2" ); status = rtems_task_suspend( Task_id[ 2 ] ); directive_failed( status, "rtems_task_suspend of TA2" ); puts( "TA1 - rtems_task_suspend - on Task 3" ); status = rtems_task_suspend( Task_id[ 3 ] ); directive_failed( status, "rtems_task_suspend of TA3" ); status = rtems_clock_get_seconds_since_epoch( &start_time ); directive_failed( status, "rtems_clock_get_seconds_since_epoch" ); puts( "TA1 - killing time" ); for ( ; ; ) { status = rtems_clock_get_seconds_since_epoch( &end_time ); directive_failed( status, "rtems_clock_get_seconds_since_epoch" ); if ( end_time > (start_time + 2) ) break; } puts( "TA1 - rtems_task_resume - on Task 2" ); status = rtems_task_resume( Task_id[ 2 ] ); directive_failed( status, "rtems_task_resume of TA2" ); puts( "TA1 - rtems_task_resume - on Task 3" ); status = rtems_task_resume( Task_id[ 3 ] ); directive_failed( status, "rtems_task_resume of TA3" ); while ( FOREVER ) { if ( Run_count[ 1 ] >= 3 ) { puts( "TA1 - rtems_task_mode - change mode to NO RTEMS_PREEMPT" ); status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &previous_mode ); directive_failed( status, "rtems_task_mode" ); status = rtems_clock_get_tod( &time ); directive_failed( status, "rtems_clock_get_tod" ); old_seconds = time.second; for ( seconds = 0 ; seconds < 6 ; ) { status = rtems_clock_get_tod( &time ); directive_failed( status, "rtems_clock_get_tod" ); if ( time.second != old_seconds ) { old_seconds = time.second; seconds++; print_time( "TA1 - ", &time, "\n" ); } } puts( "TA1 - rtems_task_mode - change mode to RTEMS_PREEMPT" ); status = rtems_task_mode( RTEMS_PREEMPT, RTEMS_PREEMPT_MASK, &previous_mode ); directive_failed( status, "rtems_task_mode" ); while ( !testsFinished ); showTaskSwitches (); puts( "TA1 - rtems_extension_delete - successful" ); status = rtems_extension_delete( Extension_id[1] ); directive_failed( status, "rtems_extension_delete" ); puts( "*** END OF TEST 4 ***" ); rtems_test_exit (0); } } }
rtems_task Init( rtems_task_argument argument ) { rtems_time_of_day time; rtems_interval interval; struct timeval tv; rtems_status_code status; TEST_BEGIN(); puts( "TA1 - rtems_clock_get_tod - RTEMS_INVALID_ADDRESS" ); status = rtems_clock_get_tod( NULL ); fatal_directive_status( status, RTEMS_INVALID_ADDRESS, "rtems_clock_get_tod NULL param" ); /* errors before clock is set */ status = rtems_clock_get_tod( &time ); if ( status == RTEMS_SUCCESSFUL ) { puts( "TA1 - rtems_clock_get_tod - RTEMS_NOT_DEFINED -- " "DID BSP SET THE TIME OF DAY?" ); } else { fatal_directive_status( status, RTEMS_NOT_DEFINED, "rtems_clock_get_tod before clock is set #1" ); puts( "TA1 - rtems_clock_get_tod - RTEMS_NOT_DEFINED" ); } puts( "TA1 - rtems_clock_get_seconds_since_epoch - RTEMS_INVALID_ADDRESS" ); status = rtems_clock_get_seconds_since_epoch( NULL ); fatal_directive_status( status, RTEMS_INVALID_ADDRESS, "rtems_clock_get_seconds_since_epoch NULL param" ); status = rtems_clock_get_seconds_since_epoch( &interval ); if ( status == RTEMS_SUCCESSFUL ) { puts( "TA1 - rtems_clock_get_seconds_since_epoch - RTEMS_NOT_DEFINED -- " "DID BSP SET THE TIME OF DAY?" ); } else { fatal_directive_status( status, RTEMS_NOT_DEFINED, "rtems_clock_get_seconds_before_epoch" ); puts( "TA1 - rtems_clock_get_seconds_since_epoch - RTEMS_NOT_DEFINED" ); } puts( "TA1 - rtems_clock_get_uptime - RTEMS_INVALID_ADDRESS" ); status = rtems_clock_get_uptime( NULL ); fatal_directive_status( status, RTEMS_INVALID_ADDRESS, "rtems_clock_get_uptime NULL param" ); puts( "TA1 - rtems_clock_get_uptime_timeval" ); rtems_clock_get_uptime_timeval( &tv ); puts( "TA1 - rtems_clock_get_uptime_seconds" ); rtems_clock_get_uptime_seconds(); puts( "TA1 - rtems_clock_get_uptime_nanoseconds" ); rtems_clock_get_uptime_nanoseconds(); puts( "TA1 - rtems_clock_get_tod_timeval - RTEMS_INVALID_ADDRESS" ); status = rtems_clock_get_tod_timeval( NULL ); fatal_directive_status( status, RTEMS_INVALID_ADDRESS, "rtems_clock_get_tod_timeval NULL param" ); status = rtems_clock_get_tod_timeval( &tv ); if ( status == RTEMS_SUCCESSFUL ) { puts( "TA1 - rtems_clock_get_tod_timeval - RTEMS_NOT_DEFINED -- " "DID BSP SET THE TIME OF DAY?" ); } else { fatal_directive_status( status, RTEMS_NOT_DEFINED, "rtems_clock_get_timeval" ); puts( "TA1 - rtems_clock_get_tod_timeval - RTEMS_NOT_DEFINED" ); } /* NULL parameter */ status = rtems_clock_set( NULL ); fatal_directive_status( status, RTEMS_INVALID_ADDRESS, "rtems_clock_set sull pointer" ); puts( "TA1 - rtems_clock_set - RTEMS_INVALID_ADDRESS" ); build_time( &time, 2, 5, 1987, 8, 30, 45, 0 ); print_time( "TA1 - rtems_clock_set - ", &time, "" ); status = rtems_clock_set( &time ); fatal_directive_status( status, RTEMS_INVALID_CLOCK, "rtems_clock_set with invalid year" ); puts( " - RTEMS_INVALID_CLOCK" ); build_time( &time, 15, 5, 1988, 8, 30, 45, 0 ); print_time( "TA1 - rtems_clock_set - ", &time, "" ); status = rtems_clock_set( &time ); fatal_directive_status( status, RTEMS_INVALID_CLOCK, "rtems_clock_set with invalid month" ); puts( " - RTEMS_INVALID_CLOCK" ); build_time( &time, 2, 32, 1988, 8, 30, 45, 0 ); print_time( "TA1 - rtems_clock_set - ", &time, "" ); status = rtems_clock_set( &time ); fatal_directive_status( status, RTEMS_INVALID_CLOCK, "rtems_clock_set with invalid day" ); puts( " - RTEMS_INVALID_CLOCK" ); build_time( &time, 2, 5, 1988, 25, 30, 45, 0 ); print_time( "TA1 - rtems_clock_set - ", &time, "" ); status = rtems_clock_set( &time ); fatal_directive_status( status, RTEMS_INVALID_CLOCK, "rtems_clock_set with invalid hour" ); puts( " - RTEMS_INVALID_CLOCK" ); build_time( &time, 2, 5, 1988, 8, 61, 45, 0 ); print_time( "TA1 - rtems_clock_set - ", &time, "" ); status = rtems_clock_set( &time ); fatal_directive_status( status, RTEMS_INVALID_CLOCK, "rtems_clock_set with invalid minute" ); puts( " - RTEMS_INVALID_CLOCK" ); build_time( &time, 2, 5, 1988, 8, 30, 61, 0 ); print_time( "TA1 - rtems_clock_set - ", &time, "" ); status = rtems_clock_set( &time ); fatal_directive_status( status, RTEMS_INVALID_CLOCK, "rtems_clock_set with invalid second" ); puts( " - RTEMS_INVALID_CLOCK" ); build_time( &time, 2, 5, 1988, 8, 30, 45, rtems_clock_get_ticks_per_second() + 1 ); print_time( "TA1 - rtems_clock_set - ", &time, "" ); status = rtems_clock_set( &time ); fatal_directive_status( status, RTEMS_INVALID_CLOCK, "rtems_clock_set with invalid ticks per second" ); puts( " - RTEMS_INVALID_CLOCK" ); 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 successful" ); puts( " - RTEMS_SUCCESSFUL" ); rtems_clock_get_tod( &time ); print_time( "TA1 - current time - ", &time, "\n" ); TEST_END(); }
void test_adjtime(void) { int sc; rtems_status_code status; struct timeval delta; struct timeval olddelta; rtems_time_of_day *the_tod; rtems_time_of_day tod; rtems_interval ticks; the_tod = &Dates[0]; print_time( "rtems_clock_set ", the_tod, "\n" ); status = rtems_clock_set( the_tod ); rtems_test_assert( !status ); delta.tv_sec = 0; delta.tv_usec = 0; olddelta.tv_sec = 0; olddelta.tv_usec = 0; puts( "adjtime - NULL delta - EINVAL" ); sc = adjtime( NULL, &olddelta ); rtems_test_assert( sc == -1 ); rtems_test_assert( errno == EINVAL ); puts( "adjtime - delta out of range - EINVAL" ); delta.tv_usec = 1000000000; /* 100 seconds worth */ sc = adjtime( &delta, &olddelta ); rtems_test_assert( sc == -1 ); rtems_test_assert( errno == EINVAL ); puts( "adjtime - delta too small - do nothing" ); delta.tv_sec = 0; delta.tv_usec = 1; sc = adjtime( &delta, &olddelta ); rtems_test_assert( sc == 0 ); puts( "adjtime - delta too small - do nothing, olddelta=NULL" ); sc = adjtime( &delta, NULL ); rtems_test_assert( sc == 0 ); puts( "adjtime - delta of one second forward, olddelta=NULL" ); delta.tv_sec = 1; delta.tv_usec = 0; sc = adjtime( &delta, NULL ); rtems_test_assert( sc == 0 ); puts( "adjtime - delta of one second forward" ); delta.tv_sec = 1; delta.tv_usec = 0; sc = adjtime( &delta, &olddelta ); rtems_test_assert( sc == 0 ); puts( "adjtime - delta of almost two seconds forward" ); delta.tv_sec = 1; delta.tv_usec = 1000000 - 1; sc = adjtime( &delta, &olddelta ); rtems_test_assert( sc == 0 ); /* * spin until over 1/2 of the way to the */ ticks = rtems_clock_get_ticks_per_second(); rtems_test_assert( ticks ); ticks /= 2; do { status = rtems_clock_get_tod( &tod ); rtems_test_assert( !status ); } while ( tod.ticks <= ticks ); puts( "adjtime - delta of almost one second forward which bumps second" ); delta.tv_sec = 0; delta.tv_usec = 1000000 - 1; sc = adjtime( &delta, &olddelta ); rtems_test_assert( sc == 0 ); status = rtems_clock_get_tod( &tod ); rtems_test_assert( !status ); print_time( "rtems_clock_get_tod ", &tod, "\n" ); }
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 ); }