static void setThreadInfo (rtems_id tid, const char *name, EPICSTHREADFUNC funptr,void *parm) { struct taskVar *v; uint32_t note; rtems_status_code sc; v = mallocMustSucceed (sizeof *v, "epicsThreadCreate_vars"); v->name = epicsStrDup(name); v->id = tid; v->funptr = funptr; v->parm = parm; v->threadVariableCapacity = 0; v->threadVariables = NULL; note = (uint32_t)v; rtems_task_set_note (tid, RTEMS_NOTEPAD_TASKVAR, note); taskVarLock (); v->forw = taskVarHead; v->back = NULL; if (v->forw) v->forw->back = v; taskVarHead = v; taskVarUnlock (); if (funptr) { sc = rtems_task_start (tid, threadWrapper, (rtems_task_argument)v); if (sc != RTEMS_SUCCESSFUL) errlogPrintf ("setThreadInfo: Can't start %s: %s\n",name, rtems_status_text (sc)); } }
rtems_task Task_2( rtems_task_argument argument ) { rtems_status_code status; rtems_task_priority the_priority; rtems_task_priority previous_priority; while( FOREVER ) { status = rtems_task_get_note( RTEMS_SELF, RTEMS_NOTEPAD_8, &the_priority ); directive_failed( status, "rtems_task_get_note" ); printf( "TA2 - rtems_task_get_note - get RTEMS_NOTEPAD_8 - current priority: %02" PRIdrtems_task_priority "\n", the_priority ); if ( --the_priority == 0 ) { puts( "TA2 - rtems_task_suspend - suspend TA1" ); status = rtems_task_suspend( Task_id[ 1 ] ); directive_failed( status, "rtems_task_suspend" ); puts( "TA2 - rtems_task_set_priority - set priority of TA1 ( blocked )" ); status = rtems_task_set_priority( Task_id[ 1 ], 5, &previous_priority ); directive_failed( status, "rtems_task_set_priority" ); status = rtems_task_delete( Task_id[ 1 ] ); /* TA1 is blocked */ directive_failed( status, "rtems_task_delete of TA1" ); status = rtems_task_delete( Task_id[ 3 ] ); /* TA3 is ready */ directive_failed( status, "rtems_task_delete of TA3" ); status = rtems_task_delete( RTEMS_SELF ); directive_failed( status, "rtems_task_delete of SELD" ); } else { printf( "TA2 - rtems_task_set_note - set TA1's RTEMS_NOTEPAD_8: %02" PRIdrtems_task_priority "\n", the_priority ); status = rtems_task_set_note(Task_id[ 1 ], RTEMS_NOTEPAD_8, the_priority); directive_failed( status, "rtems_task_set_note" ); printf( "TA2 - rtems_task_set_priority - set TA1's priority: %02" PRIdrtems_task_priority "\n", the_priority ); status = rtems_task_set_priority( Task_id[ 1 ], the_priority, &previous_priority ); directive_failed( status, "rtems_task_set_priority" ); } } }
rtems_task Init( rtems_task_argument ignored ) { rtems_status_code status; TEST_BEGIN(); status = rtems_task_set_note( rtems_task_self(), RTEMS_NOTEPAD_4, 32 ); directive_failed( status, "task_set_node of Self id" ); printf( "INIT - rtems_task_set_note - set my (id) RTEMS_NOTEPAD_4 " ); puts ( "to TA1's priority: 04" ); status = rtems_task_set_note( RTEMS_SELF, RTEMS_NOTEPAD_4, 32 ); directive_failed( status, "task_set_node of Self 0" ); printf( "INIT - rtems_task_set_note - set my (SELF) RTEMS_NOTEPAD_4 " ); puts ( "to TA1's priority: 04" ); TEST_END(); rtems_test_exit(0); }
rtems_task Init( rtems_task_argument argument ) { rtems_status_code status; rtems_id id; TEST_BEGIN(); Extension_name[ 1 ] = rtems_build_name( 'E', 'X', 'T', '1' ); Extension_name[ 2 ] = rtems_build_name( 'E', 'X', 'T', '2' ); puts ( "rtems_extension_create - bad id pointer -- RTEMS_INVALID_ADDRESS" ); status = rtems_extension_create( 0xa5a5a5a5, &Extensions, NULL ); fatal_directive_status( status, RTEMS_INVALID_ADDRESS, "rtems_extension_create" ); puts ( "rtems_extension_create - bad name -- RTEMS_INVALID_NAME" ); status = rtems_extension_create( 0, &Extensions, &id ); fatal_directive_status( status, RTEMS_INVALID_NAME, "rtems_extension_create #1" ); puts( "rtems_extension_create - first one -- OK" ); status = rtems_extension_create( Extension_name[ 1 ], &Extensions, &Extension_id[ 1 ] ); directive_failed( status, "rtems_extension_create" ); puts( "rtems_extension_create - second one-- OK" ); status = rtems_extension_create( Extension_name[ 2 ], &Extensions, &Extension_id[ 2 ] ); directive_failed( status, "rtems_extension_create #2" ); puts ( "rtems_extension_create -- RTEMS_TOO_MANY" ); status = rtems_extension_create( 0xa5a5a5a5, &Extensions, &id ); fatal_directive_status( status, RTEMS_TOO_MANY, "rtems_extension_create" ); puts( "rtems_extension_delete - second one -- OK" ); status = rtems_extension_delete( Extension_id[ 2 ] ); directive_failed( status, "rtems_extension_delete #2" ); puts( "rtems_extension_delete - second one again -- RTEMS_INVALID_ID" ); status = rtems_extension_delete( Extension_id[ 2 ] ); fatal_directive_status( status, RTEMS_INVALID_ID, "rtems_extension_delete #2 bad" ); puts ( "rtems_extension_ident -- OK" ); status = rtems_extension_ident( Extension_name[1], &id ); directive_failed( status, "rtems_extension_ident" ); puts ( "rtems_extension_ident - bad name -- RTEMS_INVALID_NAME" ); status = rtems_extension_ident( Extension_name[2], &id ); fatal_directive_status( status, RTEMS_INVALID_NAME, "rtems_extension_ident" ); puts ( "rtems_extension_ident - bad name -- RTEMS_INVALID_ADDRESS" ); status = rtems_extension_ident( Extension_name[2], NULL ); fatal_directive_status( status, RTEMS_INVALID_ADDRESS, "rtems_extension_ident" ); puts( "rtems_extension_create - harmless -- OK" ); status = rtems_extension_create( Extension_name[ 2 ], &Harmless_extensions, &Extension_id[ 2 ] ); directive_failed( status, "rtems_extension_create #3" ); Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' ); Task_name[ 2 ] = rtems_build_name( 'T', 'A', '2', ' ' ); Task_name[ 3 ] = rtems_build_name( 'T', 'A', '3', ' ' ); Task_name[ 4 ] = rtems_build_name( 'T', 'A', '4', ' ' ); status = rtems_task_create( Task_name[ 1 ], 4, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] ); directive_failed( status, "rtems_task_create of TA1" ); assert_extension_counts( &Task_created[ 0 ], 0x2 ); status = rtems_task_create( Task_name[ 2 ], 4, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 2 ] ); directive_failed( status, "rtems_task_create of TA2" ); assert_extension_counts( &Task_created[ 0 ], 0x2 | 0x4 ); #define TA3_PRIORITY (RTEMS_MAXIMUM_PRIORITY - 4u) status = rtems_task_create( Task_name[ 3 ], TA3_PRIORITY, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 3 ] ); directive_failed( status, "rtems_task_create of TA3" ); assert_extension_counts( &Task_created[ 0 ], 0x2 | 0x4 | 0x8 ); #define TA4_PRIORITY (RTEMS_MAXIMUM_PRIORITY - 1u) status = rtems_task_create( Task_name[ 4 ], TA4_PRIORITY, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 4 ] ); directive_failed( status, "rtems_task_create of TA4" ); assert_extension_counts( &Task_created[ 0 ], 0x2 | 0x4 | 0x8 | 0x10 ); status = rtems_task_start( Task_id[ 1 ], Task_1, 0 ); directive_failed( status, "rtems_task_start of TA1" ); assert_extension_counts( &Task_started[ 0 ], 0x2 ); status = rtems_task_start( Task_id[ 2 ], Task_2, 0 ); directive_failed( status, "rtems_task_start of TA2" ); assert_extension_counts( &Task_started[ 0 ], 0x2 | 0x4 ); status = rtems_task_start( Task_id[ 3 ], Task_3, 0 ); directive_failed( status, "rtems_task_start of TA3" ); assert_extension_counts( &Task_started[ 0 ], 0x2 | 0x4 | 0x8 ); status = rtems_task_start( Task_id[ 4 ], Task_4, 0 ); directive_failed( status, "rtems_task_start of TA4" ); assert_extension_counts( &Task_started[ 0 ], 0x2 | 0x4 | 0x8 | 0x10 ); status = rtems_task_restart( Task_id[ 2 ], 0 ); directive_failed( status, "rtems_task_restart of TA3" ); assert_extension_counts( &Task_restarted[ 0 ], 0x0 ); status = rtems_task_set_note( rtems_task_self(), RTEMS_NOTEPAD_4, 32 ); directive_failed( status, "task_set_node of Self id" ); printf( "INIT - rtems_task_set_note - set my (id) RTEMS_NOTEPAD_4 " ); puts ( "to TA1's priority: 04" ); status = rtems_task_set_note( RTEMS_SELF, RTEMS_NOTEPAD_4, 32 ); directive_failed( status, "task_set_node of Self 0" ); printf( "INIT - rtems_task_set_note - set my (SELF) RTEMS_NOTEPAD_4 " ); puts ( "to TA1's priority: 04" ); status = rtems_task_set_note( Task_id[ 1 ], RTEMS_NOTEPAD_8, 4 ); directive_failed( status, "task_set_node of TA1" ); printf( "INIT - rtems_task_set_note - set TA1's RTEMS_NOTEPAD_8 " ); puts ( "to TA1's priority: 04" ); status = rtems_task_set_note( Task_id[ 2 ], RTEMS_NOTEPAD_8, 4 ); directive_failed( status, "task_set_node of TA2" ); printf( "INIT - rtems_task_set_note - set TA2's RTEMS_NOTEPAD_8 " ); puts ( "to TA2's priority: 04"); status = rtems_task_delete( RTEMS_SELF ); directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); }
void Screen1() { uint32_t notepad_value; rtems_id self_id; rtems_task_priority previous_priority; rtems_status_code status; /* bad Id */ status = rtems_task_is_suspended( 100 ); fatal_directive_status( status, RTEMS_INVALID_ID, "rtems_task_set_priority with illegal id" ); puts( "TA1 - rtems_task_is_suspended - RTEMS_INVALID_ID" ); /* bad Id */ status = rtems_task_delete( 100 ); fatal_directive_status( status, RTEMS_INVALID_ID, "rtems_task_delete with illegal id" ); puts( "TA1 - rtems_task_delete - RTEMS_INVALID_ID" ); /* NULL return */ status = rtems_task_get_note( RTEMS_SELF, RTEMS_NOTEPAD_FIRST, NULL ); fatal_directive_status( status, RTEMS_INVALID_ADDRESS, "rtems_task_get_note with NULL param" ); puts( "TA1 - rtems_task_get_note - RTEMS_INVALID_ADDRESS" ); /* note too high */ status = rtems_task_get_note( RTEMS_SELF, 100, ¬epad_value ); fatal_directive_status( status, RTEMS_INVALID_NUMBER, "rtems_task_get_note with illegal notepad" ); puts( "TA1 - rtems_task_get_note - RTEMS_INVALID_NUMBER" ); /* bad Id */ status = rtems_task_get_note( 100, RTEMS_NOTEPAD_LAST, ¬epad_value ); fatal_directive_status( status, RTEMS_INVALID_ID, "rtems_task_get_note with illegal id" ); puts( "TA1 - rtems_task_get_note - RTEMS_INVALID_ID" ); /* unused Id so invalid now */ status = rtems_task_get_note( _RTEMS_tasks_Information.maximum_id, RTEMS_NOTEPAD_LAST, ¬epad_value ); fatal_directive_status( status, RTEMS_INVALID_ID, "rtems_task_get_note with illegal id" ); puts( "TA1 - rtems_task_get_note - RTEMS_INVALID_ID" ); status = rtems_task_get_note( _RTEMS_tasks_Information.minimum_id + (3L<<OBJECTS_API_START_BIT), RTEMS_NOTEPAD_LAST, ¬epad_value ); fatal_directive_status( status, RTEMS_INVALID_ID, "rtems_task_get_note with illegal id" ); status = rtems_task_get_note( rtems_build_id( OBJECTS_CLASSIC_API, 2, 1, 1 ), RTEMS_NOTEPAD_LAST, ¬epad_value ); fatal_directive_status( status, RTEMS_INVALID_ID, "rtems_task_get_note with non-task ID" ); /* NULL param */ status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, NULL ); fatal_directive_status( status, RTEMS_INVALID_ADDRESS, "rtems_task_ident NULL param" ); puts( "TA1 - rtems_task_ident - RTEMS_INVALID_ADDRESS" ); /* OK */ status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &self_id ); directive_failed( status, "rtems_task_ident of self" ); if ( self_id != Task_id[ 1 ] ) { puts( "ERROR - rtems_task_ident - incorrect ID returned!" ); } puts( "TA1 - rtems_task_ident - current task RTEMS_SUCCESSFUL" ); status = rtems_task_ident( 100, RTEMS_SEARCH_ALL_NODES, &Junk_id ); fatal_directive_status( status, RTEMS_INVALID_NAME, "rtems_task_ident with illegal name (local)" ); puts( "TA1 - rtems_task_ident - global RTEMS_INVALID_NAME" ); status = rtems_task_ident( 100, 1, &Junk_id ); fatal_directive_status( status, RTEMS_INVALID_NAME, "rtems_task_ident with illegal name (global)" ); puts( "TA1 - rtems_task_ident - local RTEMS_INVALID_NAME" ); /* * This one case is different if MP is enabled/disabled. */ status = rtems_task_ident( 100, 2, &Junk_id ); #if defined(RTEMS_MULTIPROCESSING) fatal_directive_status( status, RTEMS_INVALID_NODE, "rtems_task_ident with illegal node" ); #else fatal_directive_status( status, RTEMS_INVALID_NAME, "rtems_task_ident with illegal node" ); #endif puts( "TA1 - rtems_task_ident - RTEMS_INVALID_NODE" ); status = rtems_task_restart( 100, 0 ); fatal_directive_status( status, RTEMS_INVALID_ID, "rtems_task_restart with illegal id" ); puts( "TA1 - rtems_task_restart - RTEMS_INVALID_ID" ); status = rtems_task_resume( 100 ); fatal_directive_status( status, RTEMS_INVALID_ID, "rtems_task_resume with illegal id" ); puts( "TA1 - rtems_task_resume - RTEMS_INVALID_ID" ); status = rtems_task_resume( RTEMS_SELF ); fatal_directive_status( status, RTEMS_INCORRECT_STATE, "rtems_task_resume of ready task" ); puts( "TA1 - rtems_task_resume - RTEMS_INCORRECT_STATE" ); /* NULL param */ status = rtems_task_set_priority( RTEMS_SELF, RTEMS_CURRENT_PRIORITY, NULL ); fatal_directive_status( status, RTEMS_INVALID_ADDRESS, "rtems_task_set_priority with NULL param" ); puts( "TA1 - rtems_task_set_priority - RTEMS_INVALID_ADDRESS" ); /* bad priority */ status = rtems_task_set_priority( RTEMS_SELF, 512, &previous_priority ); fatal_directive_status( status, RTEMS_INVALID_PRIORITY, "rtems_task_set_priority with illegal priority" ); puts( "TA1 - rtems_task_set_priority - RTEMS_INVALID_PRIORITY" ); /* bad Id */ status = rtems_task_set_priority( 100, 8, &previous_priority ); fatal_directive_status( status, RTEMS_INVALID_ID, "rtems_task_set_priority with illegal id" ); puts( "TA1 - rtems_task_set_priority - RTEMS_INVALID_ID" ); status = rtems_task_set_note( RTEMS_SELF, RTEMS_NOTEPAD_LAST+10, notepad_value ); fatal_directive_status( status, RTEMS_INVALID_NUMBER, "rtems_task_set_note with illegal notepad" ); puts( "TA1 - rtems_task_set_note - RTEMS_INVALID_NUMBER" ); status = rtems_task_set_note( 100, RTEMS_NOTEPAD_LAST, notepad_value ); fatal_directive_status( status, RTEMS_INVALID_ID, "rtems_task_set_note with illegal id" ); puts( "TA1 - rtems_task_set_note - RTEMS_INVALID_ID" ); status = rtems_task_start( 100, Task_1, 0 ); fatal_directive_status( status, RTEMS_INVALID_ID, "rtems_task_start with illegal id" ); puts( "TA1 - rtems_task_start - RTEMS_INVALID_ID" ); /* already started */ status = rtems_task_start( RTEMS_SELF, Task_1, 0 ); fatal_directive_status( status, RTEMS_INCORRECT_STATE, "rtems_task_start of ready task" ); puts( "TA1 - rtems_task_start - RTEMS_INCORRECT_STATE" ); /* bad Id */ status = rtems_task_suspend( 100 ); fatal_directive_status( status, RTEMS_INVALID_ID, "rtems_task_suspend with illegal id" ); puts( "TA1 - rtems_task_suspend - RTEMS_INVALID_ID" ); /* NULL param */ status = rtems_task_mode( RTEMS_SELF, 0, NULL ); fatal_directive_status( status, RTEMS_INVALID_ADDRESS, "rtems_task_mode with NULL param" ); puts( "TA1 - rtems_task_mode - RTEMS_INVALID_ADDRESS" ); }
void _RTEMS_tasks_MP_Process_packet ( rtems_packet_prefix *the_packet_prefix ) { RTEMS_tasks_MP_Packet *the_packet; Thread_Control *the_thread; bool ignored; the_packet = (RTEMS_tasks_MP_Packet *) the_packet_prefix; switch ( the_packet->operation ) { case RTEMS_TASKS_MP_ANNOUNCE_CREATE: ignored = _Objects_MP_Allocate_and_open( &_RTEMS_tasks_Information.Objects, the_packet->name, the_packet->Prefix.id, true ); _MPCI_Return_packet( the_packet_prefix ); break; case RTEMS_TASKS_MP_ANNOUNCE_DELETE: _Objects_MP_Close( &_RTEMS_tasks_Information.Objects, the_packet->Prefix.id ); _MPCI_Return_packet( the_packet_prefix ); break; case RTEMS_TASKS_MP_SUSPEND_REQUEST: the_packet->Prefix.return_code = rtems_task_suspend( the_packet->Prefix.id ); _RTEMS_tasks_MP_Send_response_packet( RTEMS_TASKS_MP_SUSPEND_RESPONSE, _Thread_Executing ); break; case RTEMS_TASKS_MP_SUSPEND_RESPONSE: case RTEMS_TASKS_MP_RESUME_RESPONSE: case RTEMS_TASKS_MP_SET_NOTE_RESPONSE: the_thread = _MPCI_Process_response( the_packet_prefix ); _MPCI_Return_packet( the_packet_prefix ); break; case RTEMS_TASKS_MP_RESUME_REQUEST: the_packet->Prefix.return_code = rtems_task_resume( the_packet->Prefix.id ); _RTEMS_tasks_MP_Send_response_packet( RTEMS_TASKS_MP_RESUME_RESPONSE, _Thread_Executing ); break; case RTEMS_TASKS_MP_SET_PRIORITY_REQUEST: the_packet->Prefix.return_code = rtems_task_set_priority( the_packet->Prefix.id, the_packet->the_priority, &the_packet->the_priority ); _RTEMS_tasks_MP_Send_response_packet( RTEMS_TASKS_MP_SET_PRIORITY_RESPONSE, _Thread_Executing ); break; case RTEMS_TASKS_MP_SET_PRIORITY_RESPONSE: the_thread = _MPCI_Process_response( the_packet_prefix ); *(rtems_task_priority *)the_thread->Wait.return_argument = the_packet->the_priority; _MPCI_Return_packet( the_packet_prefix ); break; case RTEMS_TASKS_MP_GET_NOTE_REQUEST: the_packet->Prefix.return_code = rtems_task_get_note( the_packet->Prefix.id, the_packet->notepad, &the_packet->note ); _RTEMS_tasks_MP_Send_response_packet( RTEMS_TASKS_MP_GET_NOTE_RESPONSE, _Thread_Executing ); break; case RTEMS_TASKS_MP_GET_NOTE_RESPONSE: the_thread = _MPCI_Process_response( the_packet_prefix ); *(uint32_t *)the_thread->Wait.return_argument = the_packet->note; _MPCI_Return_packet( the_packet_prefix ); break; case RTEMS_TASKS_MP_SET_NOTE_REQUEST: the_packet->Prefix.return_code = rtems_task_set_note( the_packet->Prefix.id, the_packet->notepad, the_packet->note ); _RTEMS_tasks_MP_Send_response_packet( RTEMS_TASKS_MP_SET_NOTE_RESPONSE, _Thread_Executing ); break; } }
rtems_task Task_1( rtems_task_argument argument ) { rtems_name name; uint32_t index RTEMS_GCC_NOWARN_UNUSED; rtems_id id RTEMS_GCC_NOWARN_UNUSED; rtems_task_priority in_priority; rtems_task_priority out_priority RTEMS_GCC_NOWARN_UNUSED; rtems_mode in_mode; rtems_mode mask; rtems_mode out_mode RTEMS_GCC_NOWARN_UNUSED; uint32_t note; rtems_time_of_day time RTEMS_GCC_NOWARN_UNUSED; rtems_interval timeout; rtems_signal_set signals; 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_device_minor_number minor; uint32_t io_result RTEMS_GCC_NOWARN_UNUSED; uint32_t error; rtems_clock_get_options options; name = rtems_build_name( 'N', 'A', 'M', 'E' ); in_priority = 250; in_mode = RTEMS_NO_PREEMPT; mask = RTEMS_PREEMPT_MASK; note = 8; timeout = 100; signals = RTEMS_SIGNAL_1 | RTEMS_SIGNAL_3; major = 10; minor = 0; error = 100; options = 0; /* rtems_shutdown_executive */ benchmark_timer_initialize(); for ( index=1 ; index <= OPERATION_COUNT ; index++ ) (void) rtems_shutdown_executive( error ); end_time = benchmark_timer_read(); put_time( "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( "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( "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( "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( "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( "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( "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( "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( "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( "rtems_task_mode", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_task_get_note */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_task_get_note( id, 1, note ); end_time = benchmark_timer_read(); put_time( "rtems_task_get_note", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_task_set_note */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_task_set_note( id, 1, note ); end_time = benchmark_timer_read(); put_time( "rtems_task_set_note", 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( "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( "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( "rtems_interrupt_catch", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_clock_get */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_clock_get( options, time ); end_time = benchmark_timer_read(); put_time( "rtems_clock_get", end_time, OPERATION_COUNT, overhead, 0 ); /* rtems_clock_set */ benchmark_timer_initialize(); for ( index = 1 ; index <= OPERATION_COUNT ; index ++ ) (void) rtems_clock_set( time ); end_time = benchmark_timer_read(); put_time( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "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( "rtems_multiprocessing_announce", end_time, OPERATION_COUNT, overhead, 0 ); puts( "*** END OF TIME OVERHEAD ***" ); 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 ); }
rtems_task Task_1( rtems_task_argument argument ) { rtems_status_code status; rtems_task_priority the_priority; rtems_task_priority previous_priority; rtems_id my_id; my_id = rtems_task_self(); rtems_test_pause(); status = rtems_task_set_priority( RTEMS_SELF, RTEMS_CURRENT_PRIORITY, &the_priority ); directive_failed( status, "rtems_task_set_priority" ); printf( "TA1 - rtems_task_set_priority - get initial priority of self: %02" PRIdrtems_task_priority "\n", the_priority ); while( FOREVER ) { status = rtems_task_get_note( my_id, RTEMS_NOTEPAD_8, &the_priority ); directive_failed( status, "rtems_task_get_note" ); printf( "TA1 - rtems_task_get_note - get RTEMS_NOTEPAD_8 - current priority: %02" PRIdrtems_task_priority "\n", the_priority ); if ( --the_priority == 0 ) { puts( "TA1 - rtems_task_suspend - suspend TA2" ); status = rtems_task_suspend( Task_id[ 2 ] ); directive_failed( status, "rtems_task_suspend" ); puts( "TA1 - rtems_task_set_priority - set priority of TA2 ( blocked )" ); status = rtems_task_set_priority( Task_id[ 2 ], 5, &previous_priority ); directive_failed( status, "rtems_task_set_priority" ); status = rtems_task_delete( Task_id[ 2 ] ); directive_failed( status, "rtems_task_delete of TA2" ); status = rtems_task_delete( RTEMS_SELF ); directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); } printf( "TA1 - rtems_task_set_note - set TA2's RTEMS_NOTEPAD_8: %02" PRIdrtems_task_priority "\n", the_priority ); status = rtems_task_set_note( Task_id[ 2 ], RTEMS_NOTEPAD_8, the_priority ); directive_failed( status, "rtems_task_set_note" ); printf( "TA1 - rtems_task_set_priority - set TA2's priority: %02" PRIdrtems_task_priority "\n", the_priority ); status = rtems_task_set_priority( Task_id[ 2 ], the_priority, &previous_priority ); directive_failed( status, "rtems_task_set_priority" ); } }
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 ); /** START OF NOTEPAD TESTS **/ /* * We know this is deprecated and don't want a warning on every BSP built. */ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 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: only case", 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: only case", end_time, OPERATION_COUNT, overhead, CALLING_OVERHEAD_TASK_GET_NOTE ); #pragma GCC diagnostic pop /** END OF NOTEPAD TESTS **/ 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: only case", 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: only case", end_time, OPERATION_COUNT, overhead, CALLING_OVERHEAD_CLOCK_GET ); TEST_END(); rtems_test_exit( 0 ); }