summaryrefslogtreecommitdiffstats
path: root/testsuites/tmtests/tm04
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1995-05-11 17:39:37 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1995-05-11 17:39:37 +0000
commitac7d5ef06a6d6e8d84abbd1f0b82162725f98326 (patch)
tree9304cf759a73f2a1c6fd3191948f00e870af3787 /testsuites/tmtests/tm04
downloadrtems-ac7d5ef06a6d6e8d84abbd1f0b82162725f98326.tar.bz2
Initial revision
Diffstat (limited to 'testsuites/tmtests/tm04')
-rw-r--r--testsuites/tmtests/tm04/system.h23
-rw-r--r--testsuites/tmtests/tm04/task1.c387
-rw-r--r--testsuites/tmtests/tm04/tm04.doc13
3 files changed, 423 insertions, 0 deletions
diff --git a/testsuites/tmtests/tm04/system.h b/testsuites/tmtests/tm04/system.h
new file mode 100644
index 0000000000..9133506e7f
--- /dev/null
+++ b/testsuites/tmtests/tm04/system.h
@@ -0,0 +1,23 @@
+/* system.h
+ *
+ * This include file is used by all tests in the Time Suite.
+ *
+ * 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 <rtems.h>
+
+#include "coverhd.h"
+#include "tmacros.h"
+
+#include "timesys.h"
+#include "timegvar.h"
diff --git a/testsuites/tmtests/tm04/task1.c b/testsuites/tmtests/tm04/task1.c
new file mode 100644
index 0000000000..0014d02dd3
--- /dev/null
+++ b/testsuites/tmtests/tm04/task1.c
@@ -0,0 +1,387 @@
+/*
+ *
+ * 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 Semaphore_id;
+rtems_id Task_id[OPERATION_COUNT+1];
+rtems_unsigned32 task_count;
+rtems_id Highest_id;
+
+rtems_task Low_tasks(
+ rtems_task_argument argument
+);
+
+rtems_task High_task(
+ rtems_task_argument argument
+);
+
+rtems_task Restart_task(
+ rtems_task_argument argument
+);
+
+void test_init();
+
+rtems_task Init(
+ rtems_task_argument argument
+)
+{
+ rtems_status_code status;
+
+ puts( "\n\n*** TIME TEST 4 ***" );
+
+ 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_unsigned32 index;
+
+ task_count = OPERATION_COUNT;
+
+ for ( index = 1 ; index <= OPERATION_COUNT ; index++ ) {
+
+ status = rtems_task_create(
+ rtems_build_name( 'T', 'I', 'M', 'E' ),
+ 10,
+ 1024,
+ RTEMS_NO_PREEMPT,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &Task_id[ index ]
+ );
+ directive_failed( status, "rtems_task_create loop" );
+
+ status = rtems_task_start( Task_id[ index ], Low_tasks, 0 );
+ directive_failed( status, "rtems_task_start loop" );
+ }
+
+ status = rtems_semaphore_create(
+ rtems_build_name( 'S', 'M', '1', ' ' ),
+ 0,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &Semaphore_id
+ );
+ directive_failed( status, "rtems_semaphore_create of SM1" );
+}
+
+rtems_task Highest_task(
+ rtems_task_argument argument
+)
+{
+ rtems_task_priority old_priority;
+ rtems_status_code status;
+
+ if ( argument == 1 ) {
+
+ end_time = Read_timer();
+
+ put_time(
+ "rtems_task_restart (blocked, preempt)",
+ end_time,
+ 1,
+ 0,
+ CALLING_OVERHEAD_TASK_RESTART
+ );
+
+ status = rtems_task_set_priority(
+ RTEMS_CURRENT_PRIORITY,
+ 254,
+ &old_priority
+ );
+ directive_failed( status, "rtems_task_set_priority" );
+
+ } else if ( argument == 2 ) {
+
+ end_time = Read_timer();
+
+ put_time(
+ "rtems_task_restart (ready, preempt)",
+ end_time,
+ 1,
+ 0,
+ CALLING_OVERHEAD_TASK_RESTART
+ );
+
+ status = rtems_task_delete( RTEMS_SELF );
+ directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
+
+ } else
+ (void) rtems_semaphore_obtain(
+ Semaphore_id,
+ RTEMS_DEFAULT_OPTIONS,
+ RTEMS_NO_TIMEOUT
+ );
+
+}
+
+rtems_task High_task(
+ rtems_task_argument argument
+)
+{
+ rtems_status_code status;
+ rtems_unsigned32 index;
+ rtems_name name;
+ rtems_task_priority old_priority;
+
+ Timer_initialize();
+ (void) rtems_task_restart( Highest_id, 1 );
+ /* preempted by Higher_task */
+
+ Timer_initialize();
+ (void) rtems_task_restart( Highest_id, 2 );
+ /* preempted by Higher_task */
+
+ Timer_initialize();
+ for ( index=1 ; index <= OPERATION_COUNT ; index++ )
+ (void) Empty_function();
+ overhead = Read_timer();
+
+ Timer_initialize();
+ for ( index=1 ; index <= OPERATION_COUNT ; index++ )
+ rtems_semaphore_release( Semaphore_id );
+ end_time = Read_timer();
+
+ put_time(
+ "rtems_semaphore_release (readying)",
+ end_time,
+ OPERATION_COUNT,
+ 0,
+ CALLING_OVERHEAD_SEMAPHORE_RELEASE
+ );
+
+ name = rtems_build_name( 'T', 'I', 'M', 'E' );
+
+ for ( index=1 ; index <= OPERATION_COUNT ; index++ ) {
+ status = rtems_task_delete( Task_id[index] );
+ directive_failed( status, "rtems_task_delete" );
+ }
+
+ Timer_initialize();
+ for ( index=1 ; index <= OPERATION_COUNT ; index++ )
+ rtems_task_create(
+ name,
+ 10,
+ 1024,
+ RTEMS_NO_PREEMPT,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &Task_id[ index ]
+ );
+ end_time = Read_timer();
+
+ put_time(
+ "rtems_task_create",
+ end_time,
+ OPERATION_COUNT,
+ overhead,
+ CALLING_OVERHEAD_TASK_CREATE
+ );
+
+ Timer_initialize();
+ for ( index=1 ; index <= OPERATION_COUNT ; index++ )
+ rtems_task_start( Task_id[ index ], Low_tasks, 0 );
+
+ end_time = Read_timer();
+
+ put_time(
+ "rtems_task_start",
+ end_time,
+ OPERATION_COUNT,
+ overhead,
+ CALLING_OVERHEAD_TASK_START
+ );
+
+ for ( index=1 ; index <= OPERATION_COUNT ; index++ ) {
+ status = rtems_task_delete( Task_id[ index ] );
+ directive_failed( status, "rtems_task_delete" );
+ }
+
+ for ( index=1 ; index <= OPERATION_COUNT ; index++ ) {
+ status = rtems_task_create(
+ name,
+ 250,
+ 1024,
+ RTEMS_NO_PREEMPT,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &Task_id[ index ]
+ );
+ directive_failed( status, "rtems_task_create LOOP" );
+
+ status = rtems_task_start( Task_id[ index ], Restart_task, 0 );
+ directive_failed( status, "rtems_task_start LOOP" );
+
+ status = rtems_task_suspend( Task_id[ index ] );
+ directive_failed( status, "rtems_task_suspend LOOP" );
+ }
+
+ Timer_initialize();
+ for ( index=1 ; index <= OPERATION_COUNT ; index++ )
+ (void) rtems_task_restart( Task_id[ index ], 0 );
+ end_time = Read_timer();
+
+ put_time(
+ "rtems_task_restart (suspended)",
+ end_time,
+ OPERATION_COUNT,
+ overhead,
+ CALLING_OVERHEAD_TASK_RESTART
+ );
+
+ for ( index=1 ; index <= OPERATION_COUNT ; index++ )
+ (void) rtems_task_suspend( Task_id[ index ] );
+
+ Timer_initialize();
+ for ( index=1 ; index <= OPERATION_COUNT ; index++ )
+ (void) rtems_task_delete( Task_id[ index ] );
+ end_time = Read_timer();
+
+ put_time(
+ "rtems_task_delete (suspended)",
+ end_time,
+ OPERATION_COUNT,
+ overhead,
+ CALLING_OVERHEAD_TASK_DELETE
+ );
+
+ for ( index=1 ; index <= OPERATION_COUNT ; index++ ) {
+ status = rtems_task_create(
+ name,
+ 250,
+ 1024,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &Task_id[ index ]
+ );
+ directive_failed( status, "rtems_task_create LOOP" );
+
+ status = rtems_task_start( Task_id[ index ], Restart_task, 0 );
+ directive_failed( status, "rtems_task_start LOOP" );
+ }
+
+ Timer_initialize();
+ for ( index=1 ; index <= OPERATION_COUNT ; index++ )
+ (void) rtems_task_restart( Task_id[ index ], 1 );
+ end_time = Read_timer();
+
+ put_time(
+ "rtems_task_restart (ready)",
+ end_time,
+ OPERATION_COUNT,
+ overhead,
+ CALLING_OVERHEAD_TASK_RESTART
+ );
+
+ for ( index=1 ; index <= OPERATION_COUNT ; index++ ) {
+ status = rtems_task_set_priority( Task_id[ index ], 5, &old_priority );
+ directive_failed( status, "rtems_task_set_priority loop" );
+ }
+
+ /* yield processor -- tasks block */
+ status = rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
+ directive_failed( status, "rtems_task_wake_after" );
+
+ Timer_initialize();
+ for ( index=1 ; index <= OPERATION_COUNT ; index++ )
+ (void) rtems_task_restart( Task_id[ index ], 1 );
+ end_time = Read_timer();
+
+ put_time(
+ "rtems_task_restart (blocked, no preempt)",
+ end_time,
+ OPERATION_COUNT,
+ overhead,
+ CALLING_OVERHEAD_TASK_RESTART
+ );
+
+ /* yield processor -- tasks block */
+ status = rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
+ directive_failed( status, "rtems_task_wake_after" );
+
+ Timer_initialize();
+ for ( index=1 ; index <= OPERATION_COUNT ; index++ )
+ (void) rtems_task_delete( Task_id[ index ] );
+ end_time = Read_timer();
+
+ put_time(
+ "rtems_task_delete (blocked)",
+ end_time,
+ OPERATION_COUNT,
+ overhead,
+ CALLING_OVERHEAD_TASK_DELETE
+ );
+
+ exit( 0 );
+}
+
+rtems_task Low_tasks(
+ rtems_task_argument argument
+)
+{
+ rtems_id id;
+ rtems_status_code status;
+
+ task_count--;
+
+ if ( task_count == 0 ) {
+ status = rtems_task_create(
+ rtems_build_name( 'H', 'I', ' ', ' ' ),
+ 5,
+ 2048,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &id
+ );
+ directive_failed( status, "rtems_task_create HI" );
+
+ status = rtems_task_start( id, High_task, 0 );
+ directive_failed( status, "rtems_task_start HI" );
+
+ status = rtems_task_create(
+ rtems_build_name( 'H', 'I', 'G', 'H' ),
+ 3,
+ 2048,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &Highest_id
+ );
+ directive_failed( status, "rtems_task_create HIGH" );
+
+ status = rtems_task_start( Highest_id, Highest_task, 0 );
+ directive_failed( status, "rtems_task_start HIGH" );
+
+ }
+ (void) rtems_semaphore_obtain(
+ Semaphore_id,
+ RTEMS_DEFAULT_OPTIONS,
+ RTEMS_NO_TIMEOUT
+ );
+}
+
+rtems_task Restart_task(
+ rtems_task_argument argument
+)
+{
+ if ( argument == 1 )
+ (void) rtems_semaphore_obtain(
+ Semaphore_id,
+ RTEMS_DEFAULT_OPTIONS,
+ RTEMS_NO_TIMEOUT
+ );
+}
diff --git a/testsuites/tmtests/tm04/tm04.doc b/testsuites/tmtests/tm04/tm04.doc
new file mode 100644
index 0000000000..0de40191c6
--- /dev/null
+++ b/testsuites/tmtests/tm04/tm04.doc
@@ -0,0 +1,13 @@
+#
+# $Id$
+#
+# 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.
+#
+
+