diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 1995-05-11 17:39:37 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 1995-05-11 17:39:37 +0000 |
commit | ac7d5ef06a6d6e8d84abbd1f0b82162725f98326 (patch) | |
tree | 9304cf759a73f2a1c6fd3191948f00e870af3787 /c/src/tests/tmtests/tm09/task1.c | |
download | rtems-ac7d5ef06a6d6e8d84abbd1f0b82162725f98326.tar.bz2 |
Initial revision
Diffstat (limited to 'c/src/tests/tmtests/tm09/task1.c')
-rw-r--r-- | c/src/tests/tmtests/tm09/task1.c | 221 |
1 files changed, 221 insertions, 0 deletions
diff --git a/c/src/tests/tmtests/tm09/task1.c b/c/src/tests/tmtests/tm09/task1.c new file mode 100644 index 0000000000..9126ee8a1d --- /dev/null +++ b/c/src/tests/tmtests/tm09/task1.c @@ -0,0 +1,221 @@ +/* + * + * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. + * On-Line Applications Research Corporation (OAR). + * All rights assigned to U.S. Government, 1994. + * + * This material may be reproduced by or for the U.S. Government pursuant + * to the copyright license under the clause at DFARS 252.227-7013. This + * notice must appear in all copies of this file and its derivatives. + * + * $Id$ + */ + +#include "system.h" +#undef EXTERN +#define EXTERN +#include "conftbl.h" +#include "gvar.h" + +rtems_id Queue_id; + +rtems_task Test_task( + rtems_task_argument argument +); +void queue_test(); + +rtems_task Init( + rtems_task_argument argument +) +{ + rtems_status_code status; + + puts( "\n\n*** TIME TEST 9 ***" ); + + status = rtems_task_create( + 1, + 128, + 4096, + RTEMS_DEFAULT_MODES, + RTEMS_DEFAULT_ATTRIBUTES, + &Task_id[ 1 ] + ); + directive_failed( status, "rtems_task_create" ); + + status = rtems_task_start( Task_id[ 1 ], Test_task, 0 ); + directive_failed( status, "rtems_task_start" ); + + status = rtems_task_delete( RTEMS_SELF ); + directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); +} + +rtems_task Test_task ( + rtems_task_argument argument +) +{ + Timer_initialize(); + rtems_message_queue_create( + 1, + OPERATION_COUNT, + RTEMS_DEFAULT_ATTRIBUTES, + &Queue_id + ); + end_time = Read_timer(); + + put_time( + "rtems_message_queue_create", + end_time, + 1, + 0, + CALLING_OVERHEAD_MESSAGE_QUEUE_CREATE + ); + + queue_test(); + + Timer_initialize(); + rtems_message_queue_delete( Queue_id ); + end_time = Read_timer(); + + put_time( + "rtems_message_queue_delete", + end_time, + 1, + 0, + CALLING_OVERHEAD_MESSAGE_QUEUE_DELETE + ); + + exit( 0 ); +} + +void queue_test() +{ + rtems_unsigned32 send_loop_time; + rtems_unsigned32 urgent_loop_time; + rtems_unsigned32 receive_loop_time; + rtems_unsigned32 send_time; + rtems_unsigned32 urgent_time; + rtems_unsigned32 receive_time; + rtems_unsigned32 empty_flush_time; + rtems_unsigned32 flush_time; + rtems_unsigned32 empty_flush_count; + rtems_unsigned32 flush_count; + rtems_unsigned32 index; + rtems_unsigned32 iterations; + long buffer[4]; + rtems_status_code status; + + send_loop_time = 0; + urgent_loop_time = 0; + receive_loop_time = 0; + send_time = 0; + urgent_time = 0; + receive_time = 0; + empty_flush_time = 0; + flush_time = 0; + flush_count = 0; + empty_flush_count = 0; + + for ( iterations = 1 ; iterations <= OPERATION_COUNT ; iterations++ ) { + + Timer_initialize(); + for ( index=1 ; index <= OPERATION_COUNT ; index++ ) + (void) Empty_function(); + send_loop_time += Read_timer(); + + Timer_initialize(); + for ( index=1 ; index <= OPERATION_COUNT ; index++ ) + (void) Empty_function(); + urgent_loop_time += Read_timer(); + + Timer_initialize(); + for ( index=1 ; index <= OPERATION_COUNT ; index++ ) + (void) Empty_function(); + receive_loop_time += Read_timer(); + + Timer_initialize(); + for ( index=1 ; index <= OPERATION_COUNT ; index++ ) + (void) rtems_message_queue_send( Queue_id, (long (*)[4])buffer ); + send_time += Read_timer(); + + Timer_initialize(); + for ( index=1 ; index <= OPERATION_COUNT ; index++ ) + (void) rtems_message_queue_receive( + Queue_id, + (long (*)[4])buffer, + RTEMS_DEFAULT_OPTIONS, + RTEMS_NO_TIMEOUT + ); + receive_time += Read_timer(); + + Timer_initialize(); + for ( index=1 ; index <= OPERATION_COUNT ; index++ ) + (void) rtems_message_queue_urgent( Queue_id, (long (*)[4])buffer ); + urgent_time += Read_timer(); + + Timer_initialize(); + for ( index=1 ; index <= OPERATION_COUNT ; index++ ) + (void) rtems_message_queue_receive( + Queue_id, + (long (*)[4])buffer, + RTEMS_DEFAULT_OPTIONS, + RTEMS_NO_TIMEOUT + ); + receive_time += Read_timer(); + + Timer_initialize(); + rtems_message_queue_flush( Queue_id, &empty_flush_count ); + empty_flush_time += Read_timer(); + + /* send one message to flush */ + status = rtems_message_queue_send( + Queue_id, + (long (*)[4])buffer + ); + directive_failed( status, "rtems_message_queue_send" ); + + Timer_initialize(); + rtems_message_queue_flush( Queue_id, &flush_count ); + flush_time += Read_timer(); + } + + put_time( + "rtems_message_queue_send (no tasks waiting)", + send_time, + OPERATION_COUNT * OPERATION_COUNT, + send_loop_time, + CALLING_OVERHEAD_MESSAGE_QUEUE_SEND + ); + + put_time( + "rtems_message_queue_urgent (no tasks waiting)", + urgent_time, + OPERATION_COUNT * OPERATION_COUNT, + urgent_loop_time, + CALLING_OVERHEAD_MESSAGE_QUEUE_URGENT + ); + + put_time( + "rtems_message_queue_receive (messages available)", + receive_time, + OPERATION_COUNT * OPERATION_COUNT * 2, + receive_loop_time * 2, + CALLING_OVERHEAD_MESSAGE_QUEUE_RECEIVE + ); + + put_time( + "rtems_message_queue_flush (empty queue)", + empty_flush_time, + OPERATION_COUNT, + 0, + CALLING_OVERHEAD_MESSAGE_QUEUE_FLUSH + ); + + put_time( + "rtems_message_queue_flush (messages flushed)", + flush_time, + OPERATION_COUNT, + 0, + CALLING_OVERHEAD_MESSAGE_QUEUE_FLUSH + ); + +} |