Files
rtems/testsuites/tmtests/tm05/task1.c
T
Joel Sherrill 4389287a39 2008-12-14 Joel Sherrill <joel.sherrill@oarcorp.com>
* tm01/task1.c, tm02/task1.c, tm03/task1.c, tm04/task1.c, tm05/task1.c,
	tm06/task1.c, tm07/task1.c, tm08/task1.c, tm09/task1.c, tm10/task1.c,
	tm11/task1.c, tm12/task1.c, tm13/task1.c, tm14/task1.c, tm16/task1.c,
	tm17/task1.c, tm18/task1.c, tm19/task1.c, tm20/task1.c, tm21/task1.c,
	tm23/task1.c, tm24/task1.c, tm25/task1.c, tm26/task1.c, tm27/task1.c,
	tm28/task1.c, tm29/task1.c, tmoverhd/testtask.c: Run all tests
	successfully with maxixum number of priorities as 16 instead of 256.
	This was done by temporarily modifying the score priority.h maximum.
	This allowed testing of all API code to ensure that it worked
	properly with a reduced number of priorities. Most modifications were
	to switch from hard-coded maximum to using the API provided methods
	to determine maximum number of priority levels.
2008-12-14 18:38:45 +00:00

136 lines
2.7 KiB
C

/*
* COPYRIGHT (c) 1989-2008.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* $Id$
*/
#define CONFIGURE_INIT
#include "system.h"
rtems_id Task_id[OPERATION_COUNT+1];
uint32_t Task_index;
rtems_task High_task(
rtems_task_argument argument
);
rtems_task Middle_tasks(
rtems_task_argument argument
);
rtems_task Low_task(
rtems_task_argument argument
);
void test_init();
int operation_count = OPERATION_COUNT;
rtems_task Init(
rtems_task_argument argument
)
{
rtems_status_code status;
Print_Warning();
puts( "\n\n*** TIME TEST 5 ***" );
test_init();
status = rtems_task_delete( RTEMS_SELF );
directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
}
void test_init()
{
rtems_status_code status;
rtems_task_entry task_entry;
rtems_task_priority priority;
uint32_t index;
priority = RTEMS_MAXIMUM_PRIORITY - 1;
if ( OPERATION_COUNT > RTEMS_MAXIMUM_PRIORITY - 2 )
operation_count = RTEMS_MAXIMUM_PRIORITY - 2;
for( index = 0; index <= operation_count ; index++ ) {
status = rtems_task_create(
rtems_build_name( 'T', 'I', 'M', 'E' ),
priority,
RTEMS_MINIMUM_STACK_SIZE,
RTEMS_DEFAULT_MODES,
RTEMS_DEFAULT_ATTRIBUTES,
&Task_id[ index ]
);
directive_failed( status, "rtems_task_create loop" );
priority--;
if ( index==0 ) task_entry = Low_task;
else if ( index==operation_count ) task_entry = High_task;
else task_entry = Middle_tasks;
status = rtems_task_start( Task_id[ index ], task_entry, 0 );
directive_failed( status, "rtems_task_start loop" );
}
}
rtems_task High_task(
rtems_task_argument argument
)
{
benchmark_timer_initialize();
(void) rtems_task_suspend( RTEMS_SELF );
end_time = benchmark_timer_read();
put_time(
"rtems_task_resume: task readied -- preempts caller",
end_time,
operation_count,
0,
CALLING_OVERHEAD_TASK_RESUME
);
puts( "*** END OF TEST 5 ***" );
rtems_test_exit( 0 );
}
rtems_task Middle_tasks(
rtems_task_argument argument
)
{
(void) rtems_task_suspend( RTEMS_SELF );
Task_index++;
(void) rtems_task_resume( Task_id[ Task_index ] );
}
rtems_task Low_task(
rtems_task_argument argument
)
{
end_time = benchmark_timer_read();
put_time(
"rtems_task_suspend: calling task",
end_time,
operation_count,
0,
CALLING_OVERHEAD_TASK_SUSPEND
);
Task_index = 1;
benchmark_timer_initialize();
(void) rtems_task_resume( Task_id[ Task_index ] );
}