diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2011-06-28 21:08:48 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2011-06-28 21:08:48 +0000 |
commit | e049eeae908fe5d6418433aa1495c796cc58424f (patch) | |
tree | 9ae2ca088f2dfc3787d5965e904b1c738e14ad57 /testsuites/smptests/smp04 | |
parent | 2011-05-24 Joel Sherrill <joel.sherrill@oarcorp.com> (diff) | |
download | rtems-e049eeae908fe5d6418433aa1495c796cc58424f.tar.bz2 |
2011-06-28 Joel Sherrill <joel.sherrill@oarcorp.com>
* .configure.ac.swp, ChangeLog, Makefile.am, README, config.h.in,
configure.ac, smp01/.cvsignore, smp01/Makefile.am, smp01/init.c,
smp01/smp01.doc, smp01/smp01.scn, smp01/system.h, smp01/tasks.c,
smp02/.cvsignore, smp02/Makefile.am, smp02/init.c, smp02/smp02.doc,
smp02/smp02.scn, smp02/system.h, smp02/tasks.c, smp03/.cvsignore,
smp03/Makefile.am, smp03/init.c, smp03/smp03.doc, smp03/smp03.scn,
smp03/system.h, smp03/tasks.c, smp04/.cvsignore, smp04/Makefile.am,
smp04/init.c, smp04/smp04.doc, smp04/smp04.scn, smp04/system.h,
smp04/tasks.c, smp05/.cvsignore, smp05/Makefile.am, smp05/init.c,
smp05/smp05.doc, smp05/smp05.scn, smp06/.cvsignore,
smp06/Makefile.am, smp06/init.c, smp06/smp06.doc, smp06/smp06.scn,
smp07/.cvsignore, smp07/Makefile.am, smp07/init.c, smp07/smp07.doc,
smp07/smp07.scn, smp08/.cvsignore, smp08/Makefile.am, smp08/init.c,
smp08/smp08.doc, smp08/smp08.scn, smp08/system.h, smp08/tasks.c,
smp09/.cvsignore, smp09/Makefile.am, smp09/init.c, smp09/smp09.doc,
smp09/smp09.scn: New files.
Diffstat (limited to 'testsuites/smptests/smp04')
-rw-r--r-- | testsuites/smptests/smp04/.cvsignore | 2 | ||||
-rw-r--r-- | testsuites/smptests/smp04/Makefile.am | 29 | ||||
-rw-r--r-- | testsuites/smptests/smp04/init.c | 119 | ||||
-rw-r--r-- | testsuites/smptests/smp04/smp04.doc | 17 | ||||
-rw-r--r-- | testsuites/smptests/smp04/smp04.scn | 8 | ||||
-rw-r--r-- | testsuites/smptests/smp04/system.h | 70 | ||||
-rw-r--r-- | testsuites/smptests/smp04/tasks.c | 31 |
7 files changed, 276 insertions, 0 deletions
diff --git a/testsuites/smptests/smp04/.cvsignore b/testsuites/smptests/smp04/.cvsignore new file mode 100644 index 0000000000..282522db03 --- /dev/null +++ b/testsuites/smptests/smp04/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/testsuites/smptests/smp04/Makefile.am b/testsuites/smptests/smp04/Makefile.am new file mode 100644 index 0000000000..80f2968dc5 --- /dev/null +++ b/testsuites/smptests/smp04/Makefile.am @@ -0,0 +1,29 @@ +## +## $Id$ +## + +MANAGERS = all + +rtems_tests_PROGRAMS = smp04 +smp04_SOURCES = init.c tasks.c system.h ../../support/src/locked_print.c + +dist_rtems_tests_DATA = smp04.scn +dist_rtems_tests_DATA += smp04.doc + +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg +include $(top_srcdir)/../automake/compile.am +include $(top_srcdir)/../automake/leaf.am + +AM_CPPFLAGS += -I$(top_srcdir)/../support/include +AM_CPPFLAGS += -DSMPTEST + +smp04_LDADD = $(MANAGERS_NOT_WANTED:%=$(PROJECT_LIB)/no-%.rel) + +LINK_OBJS = $(smp04_OBJECTS) $(smp04_LDADD) +LINK_LIBS = $(smp04_LDLIBS) + +smp04$(EXEEXT): $(smp04_OBJECTS) $(smp04_DEPENDENCIES) + @rm -f smp04$(EXEEXT) + $(make-exe) + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/smptests/smp04/init.c b/testsuites/smptests/smp04/init.c new file mode 100644 index 0000000000..3bbe28cb38 --- /dev/null +++ b/testsuites/smptests/smp04/init.c @@ -0,0 +1,119 @@ +/* + * COPYRIGHT (c) 1989-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 + +#define CONFIGURE_INIT +#include "system.h" + +#include <stdio.h> + + +void Loop() { + volatile int i; + + for (i=0; i<500000; i++); +} + +void PrintTaskInfo( + const char *task_name +) +{ + int cpu_num; + + cpu_num = bsp_smp_processor_id(); + + locked_printf(" CPU %d running task %s\n", cpu_num, task_name ); +} + +rtems_task Init( + rtems_task_argument argument +) +{ + int i; + char ch; + rtems_id id; + rtems_status_code status; + bool allDone; + + Loop(); + locked_print_initialize(); + locked_printf( "\n\n*** SMP04 TEST ***\n" ); + + PrintTaskInfo( "Init" ); + + TaskRan[0] = true; + for ( i=1; i <= rtems_smp_get_number_of_processors() ; i++ ) + TaskRan[i] = false; + + for ( i=1; i < rtems_smp_get_number_of_processors() ; i++ ){ + + /* Create and start tasks for each CPU */ + ch = '0' + i; + locked_printf( + "Create a TA%c a %s task\n", + ch, + ((i%2) ? "RTEMS_PREEMPT" : "RTEMS_NO_PREEMPT" ) + ); + + status = rtems_task_create( + rtems_build_name( 'T', 'A', ch, ' ' ), + CONFIGURE_INIT_TASK_PRIORITY + + (2*rtems_smp_get_number_of_processors()) - (2*i), + RTEMS_MINIMUM_STACK_SIZE, + ((i%2) ? RTEMS_PREEMPT : RTEMS_NO_PREEMPT), + RTEMS_DEFAULT_ATTRIBUTES, + &id + ); + } + + for ( i=1; i < rtems_smp_get_number_of_processors() ; i++ ){ + status = rtems_task_start( id, Test_task, i ); + + /* Force a wait on the task to run in order to synchronize on + * simulated systems. + */ + while (TaskRan[i] == false) + ; + } + + ch = '0' + rtems_smp_get_number_of_processors() ; + + status = rtems_task_create( + rtems_build_name( 'T', 'A', ch, ' ' ), + 3, + RTEMS_MINIMUM_STACK_SIZE, + RTEMS_PREEMPT, + RTEMS_DEFAULT_ATTRIBUTES, + &id + ); + status = rtems_task_start( + id, + Test_task, + rtems_smp_get_number_of_processors() + ); + + /* Wait on the all tasks to run */ + while (1) { + allDone = true; + for ( i=1; i<=rtems_smp_get_number_of_processors() ; i++ ) { + if (TaskRan[i] == false) + allDone = false; + } + if (allDone) { + Loop(); + locked_printf( "*** END OF TEST SMP04 ***" ); + rtems_test_exit( 0 ); + } + } +} diff --git a/testsuites/smptests/smp04/smp04.doc b/testsuites/smptests/smp04/smp04.doc new file mode 100644 index 0000000000..0f347bb038 --- /dev/null +++ b/testsuites/smptests/smp04/smp04.doc @@ -0,0 +1,17 @@ +# +# $Id$ +# +# COPYRIGHT (c) 1989-1999. +# 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 test startst Init task with priority 5 and preemption on which +runs on CPU 0. The init task alternates preemption off and preemtion +on as it creates tasks for every other cpu in the system. The priority +of task N will be 5 + 2; task N-1 will be 5 + 4 ..... +Another task will be created after tasks are running on all cpus. This +task will be of a priority 3. For a 4 cpu system this task should run +on cpu 2. For a 2 cpu system the task should preempt the Init task. diff --git a/testsuites/smptests/smp04/smp04.scn b/testsuites/smptests/smp04/smp04.scn new file mode 100644 index 0000000000..a6c775cc50 --- /dev/null +++ b/testsuites/smptests/smp04/smp04.scn @@ -0,0 +1,8 @@ +*** SMP04 TEST *** + CPU 0 running task Init + CPU 1 running task TA1 + CPU 2 running task TA2 + CPU 3 running task TA3 + CPU 2 running task TA4 +*** END OF SMP 04 TEST *** + diff --git a/testsuites/smptests/smp04/system.h b/testsuites/smptests/smp04/system.h new file mode 100644 index 0000000000..ae7a254fac --- /dev/null +++ b/testsuites/smptests/smp04/system.h @@ -0,0 +1,70 @@ +/* + * COPYRIGHT (c) 1989-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$ + */ + +#include "tmacros.h" +#include "test_support.h" + +/* functions */ + +rtems_task Init( + rtems_task_argument argument +); + +rtems_task Test_task( + rtems_task_argument argument +); + +/* configuration information */ + +#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER + +#define CONFIGURE_SMP_APPLICATION +#define CONFIGURE_SMP_MAXIMUM_PROCESSORS 4 + +#define CONFIGURE_MAXIMUM_TASKS \ + (1 + CONFIGURE_SMP_MAXIMUM_PROCESSORS) + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE +#define CONFIGURE_INIT_TASK_STACK_SIZE \ + (3 * CONFIGURE_MINIMUM_TASK_STACK_SIZE) + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_INIT_TASK_PRIORITY 5 +#define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_NO_PREEMPT + +#define CONFIGURE_MAXIMUM_SEMAPHORES 1 + +#include <rtems/confdefs.h> + + +/* global variables */ + +/* + * Keep the names and IDs in global variables so another task can use them. + */ +void Loop(void); +void PrintTaskInfo( + const char *task_name +); + +TEST_EXTERN volatile bool TaskRan[ CONFIGURE_SMP_MAXIMUM_PROCESSORS ]; + +/* + * Handy macros and static inline functions + */ + +/* + * Macro to hide the ugliness of printing the time. + */ + +/* end of include file */ diff --git a/testsuites/smptests/smp04/tasks.c b/testsuites/smptests/smp04/tasks.c new file mode 100644 index 0000000000..a8b96cf688 --- /dev/null +++ b/testsuites/smptests/smp04/tasks.c @@ -0,0 +1,31 @@ +/* + * COPYRIGHT (c) 1989-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 "system.h" + +rtems_task Test_task( + rtems_task_argument task_index +) +{ + char task_name[5]; + + sprintf(task_name, "TA%" PRIu32, task_index ); + PrintTaskInfo( task_name ); + + Loop(); + TaskRan[task_index] = true; + + while(1); +} |