Bool is char, a 4 CPU 8-bit variable array will crate a race, where CPU1 might 
over write CPU2 and CPU3 task execution status. There is no atomic locking of 
the TaskRan array.

Daniel

On 10/31/2013 03:17 PM, Gedare Bloom wrote:
I don't understand the problem being solved here / the reason for this
change from bool to int.

On Thu, Oct 31, 2013 at 9:58 AM, Daniel Hellstrom <dan...@gaisler.com> wrote:
Switch to using 32-bit variable that works better on a
32-bit CPU. This does not solve the general SMP case
though, would perhaps better to use an atomic set
here.

Signed-off-by: Daniel Hellstrom <dan...@gaisler.com>
---
  testsuites/smptests/smp01/init.c   |    6 +++---
  testsuites/smptests/smp01/system.h |    2 +-
  testsuites/smptests/smp01/tasks.c  |    2 +-
  3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/testsuites/smptests/smp01/init.c b/testsuites/smptests/smp01/init.c
index 3e12726..eadb26a 100644
--- a/testsuites/smptests/smp01/init.c
+++ b/testsuites/smptests/smp01/init.c
@@ -43,11 +43,11 @@ rtems_task Init(
    locked_print_initialize();

    /* Put start of test message */
-  locked_printf( "\n\n***  SMP01 TEST ***\n" );
+  locked_printf( "\n\n***  SMP01 TEST %d ***\n", cpu_self );

    /* Initialize the TaskRan array */
    for ( i=0; i<rtems_smp_get_processor_count() ; i++ ) {
-    TaskRan[i] = false;
+    TaskRan[i] = 0;
    }

    /* Create and start tasks for each processor */
@@ -77,7 +77,7 @@ rtems_task Init(
    while (1) {
      allDone = true;
      for ( i=0; i<rtems_smp_get_processor_count() ; i++ ) {
-      if ( i != cpu_self && TaskRan[i] == false)
+      if ( i != cpu_self && TaskRan[i] == 0)
          allDone = false;
      }
      if (allDone) {
diff --git a/testsuites/smptests/smp01/system.h 
b/testsuites/smptests/smp01/system.h
index e360e37..5f2d5b7 100644
--- a/testsuites/smptests/smp01/system.h
+++ b/testsuites/smptests/smp01/system.h
@@ -42,7 +42,7 @@ rtems_task Test_task(
   *  Keep the names and IDs in global variables so another task can use them.
   */

-TEST_EXTERN volatile bool TaskRan[ CONFIGURE_SMP_MAXIMUM_PROCESSORS ];
+TEST_EXTERN volatile int TaskRan[ CONFIGURE_SMP_MAXIMUM_PROCESSORS ];

  void Loop( void );

diff --git a/testsuites/smptests/smp01/tasks.c 
b/testsuites/smptests/smp01/tasks.c
index 4eb81f1..7bd7cc4 100644
--- a/testsuites/smptests/smp01/tasks.c
+++ b/testsuites/smptests/smp01/tasks.c
@@ -35,7 +35,7 @@ rtems_task Test_task(
    locked_printf(" CPU %" PRIu32 " running Task %s\n", cpu_num, name);

    /* Set the flag that the task is up and running */
-  TaskRan[cpu_num] = true;
+  TaskRan[cpu_num] = 1;


    /* Drop into a loop which will keep this task on
--
1.7.0.4

_______________________________________________
rtems-devel mailing list
rtems-devel@rtems.org
http://www.rtems.org/mailman/listinfo/rtems-devel

_______________________________________________
rtems-devel mailing list
rtems-devel@rtems.org
http://www.rtems.org/mailman/listinfo/rtems-devel

Reply via email to