diff options
author | wtc%netscape.com <devnull@localhost> | 2001-06-05 04:51:46 +0000 |
---|---|---|
committer | wtc%netscape.com <devnull@localhost> | 2001-06-05 04:51:46 +0000 |
commit | 64dc7e40ab3aed7b13938bcd4be5c1e2d31ebd33 (patch) | |
tree | 5f0ca78ac9e5cf702bf6da5397c6b29a33341309 | |
parent | 48d1de3ad7396cf7f1631293ffc96a543f1f18d0 (diff) | |
download | nspr-hg-64dc7e40ab3aed7b13938bcd4be5c1e2d31ebd33.tar.gz |
Bugzilla bug #30746: in combined MxN thread model, let the primordial
thread remain a native thread. Create a separate CPU thread to run
the local threads.
Modified files: prucpu.c, pruthr.c
-rw-r--r-- | pr/src/threads/combined/prucpu.c | 34 | ||||
-rw-r--r-- | pr/src/threads/combined/pruthr.c | 26 |
2 files changed, 42 insertions, 18 deletions
diff --git a/pr/src/threads/combined/prucpu.c b/pr/src/threads/combined/prucpu.c index 882fe82f..d9159b52 100644 --- a/pr/src/threads/combined/prucpu.c +++ b/pr/src/threads/combined/prucpu.c @@ -61,6 +61,10 @@ static void PR_CALLBACK _PR_CPU_Idle(void *); static _PRCPU *_PR_CreateCPU(PRThread *thread, PRBool needQueue); +#if !defined(_PR_LOCAL_THREADS_ONLY) +static void _PR_RunCPU(void *arg); +#endif + void _PR_InitCPUs() { PRThread *me = _PR_MD_CURRENT_THREAD(); @@ -73,6 +77,8 @@ void _PR_InitCPUs() #endif #endif +#ifdef _PR_LOCAL_THREADS_ONLY + #ifdef HAVE_CUSTOM_USER_THREADS if (!_native_threads_only) _PR_MD_CREATE_PRIMORDIAL_USER_THREAD(me); @@ -89,6 +95,20 @@ void _PR_InitCPUs() _PR_MD_SET_LAST_THREAD(me); +#else /* Combined MxN model */ + + _PR_CreateThread(PR_SYSTEM_THREAD, + _PR_RunCPU, + me, + PR_PRIORITY_NORMAL, + PR_GLOBAL_THREAD, + PR_UNJOINABLE_THREAD, + 0, + _PR_IDLE_THREAD); + _PR_MD_WAIT(me, PR_INTERVAL_NO_TIMEOUT); + +#endif /* _PR_LOCAL_THREADS_ONLY */ + _PR_MD_INIT_CPUS(); } @@ -187,14 +207,11 @@ static _PRCPU *_PR_CreateCPU(PRThread *thread, PRBool needQueue) /* ** This code is used during a cpu's initial creation. */ -static void _PR_RunCPU(void *unused) +static void _PR_RunCPU(void *arg) { -#if defined(XP_MAC) -#pragma unused (unused) -#endif - _PRCPU *cpu; PRThread *me = _PR_MD_CURRENT_THREAD(); + PRThread *waiter = (PRThread *) arg; PR_ASSERT(NULL != me); @@ -228,6 +245,13 @@ static void _PR_RunCPU(void *unused) _PR_MD_SET_CURRENT_CPU(cpu); _PR_MD_SET_CURRENT_THREAD(cpu->thread); me->cpu = cpu; + + if (waiter) { + _pr_primordialCPU = cpu; + _pr_numCPU = 1; + _PR_MD_WAKEUP_WAITER(waiter); + } + while(1) { PRInt32 is; if (!_PR_IS_NATIVE_THREAD(me)) _PR_INTSOFF(is); diff --git a/pr/src/threads/combined/pruthr.c b/pr/src/threads/combined/pruthr.c index c95decec..ac7e9eb6 100644 --- a/pr/src/threads/combined/pruthr.c +++ b/pr/src/threads/combined/pruthr.c @@ -147,15 +147,12 @@ void _PR_InitThreads(PRThreadType type, PRThreadPriority priority, } if (!thread) PR_Abort(); -#ifdef _PR_GLOBAL_THREADS_ONLY - thread->flags |= _PR_PRIMORDIAL | _PR_GLOBAL_SCOPE; -#else +#ifdef _PR_LOCAL_THREADS_ONLY thread->flags |= _PR_PRIMORDIAL; +#else + thread->flags |= _PR_PRIMORDIAL | _PR_GLOBAL_SCOPE; #endif - if (_native_threads_only) - thread->flags |= _PR_GLOBAL_SCOPE; - /* * Needs _PR_PRIMORDIAL flag set before calling * _PR_MD_INIT_THREAD() @@ -366,10 +363,10 @@ _PR_UserDestroyThread(PRThread *thread) _PR_MD_CLEAN_THREAD(thread); #else /* - * This assertion does not apply to NT. On NT, every fiber, - * including the primordial thread, has its threadAllocatedOnStack - * equal to 0. Elsewhere, only the primordial thread has its - * threadAllocatedOnStack equal to 0. + * This assertion does not apply to NT. On NT, every fiber + * has its threadAllocatedOnStack equal to 0. Elsewhere, + * only the primordial thread has its threadAllocatedOnStack + * equal to 0. */ PR_ASSERT(thread->flags & _PR_PRIMORDIAL); #endif @@ -1373,15 +1370,16 @@ PR_IMPLEMENT(PRThread*) _PR_CreateThread(PRThreadType type, else thread->cpu = _PR_MD_CURRENT_CPU(); - if ((! (thread->flags & _PR_IDLE_THREAD)) && !_PR_IS_NATIVE_THREAD(me)) + PR_ASSERT(!_PR_IS_NATIVE_THREAD(thread)); + + if ((! (thread->flags & _PR_IDLE_THREAD)) && !_PR_IS_NATIVE_THREAD(me)) { _PR_INTSOFF(is); - if ((! (thread->flags & _PR_IDLE_THREAD)) && !_PR_IS_NATIVE_THREAD(thread)) { _PR_RUNQ_LOCK(thread->cpu); _PR_ADD_RUNQ(thread, thread->cpu, priority); _PR_RUNQ_UNLOCK(thread->cpu); } - if ((thread->flags & _PR_IDLE_THREAD) || _PR_IS_NATIVE_THREAD(me)) { + if (thread->flags & _PR_IDLE_THREAD) { /* ** If the creating thread is a kernel thread, we need to ** awaken the user thread idle thread somehow; potentially @@ -1389,6 +1387,8 @@ PR_IMPLEMENT(PRThread*) _PR_CreateThread(PRThreadType type, ** it. To do so, wake the idle thread... */ _PR_MD_WAKEUP_WAITER(NULL); + } else if (_PR_IS_NATIVE_THREAD(me)) { + _PR_MD_WAKEUP_WAITER(thread); } if ((! (thread->flags & _PR_IDLE_THREAD)) && !_PR_IS_NATIVE_THREAD(me) ) _PR_INTSON(is); |