summaryrefslogtreecommitdiffstats
path: root/testsuites/sptests/spsimplesched02
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2011-03-16 16:33:04 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2011-03-16 16:33:04 +0000
commit5bbc204431e8b2fbec5b06e38434031ed92e1d5c (patch)
tree51570e5b0d54b36bc9285269684a61ccb014d7d9 /testsuites/sptests/spsimplesched02
parent2011-03-16 Jennifer Averett <jennifer.averett@OARcorp.com> (diff)
downloadrtems-5bbc204431e8b2fbec5b06e38434031ed92e1d5c.tar.bz2
2011-03-16 Jennifer Averett <jennifer.averett@OARcorp.com>
PR 1743/cpu * Makefile.am, configure.ac, spsize/size.c: Add Simple Priority Scheduler as complement to existing Deterministic Priority Scheduler. This scheduler serves both as an example and as a lighter weight implementation for smaller systems. * spsimplesched01/.cvsignore, spsimplesched01/Makefile.am, spsimplesched01/init.c, spsimplesched01/spsimplesched01.doc, spsimplesched01/spsimplesched01.scn, spsimplesched02/.cvsignore, spsimplesched02/Makefile.am, spsimplesched02/init.c, spsimplesched02/spsimplesched02.doc, spsimplesched02/spsimplesched02.scn, spsimplesched03/.cvsignore, spsimplesched03/Makefile.am, spsimplesched03/init.c, spsimplesched03/spsimplesched03.doc, spsimplesched03/spsimplesched03.scn: New files.
Diffstat (limited to 'testsuites/sptests/spsimplesched02')
-rw-r--r--testsuites/sptests/spsimplesched02/.cvsignore2
-rw-r--r--testsuites/sptests/spsimplesched02/Makefile.am28
-rw-r--r--testsuites/sptests/spsimplesched02/init.c143
-rw-r--r--testsuites/sptests/spsimplesched02/spsimplesched02.doc24
-rw-r--r--testsuites/sptests/spsimplesched02/spsimplesched02.scn15
5 files changed, 212 insertions, 0 deletions
diff --git a/testsuites/sptests/spsimplesched02/.cvsignore b/testsuites/sptests/spsimplesched02/.cvsignore
new file mode 100644
index 0000000000..282522db03
--- /dev/null
+++ b/testsuites/sptests/spsimplesched02/.cvsignore
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/testsuites/sptests/spsimplesched02/Makefile.am b/testsuites/sptests/spsimplesched02/Makefile.am
new file mode 100644
index 0000000000..fad1747b9a
--- /dev/null
+++ b/testsuites/sptests/spsimplesched02/Makefile.am
@@ -0,0 +1,28 @@
+##
+## $Id$
+##
+
+MANAGERS = all
+
+rtems_tests_PROGRAMS = spsimplesched02
+spsimplesched02_SOURCES = init.c
+
+dist_rtems_tests_DATA = spsimplesched02.scn
+dist_rtems_tests_DATA += spsimplesched02.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+spsimplesched02_LDADD = $(MANAGERS_NOT_WANTED:%=$(PROJECT_LIB)/no-%.rel)
+
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(spsimplesched02_OBJECTS) $(spsimplesched02_LDADD)
+LINK_LIBS = $(spsimplesched02_LDLIBS)
+
+spsimplesched02$(EXEEXT): $(spsimplesched02_OBJECTS) $(spsimplesched02_DEPENDENCIES)
+ @rm -f spsimplesched02$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/sptests/spsimplesched02/init.c b/testsuites/sptests/spsimplesched02/init.c
new file mode 100644
index 0000000000..381d4ca229
--- /dev/null
+++ b/testsuites/sptests/spsimplesched02/init.c
@@ -0,0 +1,143 @@
+/*
+ * COPYRIGHT (c) 2011.
+ * 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$
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tmacros.h>
+
+/*
+ * Keep the names and IDs in global variables so another task can use them.
+ */
+rtems_id Task_id[ 3 ]; /* array of task ids */
+rtems_name Task_name[ 3 ]; /* array of task names */
+rtems_name Semaphore_name[ 2 ];
+rtems_id Semaphore_id[ 2 ];
+
+rtems_task Test_task(
+ rtems_task_argument unused
+)
+{
+ rtems_id tid;
+ uint32_t task_index;
+ rtems_status_code status;
+
+ status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid );
+ task_index = task_number( tid );
+
+ for ( ; ; ) {
+ rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
+ }
+}
+
+void ObtainRelease( bool suspendIdle )
+{
+ rtems_status_code status;
+
+ if (suspendIdle) {
+ puts( "INIT - Suspend Idle Task");
+ status = rtems_task_suspend( _Thread_Idle->Object.id );
+ directive_failed( status, "rtems_task_suspend idle" );
+ }
+
+ puts( "INIT - Obtain priority ceiling semaphore - priority increases" );
+ status= rtems_semaphore_obtain( Semaphore_id[1], RTEMS_DEFAULT_OPTIONS, 0 );
+ directive_failed( status, "rtems_semaphore_obtain" );
+
+ puts( "INIT - Obtain priority ceiling semaphore - priority decreases" );
+ status = rtems_semaphore_release( Semaphore_id[1] );
+ directive_failed( status, "rtems_semaphore_release" );
+
+ if (suspendIdle) {
+ puts( "INIT - Resume Idle Task");
+ status = rtems_task_resume( _Thread_Idle->Object.id );
+ directive_failed( status, "rtems_task_resume idle" );
+ }
+}
+
+rtems_task Init(
+ rtems_task_argument argument
+)
+{
+ rtems_status_code status;
+
+ puts( "\n\n*** SIMPLE SCHEDULER 02 TEST ***" );
+
+ /*
+ * Create the semaphore. Then obtain and release the
+ * semaphore with no other tasks running.
+ */
+ puts( "INIT - Create priority ceiling semaphore" );
+ Semaphore_name[ 1 ] = rtems_build_name( 'S', 'M', '1', ' ' );
+ status = rtems_semaphore_create(
+ Semaphore_name[ 1 ],
+ 1,
+ RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY_CEILING | RTEMS_PRIORITY,
+ 2,
+ &Semaphore_id[ 1 ]
+ );
+ directive_failed( status, "rtems_semaphore_create of SM1" );
+ ObtainRelease( false );
+
+ /*
+ * Create test task and obtain release the semaphore with
+ * one other task running.
+ */
+ puts( "INIT - create task 1" );
+ Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' );
+ status = rtems_task_create(
+ Task_name[ 1 ], 1, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ]
+ );
+ status = rtems_task_start( Task_id[ 1 ], Test_task, 1 );
+ ObtainRelease( false );
+
+ /*
+ * Create a a second test task and obtain release the semaphore
+ * with both tasks running.
+ */
+ puts( "INIT - create task 2" );
+ Task_name[ 1 ] = rtems_build_name( 'T', 'A', '2', ' ' );
+ status = rtems_task_create(
+ Task_name[ 2 ], 1, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 2 ]
+ );
+ status = rtems_task_start( Task_id[ 2 ], Test_task, 1 );
+ ObtainRelease( false );
+
+ /*
+ * Obtain and release the semaphore with the idle task suspended.
+ */
+ ObtainRelease( true );
+
+ /* End the Test */
+ puts( "*** END OF SIMPLE SCHEDULER 02 TEST ***" );
+ rtems_test_exit(0);
+}
+
+/* configuration information */
+
+#define CONFIGURE_SCHEDULER_SIMPLE
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+
+#define CONFIGURE_MAXIMUM_TASKS 3
+#define CONFIGURE_MAXIMUM_SEMAPHORES 2
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
+#define CONFIGURE_INIT_TASK_PRIORITY 4
+
+#define CONFIGURE_INIT
+#include <rtems/confdefs.h>
+/* end of include file */
diff --git a/testsuites/sptests/spsimplesched02/spsimplesched02.doc b/testsuites/sptests/spsimplesched02/spsimplesched02.doc
new file mode 100644
index 0000000000..0db30ae941
--- /dev/null
+++ b/testsuites/sptests/spsimplesched02/spsimplesched02.doc
@@ -0,0 +1,24 @@
+#
+# $Id$
+#
+# COPYRIGHT (c) 2011.
+# 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.
+#
+
+This file describes the directives and concepts tested by this test set.
+
+test set name: spsimplesched02
+
+directives:
+ + rtems_semaphore_create
+ + rtems_semaphore_obtain
+ + rtems_semaphore_release
+
+concepts:
+
++ The purpose of this test is to exercise paths in the Simple Scheduler.
+ It exercises logic required to inherit and restore priority.
diff --git a/testsuites/sptests/spsimplesched02/spsimplesched02.scn b/testsuites/sptests/spsimplesched02/spsimplesched02.scn
new file mode 100644
index 0000000000..db57c882b4
--- /dev/null
+++ b/testsuites/sptests/spsimplesched02/spsimplesched02.scn
@@ -0,0 +1,15 @@
+*** SIMPLE SCHEDULER 02 TEST ***
+INIT - Create priority ceiling semaphore
+INIT - Obtain priority ceiling semaphore - priority increases
+INIT - Obtain priority ceiling semaphore - priority decreases
+INIT - create task 1
+INIT - Obtain priority ceiling semaphore - priority increases
+INIT - Obtain priority ceiling semaphore - priority decreases
+INIT - create task 2
+INIT - Obtain priority ceiling semaphore - priority increases
+INIT - Obtain priority ceiling semaphore - priority decreases
+INIT - Suspend Idle Task
+INIT - Obtain priority ceiling semaphore - priority increases
+INIT - Obtain priority ceiling semaphore - priority decreases
+INIT - Resume Idle Task
+*** END OF SIMPLE SCHEDULER 02 TEST ***