diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2008-08-05 13:09:53 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2008-08-05 13:09:53 +0000 |
commit | 2a6c66e5d0ab9e5c7d53344cc7085512ccc366ab (patch) | |
tree | cf47a38dddc4a7c04307b08a6ecbb588bc8fceff | |
parent | 2008-08-05 Xudong Guan <xudong.guan@criticalsoftware.com> (diff) | |
download | rtems-2a6c66e5d0ab9e5c7d53344cc7085512ccc366ab.tar.bz2 |
2008-08-05 Xudong Guan <xudong.guan@criticalsoftware.com>
PR 1212/cpukit
* Makefile.am, configure.ac: Time slicing will not happen if the task
mode is changed from a non-timeslicing mode to timeslicing mode if it
is done by the executing thread (e.g. in its task body). This change
includes sp44 to demonstrate the problem and verify the correction.
* sp44/.cvsignore, sp44/Makefile.am, sp44/init.c, sp44/sp44.scn: New files.
-rw-r--r-- | testsuites/sptests/ChangeLog | 9 | ||||
-rw-r--r-- | testsuites/sptests/Makefile.am | 2 | ||||
-rw-r--r-- | testsuites/sptests/configure.ac | 1 | ||||
-rw-r--r-- | testsuites/sptests/sp44/.cvsignore | 2 | ||||
-rw-r--r-- | testsuites/sptests/sp44/Makefile.am | 27 | ||||
-rw-r--r-- | testsuites/sptests/sp44/init.c | 141 | ||||
-rw-r--r-- | testsuites/sptests/sp44/sp44.scn | 21 |
7 files changed, 202 insertions, 1 deletions
diff --git a/testsuites/sptests/ChangeLog b/testsuites/sptests/ChangeLog index b9e5161851..e2aa83319d 100644 --- a/testsuites/sptests/ChangeLog +++ b/testsuites/sptests/ChangeLog @@ -1,3 +1,12 @@ +2008-08-05 Xudong Guan <xudong.guan@criticalsoftware.com> + + PR 1212/cpukit + * Makefile.am, configure.ac: Time slicing will not happen if the task + mode is changed from a non-timeslicing mode to timeslicing mode if it + is done by the executing thread (e.g. in its task body). This change + includes sp44 to demonstrate the problem and verify the correction. + * sp44/.cvsignore, sp44/Makefile.am, sp44/init.c, sp44/sp44.scn: New files. + 2007-03-29 Ralf Corsépius <ralf.corsepius@rtems.org> * sp06/task1.c, sp20/task1.c: Use rtems_task_argument. diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am index cfa8ee915b..ab7103ff1c 100644 --- a/testsuites/sptests/Makefile.am +++ b/testsuites/sptests/Makefile.am @@ -7,7 +7,7 @@ ACLOCAL_AMFLAGS = -I ../aclocal ## spfatal is not included for now SUBDIRS = sp01 sp02 sp03 sp04 sp05 sp06 sp07 sp08 sp09 sp11 sp12 sp13 sp14 \ sp15 sp16 sp17 sp19 sp20 sp21 sp22 sp23 sp24 sp25 sp26 sp27 sp28 sp29 \ - sp30 sp31 sp32 spsize + sp30 sp31 sp32 sp44 spsize DIST_SUBDIRS = $(SUBDIRS) spfatal include $(top_srcdir)/../automake/subdirs.am diff --git a/testsuites/sptests/configure.ac b/testsuites/sptests/configure.ac index 320639b454..7b319349e7 100644 --- a/testsuites/sptests/configure.ac +++ b/testsuites/sptests/configure.ac @@ -57,6 +57,7 @@ sp29/Makefile sp30/Makefile sp31/Makefile sp32/Makefile +sp44/Makefile spsize/Makefile spfatal/Makefile ]) diff --git a/testsuites/sptests/sp44/.cvsignore b/testsuites/sptests/sp44/.cvsignore new file mode 100644 index 0000000000..282522db03 --- /dev/null +++ b/testsuites/sptests/sp44/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/testsuites/sptests/sp44/Makefile.am b/testsuites/sptests/sp44/Makefile.am new file mode 100644 index 0000000000..7b1b5e4b36 --- /dev/null +++ b/testsuites/sptests/sp44/Makefile.am @@ -0,0 +1,27 @@ +## +## $Id$ +## + +MANAGERS = all + +rtems_tests_PROGRAMS = sp44.exe +sp44_exe_SOURCES = init.c + +dist_rtems_tests_DATA = sp44.scn + +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg +include $(top_srcdir)/../automake/compile.am +include $(top_srcdir)/../automake/leaf.am + +sp44_exe_LDADD = $(MANAGERS_NOT_WANTED:%=$(PROJECT_LIB)/no-%.rel) + +AM_CPPFLAGS += -I$(top_srcdir)/../support/include + +LINK_OBJS = $(sp44_exe_OBJECTS) $(sp44_exe_LDADD) +LINK_LIBS = $(sp44_exe_LDLIBS) + +sp44.exe$(EXEEXT): $(sp44_exe_OBJECTS) $(sp44_exe_DEPENDENCIES) + @rm -f sp44.exe$(EXEEXT) + $(make-exe) + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/sptests/sp44/init.c b/testsuites/sptests/sp44/init.c new file mode 100644 index 0000000000..4e39de1286 --- /dev/null +++ b/testsuites/sptests/sp44/init.c @@ -0,0 +1,141 @@ +/* + * Original version submitted as part of PR1212 + * + * This example shows a possible blocking of timeslicing if task mode is + * changed to timeslicing in the middle of its executing. + * + * The expected output is: + * + * Task #0's turn. Now setting turn to 1 + * Task #1's turn. Now setting turn to 0 + * Task #0's turn. Now setting turn to 1 + * Task #1's turn. Now setting turn to 0 + * Task #0's turn. Now setting turn to 1 + * Task #1's turn. Now setting turn to 0 + * Task #0's turn. Now setting turn to 1 + * ... + * + * The actural output is: + * + * Task #0's turn. Now setting turn to 1 + * + * Task #1 can not be dispatched also both tasks have timeslice enabled. + * + * Setting TASK_A/B_INITMODE to RTEMS_DEFAULT_MODES | RTEMS_TIMESLICE + * will produce the expected output. + * + * $Id$ + */ + +#include <tmacros.h> +#include <rtems.h> +#include <stdio.h> +#include <stdlib.h> + +/*** Task priorities ***/ +#define TASK_A_PRIORITY 10 +#define TASK_B_PRIORITY 10 + +/*** Task names ***/ +#define TASK_A_NAME 1 +#define TASK_B_NAME 2 + +/*** Task atributes ***/ +#define TASK_A_INITMODE RTEMS_DEFAULT_MODES +#define TASK_B_INITMODE RTEMS_DEFAULT_MODES + +/*** Task generic parameters ***/ +#define TASK_A_STACKSIZE RTEMS_MINIMUM_STACK_SIZE +#define TASK_A_MODEATTR RTEMS_DEFAULT_ATTRIBUTES +#define TASK_B_STACKSIZE RTEMS_MINIMUM_STACK_SIZE +#define TASK_B_MODEATTR RTEMS_DEFAULT_ATTRIBUTES + +volatile uint32_t turn; +rtems_id TaskA_id, TaskB_id; + +#define TEST_FAILED(_status, _msg) \ + do { \ + printf("Test failed, status code: %d, msg: %s\n", _status, _msg); \ + exit(1); \ + } while(0) + +/* TASK A/B */ +rtems_task TaskAB_entry(rtems_task_argument me) +{ + static rtems_mode previous_mode_set; + rtems_status_code status; + uint32_t iterations = 0; + + status = rtems_task_mode(RTEMS_PREEMPT | RTEMS_TIMESLICE, + RTEMS_PREEMPT_MASK | RTEMS_TIMESLICE_MASK, + &previous_mode_set); + if (status != RTEMS_SUCCESSFUL) + TEST_FAILED(status, "Unable to change task mode."); + + while(1) { + if (turn == me) { + printf("Task #%d's turn. Now setting turn to %d\n", me, 1 - me); + turn = 1 - me; + + if ( ++iterations == 10 ) { + puts( "*** END OF SP44 TEST ***" ); + exit( 0 ); + } + } + } +} + +rtems_task Init(rtems_task_argument ignored) +{ + static rtems_status_code status; + + puts( "\n\n*** SP44 TEST ***" ); + + /* Create Task A */ + status = rtems_task_create(TASK_A_NAME, TASK_A_PRIORITY, TASK_A_STACKSIZE, + TASK_A_INITMODE, TASK_A_MODEATTR, &TaskA_id); + + if (status != RTEMS_SUCCESSFUL) + TEST_FAILED(status,"rtems_task_create failed.\n"); + + /* Start Task A */ + status = rtems_task_start(TaskA_id, TaskAB_entry, 0); + if (status != RTEMS_SUCCESSFUL) + TEST_FAILED(status,"rtems_task_start failed.\n"); + + /* Create Task B */ + status = rtems_task_create(TASK_B_NAME, TASK_B_PRIORITY, TASK_B_STACKSIZE, + TASK_B_INITMODE, TASK_B_MODEATTR, &TaskB_id); + + if (status != RTEMS_SUCCESSFUL) + TEST_FAILED(status,"rtems_task_create failed.\n"); + + /* Start Task B */ + status = rtems_task_start(TaskB_id, TaskAB_entry, 1); + if (status != RTEMS_SUCCESSFUL) + TEST_FAILED(status,"rtems_task_start failed.\n"); + + /* Suspend itself */ + status = rtems_task_suspend(RTEMS_SELF); + if (status != RTEMS_SUCCESSFUL) + TEST_FAILED(status,"rtems_task_suspend failed.\n"); + + /* This task is not suposed to be executed anymore */ + printf("\nNOT SUPOSED TO RETURN HERE...\n"); + exit(1); +} + +/* configuration information */ + +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER + +#define CONFIGURE_MICROSECONDS_PER_TICK 1000 +#define CONFIGURE_TICKS_PER_TIMESLICE 10 +#define CONFIGURE_MAXIMUM_TASKS 3 + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_INIT + +#include <rtems/confdefs.h> diff --git a/testsuites/sptests/sp44/sp44.scn b/testsuites/sptests/sp44/sp44.scn new file mode 100644 index 0000000000..30ed1242a9 --- /dev/null +++ b/testsuites/sptests/sp44/sp44.scn @@ -0,0 +1,21 @@ +*** SP44 TEST *** +Task #0's turn. Now setting turn to 1 +Task #1's turn. Now setting turn to 0 +Task #0's turn. Now setting turn to 1 +Task #1's turn. Now setting turn to 0 +Task #0's turn. Now setting turn to 1 +Task #1's turn. Now setting turn to 0 +Task #0's turn. Now setting turn to 1 +Task #1's turn. Now setting turn to 0 +Task #0's turn. Now setting turn to 1 +Task #1's turn. Now setting turn to 0 +Task #0's turn. Now setting turn to 1 +Task #1's turn. Now setting turn to 0 +Task #0's turn. Now setting turn to 1 +Task #1's turn. Now setting turn to 0 +Task #0's turn. Now setting turn to 1 +Task #1's turn. Now setting turn to 0 +Task #0's turn. Now setting turn to 1 +Task #1's turn. Now setting turn to 0 +Task #0's turn. Now setting turn to 1 +*** END OF SP44 TEST *** |