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 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 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" ); } }
epos_task Task_1_through_3( epos_task_argument argument ) { epos_id tid; epos_time_of_day time; epos_status_code status; status = epos_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid ); directive_failed( status, "epos_task_ident" ); while( FOREVER ) { status = epos_clock_get( RTEMS_CLOCK_GET_TOD, &time ); directive_failed( status, "epos_clock_get" ); if ( time.second >= 35 ) { printk( "*** END OF TEST 1 ***" ); epos_test_exit( 0 ); } put_name( Task_name[ task_number( tid ) ], FALSE ); print_time( " - epos_clock_get - ", &time, "\n" ); // status = epos_task_wake_after( task_number( tid ) * 5 * TICKS_PER_SECOND ); status = epos_task_wake_after( task_number( tid ) * 5); directive_failed( status, "epos_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_fire_after( Timer_id[ argument ], task_number( tid ) * 5 * TICKS_PER_SECOND, Resume_task, NULL ); directive_failed( status, "tm_fire_after failed" ); status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time ); directive_failed( status, "rtems_clock_get failed" ); if ( time.second >= 35 ) { puts( "*** END OF TEST 24 ***" ); rtems_test_exit( 0 ); } put_name( Task_name[ task_number( tid ) ], FALSE ); print_time( " - rtems_clock_get - ", &time, "\n" ); status = rtems_task_suspend( RTEMS_SELF ); directive_failed( status, "rtems_task_suspend" ); } }
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_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 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" ); } }
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_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 showTaskSwitches (void) { int i; int switches = taskSwitchLogIndex; for (i = 0 ; i < switches ; i++) { put_name( Task_name[taskSwitchLog[i].taskIndex], FALSE ); print_time( "- ", &taskSwitchLog[i].when, "\n" ); } }
rtems_task Test_task( rtems_task_argument argument ) { rtems_id tid; rtems_status_code status; status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid ); directive_failed( status, "rtems_task_ident" ); puts( "Getting TID of remote task" ); remote_node = (Multiprocessing_configuration.node == 1) ? 2 : 1; printf( "Remote task's name is : " ); put_name( Task_name[ remote_node ], TRUE ); do { status = rtems_task_ident( Task_name[ remote_node ], RTEMS_SEARCH_ALL_NODES, &remote_tid ); } while ( status != RTEMS_SUCCESSFUL ); directive_failed( status, "rtems_task_ident" ); status = rtems_timer_fire_after( Timer_id[ 1 ], 5 * rtems_clock_get_ticks_per_second(), Delayed_send_event, NULL ); directive_failed( status, "rtems_timer_fire_after" ); Test_Task_Support( 1 ); status = rtems_timer_fire_after( Timer_id[ 1 ], 5 * rtems_clock_get_ticks_per_second(), Delayed_send_event, NULL ); directive_failed( status, "rtems_timer_fire_after" ); if ( Multiprocessing_configuration.node == 1 ) { status = rtems_task_wake_after( 2 * rtems_clock_get_ticks_per_second() ); directive_failed( status, "rtems_task_wake_after" ); } Test_Task_Support( 2 ); puts( "*** END OF TEST 3 ***" ); rtems_test_exit( 0 ); }
rtems_extension Task_exit_extension( rtems_tcb *running_task ) { if ( task_number( running_task->Object.id ) > 0 ) { puts_nocr( "RTEMS_TASK_EXITTED - extension invoked for " ); put_name( Task_name[ task_number( running_task->Object.id ) ], TRUE ); } puts("*** END OF TEST 7 ***" ); rtems_test_exit( 0 ); }
PRIVATE void put_storage P1 (SYM *, sp) { SIZE al = alignment_of_type (typeof (sp)); put_bseg (al); if (is_static (sp)) { put_label (sp->value.l); } else { put_name (sp); } oprintf ("\t.space\t%ld%s", typeof (sp)->size, newline); }
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 Test_task( rtems_task_argument index ) { rtems_status_code status; rtems_name name; status = rtems_object_get_classic_name( rtems_task_self(), &name ); directive_failed( status, "rtems_object_get_classic_name" ); put_name( name, FALSE ); puts( " - Successfully yielded it to higher priority task" ); puts( "*** END OF SP76 TEST ***" ); rtems_test_exit( 0 ); }
static rtems_task Locker_task( rtems_task_argument task_index ) { rtems_id tid; rtems_status_code status; rtems_task_argument my_obtain_counter; status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid ); directive_failed( status, "rtems_task_ident" ); rtems_test_assert( task_index == task_number( tid ) - 1 ); status = rtems_semaphore_obtain( Semaphore, RTEMS_DEFAULT_OPTIONS, 0 ); directive_failed( status, "rtems_semaphore_obtain" ); put_name( Task_name[ task_index ], FALSE ); puts( " - unblocked - OK" ); status = rtems_task_wake_after( 10 ); directive_failed( status, "rtems_task_wake_after" ); my_obtain_counter = Obtain_counter; rtems_test_assert( task_index == Obtain_order[ Variant ][ Obtain_counter ] ); ++Obtain_counter; status = rtems_semaphore_release( Semaphore ); directive_failed( status, "rtems_semaphore_release" ); if ( my_obtain_counter == MAX_TASKS - 1 ) { status = rtems_event_transient_send( Master ); directive_failed( status, "rtems_event_transient_send" ); } (void) rtems_task_delete( RTEMS_SELF ); }
rtems_task Tasks_Aperiodic( rtems_task_argument argument ) { rtems_status_code status; int start; int stop; int now; put_name( Task_name[ argument ], FALSE ); status = rtems_task_wake_after( 2 + Phases[argument] ); directive_failed( status, "rtems_task_wake_after" ); if ( argument == 6 ) { rtems_task_suspend( Task_id[5] ); rtems_task_resume( Task_id[5] ); } rtems_clock_get(RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &start); printf("AT%" PRIdPTR "-S ticks:%d\n", argument, start); /* active computing */ while(FOREVER) { rtems_clock_get(RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &now); if (now >= start + Execution[argument]) break; } rtems_clock_get(RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &stop); printf("P%" PRIdPTR "-F ticks:%d\n", argument, stop); /* delete SELF */ fflush(stdout); printf( "Killing task %" PRIdPTR "\n", argument); status = rtems_task_delete(RTEMS_SELF); directive_failed(status, "rtems_task_delete of RTEMS_SELF"); }
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%x)\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 = -1; while( FOREVER ) { status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time ); directive_failed( status, "rtems_clock_get" ); 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 - ", &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( TICKS_PER_SECOND ); directive_failed( status, "rtems_task_wake_after" ); } } }
void reset_init(void) { /* send the reset and init strings */ int i; ptext("Terminal reset"); i = char_count; put_name(reset_1string, " (rs1)"); put_name(reset_2string, " (rs2)"); /* run the reset file */ if (reset_file && reset_file[0]) { FILE *fp; int ch; can_test("rf", FLAG_TESTED); if ((fp = fopen(reset_file, "r"))) { /* send the reset file */ sprintf(temp, " (rf) %s", reset_file); ptextln(temp); while (1) { ch = getc(fp); if (ch == EOF) break; put_this(ch); } fclose(fp); } else { sprintf(temp, "\nCannot open reset file (rf) %s", reset_file); ptextln(temp); } } put_name(reset_3string, " (rs3)"); if (i != char_count) { put_crlf(); } ptext(" init"); put_name(init_1string, " (is1)"); put_name(init_2string, " (is2)"); if (set_tab && clear_all_tabs && init_tabs != 8) { put_crlf(); tc_putp(clear_all_tabs); for (char_count = 0; char_count < columns; char_count++) { put_this(' '); if ((char_count & 7) == 7) { tc_putp(set_tab); } } put_cr(); } /* run the initialization file */ if (init_file && init_file[0]) { FILE *fp; int ch; can_test("if", FLAG_TESTED); if ((fp = fopen(init_file, "r"))) { /* send the init file */ sprintf(temp, " (if) %s", init_file); ptextln(temp); while (1) { ch = getc(fp); if (ch == EOF) break; put_this(ch); } fclose(fp); } else { sprintf(temp, "\nCannot open init file (if) %s", init_file); ptextln(temp); } } if (init_prog) { can_test("iprog", FLAG_TESTED); (void) system(init_prog); } put_name(init_3string, " (is3)"); fflush(stdout); }
void Test_Task_Support( uint32_t node ) { rtems_event_set events; rtems_status_code status; if ( Multiprocessing_configuration.node == node ) { for ( ; ; ) { status = rtems_event_receive( RTEMS_EVENT_16, RTEMS_NO_WAIT, RTEMS_NO_TIMEOUT, &events ); if ( status == RTEMS_SUCCESSFUL ) break; fatal_directive_status(status, RTEMS_UNSATISFIED, "rtems_event_receive"); status = rtems_task_wake_after( 2 * rtems_clock_get_ticks_per_second() ); directive_failed( status, "rtems_task_wake_after" ); put_name( Task_name[ node ], FALSE ); puts( " - Suspending remote task" ); status = rtems_task_suspend( remote_tid ); directive_failed( status, "rtems_task_suspend" ); status = rtems_task_wake_after( 2 * rtems_clock_get_ticks_per_second() ); directive_failed( status, "rtems_task_wake_after" ); put_name( Task_name[ node ], FALSE ); puts( " - Resuming remote task" ); status = rtems_task_resume( remote_tid ) ; directive_failed( status, "rtems_task_resume" ); } } else { for ( ; ; ) { status = rtems_event_receive( RTEMS_EVENT_16, RTEMS_NO_WAIT, RTEMS_NO_TIMEOUT, &events ); if ( status == RTEMS_SUCCESSFUL ) break; fatal_directive_status(status, RTEMS_UNSATISFIED, "rtems_event_receive"); put_name( Task_name[ remote_node ], FALSE ); puts( " - have I been suspended???" ); status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() / 2 ); directive_failed( status, "rtems_task_wake_after" ); } } }
rtems_task Test_task( rtems_task_argument argument ) { rtems_status_code status; uint32_t count; uint32_t remote_node; rtems_id remote_tid; rtems_event_set event_out; rtems_event_set event_for_this_iteration; Stop_Test = FALSE; remote_node = (Multiprocessing_configuration.node == 1) ? 2 : 1; puts_nocr( "Remote task's name is : " ); put_name( Task_name[ remote_node ], TRUE ); puts( "Getting TID of remote task" ); do { status = rtems_task_ident( Task_name[ remote_node ], RTEMS_SEARCH_ALL_NODES, &remote_tid ); } while ( status != RTEMS_SUCCESSFUL ); directive_failed( status, "rtems_task_ident FAILED!!" ); if ( Multiprocessing_configuration.node == 1 ) puts( "Sending events to remote task" ); else puts( "Receiving events from remote task" ); status = rtems_timer_fire_after( Timer_id[ 1 ], 5 * TICKS_PER_SECOND, Stop_Test_TSR, NULL ); directive_failed( status, "rtems_timer_fire_after" ); count = 0; for ( ; ; ) { if ( Stop_Test == TRUE ) break; event_for_this_iteration = Event_set_table[ count % 32 ]; if ( Multiprocessing_configuration.node == 1 ) { status = rtems_event_send( remote_tid, event_for_this_iteration ); directive_failed( status, "rtems_event_send" ); status = rtems_task_wake_after( 1 ); directive_failed( status, "rtems_task_wake_after" ); } else { status = rtems_event_receive( event_for_this_iteration, RTEMS_DEFAULT_OPTIONS, 1 * TICKS_PER_SECOND, &event_out ); if ( rtems_are_statuses_equal( status, RTEMS_TIMEOUT ) ) { if ( Multiprocessing_configuration.node == 2 ) puts( "\nCorrect behavior if the other node exitted." ); else puts( "\nERROR... node 1 died" ); break; } else directive_failed( status, "rtems_event_receive" ); } if ( (count % DOT_COUNT) == 0 ) put_dot('.'); count++; } putchar( '\n' ); if ( Multiprocessing_configuration.node == 2 ) { status = rtems_event_receive( RTEMS_EVENT_16, RTEMS_DEFAULT_OPTIONS, 1 * TICKS_PER_SECOND, &event_out ); fatal_directive_status( status, RTEMS_TIMEOUT, "rtems_event_receive" ); puts( "rtems_event_receive - correctly returned RTEMS_TIMEOUT" ); } puts( "*** END OF TEST 6 ***" ); rtems_test_exit( 0 ); }
void write_as_matrix(char **file, char *x, int *N, int *M, char **rnames, char **cnames, int *asalleles, int *append, int *quote, char **sep, char **eol, char **na, int *row_names, int *col_names, int *iferror) { int zerom = (int) '0' -1 ; /* Character code for zero ... minus 1 */ int nrow = *N; int ncol = *M; FILE * outfile; int i=0, j=0, ij=0; if (*append) outfile = fopen(*file, "a"); else outfile = fopen(*file, "w"); if (!outfile) { *iferror = 1; return; } if (*col_names) { for (i=0; i<ncol; i++) { if (i) fputs(*sep, outfile); put_name(outfile, cnames[i], *quote); } fputs(*eol, outfile); } for (i=0; i<nrow; i++) { if (*row_names) { put_name(outfile, rnames[i], *quote); fputs(*sep, outfile); } for (j=0, ij=i; j<ncol; j++, ij+=nrow) { if (j) fputs(*sep, outfile); int g = (int) x[ij]; if (*asalleles) { if (!g) { fputs(*na, outfile); fputs(*sep, outfile); fputs(*na, outfile); } else { fputc(g<3? '1': '2', outfile); fputs(*sep, outfile); fputc(g<2? '1': '2', outfile); } } else { if (!g) fputs(*na, outfile); else { g += zerom; fputc((char) g, outfile); } } } fputs(*eol, outfile); } fclose(outfile); *iferror = 0; return; }
rtems_task Tasks_Periodic( rtems_task_argument argument ) { rtems_id rmid; rtems_id test_rmid; rtems_status_code status; bool scenario_done = 0; int start, stop, now; rtems_cbs_server_id server_id, tsid; rtems_cbs_parameters params, tparams; params.deadline = Periods[ argument ]; params.budget = Execution[ argument ]+1; if ( argument == 4 ) { if ( rtems_cbs_create_server( ¶ms, &overrun_handler_task_4, &server_id )) printf( "ERROR: CREATE SERVER FAILED\n" ); } else { if ( rtems_cbs_create_server( ¶ms, NULL, &server_id ) ) printf( "ERROR: CREATE SERVER FAILED\n" ); } if ( rtems_cbs_attach_thread( server_id, Task_id[ argument ] ) ) printf( "ERROR: ATTACH THREAD FAILED\n" ); if ( rtems_cbs_get_server_id( Task_id[ argument ], &tsid ) ) printf( "ERROR: GET SERVER ID FAILED\n" ); if ( tsid != server_id ) printf( "ERROR: SERVER ID MISMATCH\n" ); if ( rtems_cbs_get_parameters( server_id, &tparams ) ) printf( "ERROR: GET PARAMETERS FAILED\n" ); if ( params.deadline != tparams.deadline || params.budget != tparams.budget ) printf( "ERROR: PARAMETERS MISMATCH\n" ); status = rtems_rate_monotonic_create( argument, &rmid ); directive_failed( status, "rtems_rate_monotonic_create" ); put_name( Task_name[ argument ], FALSE ); printf( "- rtems_rate_monotonic_create id = 0x%08" PRIxrtems_id "\n", rmid ); status = rtems_rate_monotonic_ident( argument, &test_rmid ); directive_failed( status, "rtems_rate_monotonic_ident" ); put_name( Task_name[ argument ], FALSE ); printf( "- rtems_rate_monotonic_ident id = 0x%08" PRIxrtems_id "\n", test_rmid ); if ( rmid != test_rmid ) { printf( "RMID's DO NOT MATCH (0x%" PRIxrtems_id " and 0x%" PRIxrtems_id ")\n", rmid, test_rmid ); rtems_test_exit( 0 ); } put_name( Task_name[ argument ], FALSE ); printf( "- (0x%08" PRIxrtems_id ") period %" PRIu32 "\n", rmid, Periods[ argument ] ); status = rtems_task_wake_after( 2 + Phases[argument] ); directive_failed( status, "rtems_task_wake_after" ); while (FOREVER) { if (rtems_rate_monotonic_period(rmid, Periods[argument])==RTEMS_TIMEOUT) printf("P%" PRIdPTR " - Deadline miss\n", argument); start = rtems_clock_get_ticks_since_boot(); printf("P%" PRIdPTR "-S ticks:%d\n", argument, start); if ( start >= 2*HP_LENGTH ) break; /* stop */ /* Specific scenario for task 4: tries to exceed announced budget, the task priority has to be pulled down to background. */ now = rtems_clock_get_ticks_since_boot(); if ( !scenario_done && argument == 4 && now >= 200 ) { Violating_task[ argument ] = 1; scenario_done = 1; } /* Specific scenario for task 3: changes scheduling parameters. */ if ( !scenario_done && argument == 3 && now >= 250 ) { Periods[ argument ] = Periods[ argument ] * 2; Execution[ argument ] = Execution[ argument ] * 2; params.deadline = Periods[ argument ]; params.budget = Execution[ argument ]+1; if ( rtems_cbs_set_parameters( server_id, ¶ms) ) printf( "ERROR: SET PARAMETERS FAILED\n" ); if ( rtems_cbs_get_parameters( server_id, &tparams ) ) printf( "ERROR: GET PARAMETERS FAILED\n" ); if ( params.deadline != tparams.deadline || params.budget != tparams.budget ) printf( "ERROR: PARAMETERS MISMATCH\n" ); scenario_done = 1; } /* Specific scenario for task 2: late unblock after being blocked by itself, the task priority has to be pulled down to background. */ if ( !scenario_done && argument == 2 && now >= 500 ) { Violating_task[ argument ] = 1; scenario_done = 1; } if (argument == 2 && Violating_task[ argument ]) rtems_task_wake_after( 10 ); /* active computing */ while(FOREVER) { now = rtems_clock_get_ticks_since_boot(); if ( argument == 4 && !Violating_task[ argument ] && (now >= start + Execution[argument])) break; if ( argument != 4 && (now >= start + Execution[argument]) ) break; } stop = rtems_clock_get_ticks_since_boot(); printf("P%" PRIdPTR "-F ticks:%d\n", argument, stop); } /* delete period and SELF */ status = rtems_rate_monotonic_delete( rmid ); if ( status != RTEMS_SUCCESSFUL ) { printf("rtems_rate_monotonic_delete failed with status of %d.\n",status); rtems_test_exit( 0 ); } if ( rtems_cbs_cleanup() ) printf( "ERROR: CBS CLEANUP\n" ); fflush(stdout); TEST_END(); rtems_test_exit( 0 ); }
rtems_task Task_1_through_6( rtems_task_argument argument ) { rtems_id rmid; rtems_id test_rmid; int index; int pass; uint32_t failed; rtems_status_code status; status = rtems_rate_monotonic_create( argument, &rmid ); directive_failed( status, "rtems_rate_monotonic_create" ); put_name( Task_name[ argument ], FALSE ); printf( "- rtems_rate_monotonic_create id = 0x%08" PRIxrtems_id "\n", rmid ); status = rtems_rate_monotonic_ident( argument, &test_rmid ); directive_failed( status, "rtems_rate_monotonic_ident" ); put_name( Task_name[ argument ], FALSE ); printf( "- rtems_rate_monotonic_ident id = 0x%08" PRIxrtems_id "\n", test_rmid ); if ( rmid != test_rmid ) { printf( "RMID's DO NOT MATCH (0x%" PRIxrtems_id " and 0x%" PRIxrtems_id ")\n", rmid, test_rmid ); rtems_test_exit( 0 ); } put_name( Task_name[ argument ], FALSE ); printf( "- (0x%08" PRIxrtems_id ") period %" PRIu32 "\n", rmid, Periods[ argument ] ); status = rtems_task_wake_after( 2 ); directive_failed( status, "rtems_task_wake_after" ); switch ( argument ) { case 1: case 2: case 3: case 4: while ( FOREVER ) { status = rtems_rate_monotonic_period( rmid, Periods[ argument ] ); directive_failed( status, "rtems_rate_monotonic_period" ); Count.count[ argument ]++; } break; case 5: pass = 0; failed = 0; status = rtems_rate_monotonic_period( rmid, Periods[ argument ] ); directive_failed( status, "rtems_rate_monotonic_period 1 of TA5" ); Get_all_counters(); while ( FOREVER ) { status = rtems_rate_monotonic_period( rmid, Periods[ argument ] ); directive_failed( status, "rtems_rate_monotonic_period 2 of TA5" ); Get_all_counters(); for( index = 1 ; index <= 4 ; index++ ) { if ( Temporary_count.count[ index ] != Iterations[ index ] ) { puts_nocr( "FAIL -- " ); put_name ( Task_name[ index ], FALSE ); printf ( " Actual=%" PRIu32 ", Expected=%" PRIu32 "\n", Temporary_count.count[ index ], Iterations[ index ] ); failed += 1; } } if ( failed == 5 ) rtems_test_exit( 0 ); pass += 1; printf( "TA5 - PERIODS CHECK OK (%d)\n", pass ); fflush( stdout ); if ( pass == 10 ) { TEST_END(); rtems_test_exit( 0 ); } } break; case 6: /* test changing periods */ { uint32_t time[TA6_ITERATIONS+1]; rtems_interval period; period = 1*TA6_PERIOD_FACTOR; status = rtems_rate_monotonic_period( rmid, period); directive_failed( status, "rtems_rate_monotonic_period of TA6" ); time[0] = _Watchdog_Ticks_since_boot; /* timestamp */ /*printf("%d - %d\n", period, time[0]);*/ for (index = 1; index <= TA6_ITERATIONS; index++) { period = (index+1)*TA6_PERIOD_FACTOR; status = rtems_rate_monotonic_period( rmid, period); directive_failed( status, "rtems_rate_monotonic_period of TA6" ); time[index] = _Watchdog_Ticks_since_boot; /* timestamp */ /*printf("%d - %d\n", period, time[index]);*/ } for (index = 1; index <= TA6_ITERATIONS; index++) { rtems_interval meas = time[index] - time[index-1]; period = index*TA6_PERIOD_FACTOR; printf( "TA6 - Actual: %" PRIdrtems_interval " Expected: %" PRIdrtems_interval, meas, period ); if (period == meas) printf(" - OK\n"); else printf(" - FAILED\n"); } } rtems_task_suspend(RTEMS_SELF); break; } }
rtems_task Task_1_through_5( rtems_task_argument argument ) { rtems_id rmid; rtems_id test_rmid; uint32_t index; uint32_t pass; uint32_t failed; rtems_status_code status; status = rtems_rate_monotonic_create( argument, &rmid ); directive_failed( status, "rtems_rate_monotonic_create" ); put_name( Task_name[ argument ], FALSE ); printf( "- rtems_rate_monotonic_create id = 0x%08" PRIxrtems_id "\n", rmid ); status = rtems_rate_monotonic_ident( argument, &test_rmid ); directive_failed( status, "rtems_rate_monotonic_ident" ); put_name( Task_name[ argument ], FALSE ); printf( "- rtems_rate_monotonic_ident id = 0x%08" PRIxrtems_id "\n", test_rmid ); if ( rmid != test_rmid ) { printf( "RMID's DO NOT MATCH (0x%" PRIxrtems_id " and 0x%" PRIxrtems_id ")\n", rmid, test_rmid ); rtems_test_exit( 0 ); } put_name( Task_name[ argument ], FALSE ); printf( "- (0x%08" PRIxrtems_id ") period %" PRIu32 "\n", rmid, Periods[ argument ] ); status = rtems_task_wake_after( 2 ); directive_failed( status, "rtems_task_wake_after" ); switch ( argument ) { case 1: case 2: case 3: case 4: while ( FOREVER ) { status = rtems_rate_monotonic_period( rmid, Periods[ argument ] ); directive_failed( status, "rtems_rate_monotonic_period" ); Count.count[ argument ]++; } break; case 5: pass = 0; failed = 0; status = rtems_rate_monotonic_period( rmid, Periods[ argument ] ); directive_failed( status, "rtems_rate_monotonic_period 1 of TA5" ); Get_all_counters(); while ( FOREVER ) { status = rtems_rate_monotonic_period( rmid, Periods[ argument ] ); directive_failed( status, "rtems_rate_monotonic_period 2 of TA5" ); Get_all_counters(); for( index = 1 ; index <= 4 ; index++ ) { if ( Temporary_count.count[ index ] != Iterations[ index ] ) { puts_nocr( "FAIL -- " ); put_name ( Task_name[ index ], FALSE ); printf ( " Actual=%" PRIu32 ", Expected=%" PRIu32 "\n", Temporary_count.count[ index ], Iterations[ index ] ); failed += 1; } } if ( failed == 5 ) rtems_test_exit( 0 ); pass += 1; printf( "TA5 - PERIODS CHECK OK (%" PRIu32 ")\n", pass ); FLUSH_OUTPUT(); if ( pass == 10 ) { puts( "" ); rtems_rate_monotonic_report_statistics(); rtems_rate_monotonic_reset_statistics( rmid ); puts( "" ); puts( "TA5 - PERIOD STATISTICS RESET" ); puts( "" ); rtems_rate_monotonic_report_statistics(); rtems_rate_monotonic_reset_all_statistics(); puts( "" ); puts( "TA5 - ALL PERIOD STATISTICS RESET" ); puts( "" ); rtems_rate_monotonic_report_statistics(); puts( "" ); puts( "*** END OF RATE MONOTONIC PERIOD STATISTICS TEST ***" ); rtems_test_exit( 0 ); } } break; } }
rtems_task Test_task( rtems_task_argument argument ) { rtems_status_code status; uint32_t count; uint32_t remote_node; rtems_id remote_tid; rtems_event_set event_out; remote_node = ((Multiprocessing_configuration.node == 1) ? 2 : 1); puts( "About to go to sleep!" ); status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() ); directive_failed( status, "rtems_task_wake_after" ); puts( "Waking up!" ); puts_nocr( "Remote task's name is : " ); put_name( Task_name[ remote_node ], TRUE ); puts( "Getting TID of remote task" ); while ( FOREVER ) { status = rtems_task_ident( Task_name[ remote_node ], RTEMS_SEARCH_ALL_NODES, &remote_tid ); if ( status == RTEMS_SUCCESSFUL ) break; puts( "rtems_task_ident FAILED!!" ); rtems_task_wake_after(2); } if ( Multiprocessing_configuration.node == 1 ) { puts( "Sending events to remote task" ); while ( Stop_Test == false ) { for ( count=EVENT_TASK_DOT_COUNT; Stop_Test == false && count; count-- ) { status = rtems_event_send( remote_tid, RTEMS_EVENT_16 ); directive_failed( status, "rtems_event_send" ); } put_dot( 'e' ); } } puts( "Receiving events from remote task" ); while ( Stop_Test == false ) { for ( count=EVENT_TASK_DOT_COUNT ; Stop_Test == false && count ; count-- ) { status = rtems_event_receive( RTEMS_EVENT_16, RTEMS_DEFAULT_OPTIONS, RTEMS_NO_TIMEOUT, &event_out ); directive_failed( status, "rtems_event_receive" ); } put_dot( 'e' ); } Exit_test(); }