diff packages/kernel/current/tests/testaux.hxx @ 191:678094f34118

Merge from eCos master repository on 2001-10-19-06:43:02-BST
author jlarmour
date Fri, 19 Oct 2001 07:02:26 +0000
parents eb9fd8c04db3
children e0c0827131d1
line wrap: on
line diff
--- a/packages/kernel/current/tests/testaux.hxx
+++ b/packages/kernel/current/tests/testaux.hxx
@@ -73,22 +73,24 @@ static CYG_ALIGNMENT_TYPE stack[NTHREADS
    (STACKSIZE+sizeof(CYG_ALIGNMENT_TYPE)-1)
      / sizeof(CYG_ALIGNMENT_TYPE)                     ];
 
-static int nthreads = 0;
+static volatile int nthreads = 0;
 
-static Cyg_Thread *new_thread(cyg_thread_entry *entry, CYG_ADDRWORD data) {
+static Cyg_Thread *new_thread(cyg_thread_entry *entry, CYG_ADDRWORD data)
+{
+    int _nthreads = nthreads++;
 
-    CYG_ASSERT(nthreads < NTHREADS, 
+    CYG_ASSERT(_nthreads < NTHREADS, 
                "Attempt to create more than NTHREADS threads");
 
-    thread[nthreads] = new( (void *)&thread_obj[nthreads] )
+    thread[_nthreads] = new( (void *)&thread_obj[_nthreads] )
         Cyg_Thread(CYG_SCHED_DEFAULT_INFO,
                    entry, data, 
                    NULL,                // no name
-                   (CYG_ADDRESS)stack[nthreads], STACKSIZE );
+                   (CYG_ADDRESS)stack[_nthreads], STACKSIZE );
 
-    thread[nthreads]->resume();
+    thread[_nthreads]->resume();
 
-    return thread[nthreads++];
+    return thread[_nthreads];
 }
 #endif // defined(NTHREADS)