Bugzilla bug 30746: fixed the problem of the previous NT primordial thread
authorwtc%netscape.com
Fri, 22 Feb 2002 02:52:28 +0000
changeset 2269 5cfa8d30e3c543199642de45fe3f5782eecb3f16
parent 2268 e3c2dc8ad80b4cbd70d6e1a39cd1f28c344a19af
child 2270 ecde1e44481790db360d2c13f866fcc1c6494025
push idunknown
push userunknown
push dateunknown
bugs30746
Bugzilla bug 30746: fixed the problem of the previous NT primordial thread fix in native threads only mode.
pr/src/threads/combined/prucpu.c
--- a/pr/src/threads/combined/prucpu.c
+++ b/pr/src/threads/combined/prucpu.c
@@ -65,29 +65,31 @@ static PRStatus _PR_StartCPU(_PRCPU *cpu
 #if !defined(_PR_LOCAL_THREADS_ONLY)
 static void _PR_RunCPU(void *arg);
 #endif
 
 void  _PR_InitCPUs()
 {
     PRThread *me = _PR_MD_CURRENT_THREAD();
 
+    if (_native_threads_only)
+        return;
+
     _pr_cpuID = 0;
     _MD_NEW_LOCK( &_pr_cpuLock);
 #if !defined(_PR_LOCAL_THREADS_ONLY) && !defined(_PR_GLOBAL_THREADS_ONLY)
 #ifndef _PR_HAVE_ATOMIC_OPS
     _MD_NEW_LOCK(&_pr_md_idle_cpus_lock);
 #endif
 #endif
 
 #ifdef _PR_LOCAL_THREADS_ONLY
 
 #ifdef HAVE_CUSTOM_USER_THREADS
-	if (!_native_threads_only)
-    	_PR_MD_CREATE_PRIMORDIAL_USER_THREAD(me);
+    _PR_MD_CREATE_PRIMORDIAL_USER_THREAD(me);
 #endif
 
     /* Now start the first CPU. */
     _pr_primordialCPU = _PR_CreateCPU();
     _pr_numCPU = 1;
     _PR_StartCPU(_pr_primordialCPU, me);
 
     _PR_MD_SET_CURRENT_CPU(_pr_primordialCPU);
@@ -183,44 +185,44 @@ static _PRCPU *_PR_CreateCPU(void)
 static PRStatus _PR_StartCPU(_PRCPU *cpu, PRThread *thread)
 {
     /*
     ** Start a new cpu. The assumption this code makes is that the
     ** underlying operating system creates a stack to go with the new
     ** native thread. That stack will be used by the cpu when pausing.
     */
 
+    PR_ASSERT(!_native_threads_only);
+
     cpu->last_clock = PR_IntervalNow();
 
     /* Before we create any threads on this CPU we have to
      * set the current CPU 
      */
     _PR_MD_SET_CURRENT_CPU(cpu);
     _PR_MD_INIT_RUNNING_CPU(cpu);
     thread->cpu = cpu;
 
-    if (!_native_threads_only) {
-        cpu->idle_thread = _PR_CreateThread(PR_SYSTEM_THREAD,
-                                            _PR_CPU_Idle,
-                                            (void *)cpu,
-                                            PR_PRIORITY_NORMAL,
-                                            PR_LOCAL_THREAD,
-                                            PR_UNJOINABLE_THREAD,
-                                            0,
-                                            _PR_IDLE_THREAD);
+    cpu->idle_thread = _PR_CreateThread(PR_SYSTEM_THREAD,
+                                        _PR_CPU_Idle,
+                                        (void *)cpu,
+                                        PR_PRIORITY_NORMAL,
+                                        PR_LOCAL_THREAD,
+                                        PR_UNJOINABLE_THREAD,
+                                        0,
+                                        _PR_IDLE_THREAD);
 
-        if (!cpu->idle_thread) {
-            /* didn't clean up CPU queue XXXMB */
-            PR_DELETE(cpu);
-            return PR_FAILURE;
-        } 
-        PR_ASSERT(cpu->idle_thread->cpu == cpu);
+    if (!cpu->idle_thread) {
+        /* didn't clean up CPU queue XXXMB */
+        PR_DELETE(cpu);
+        return PR_FAILURE;
+    } 
+    PR_ASSERT(cpu->idle_thread->cpu == cpu);
 
-        cpu->idle_thread->no_sched = 0;
-    }
+    cpu->idle_thread->no_sched = 0;
 
     cpu->thread = thread;
 
     if (_pr_cpu_affinity_mask)
         PR_SetThreadAffinityMask(thread, _pr_cpu_affinity_mask);
 
     /* Created and started a new CPU */
     _PR_CPU_LIST_LOCK();