Changeset 54358 in vbox
- Timestamp:
- Feb 22, 2015 11:29:25 PM (10 years ago)
- Location:
- trunk/src/VBox/Runtime
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/misc/thread.cpp
r52457 r54358 74 74 *******************************************************************************/ 75 75 /** The AVL thread containing the threads. */ 76 static PAVLPVNODECORE g_ThreadTree; 76 static PAVLPVNODECORE g_ThreadTree; 77 /** The number of threads in the tree (for ring-0 termination kludge). */ 78 static uint32_t volatile g_cThreadInTree; 77 79 #ifdef IN_RING3 78 80 /** The RW lock protecting the tree. */ … … 455 457 fRc = RTAvlPVInsert(&g_ThreadTree, &pThread->Core); 456 458 ASMAtomicOrU32(&pThread->fIntFlags, RTTHREADINT_FLAG_IN_TREE); 459 if (fRc) 460 ASMAtomicIncU32(&g_cThreadInTree); 457 461 458 462 AssertReleaseMsg(fRc, ("Lock problem? %p (%RTnthrd) %s\n", pThread, NativeThread, pThread->szName)); … … 479 483 pThread, pThread->Core.Key, pThread->szName)); 480 484 #endif 481 NOREF(pThread2); 485 if (pThread2) 486 ASMAtomicDecU32(&g_cThreadInTree); 482 487 } 483 488 … … 1176 1181 */ 1177 1182 if (ASMAtomicBitTestAndClear(&pThread->fFlags, RTTHREADFLAGS_WAITABLE_BIT)) 1183 { 1178 1184 rtThreadRelease(pThread); 1185 #ifdef IN_RING0 1186 /* 1187 * IPRT termination kludge. Call native code to make sure 1188 * the last thread is really out of IPRT to prevent it from 1189 * crashing after we destroyed the spinlock in rtThreadTerm. 1190 */ 1191 if ( ASMAtomicReadU32(&g_cThreadInTree) == 1 1192 && ASMAtomicReadU32(&pThread->cRefs) > 1) 1193 rtThreadNativeWaitKludge(pThread); 1194 #endif 1195 } 1179 1196 } 1180 1197 } -
trunk/src/VBox/Runtime/include/internal/thread.h
r52457 r54358 176 176 DECLHIDDEN(void) rtThreadNativeDestroy(PRTTHREADINT pThread); 177 177 178 #ifdef IN_RING0 179 /** 180 * Called from rtThreadWait when the last thread has completed in order to make 181 * sure it's all the way out of IPRT before RTR0Term is called. 182 * 183 * @param pThread The thread structure. 184 */ 185 DECLHIDDEN(void) rtThreadNativeWaitKludge(PRTTHREADINT pThread); 186 #endif 187 188 178 189 /** 179 190 * Sets the priority of the thread according to the thread type -
trunk/src/VBox/Runtime/r0drv/darwin/thread2-r0drv-darwin.cpp
r48935 r54358 137 137 138 138 139 DECLHIDDEN(void) rtThreadNativeWaitKludge(PRTTHREADINT pThread) 140 { 141 /** @todo fix RTThreadWait/RTR0Term race on darwin. */ 142 RTThreadSleep(1); 143 } 144 145 139 146 DECLHIDDEN(void) rtThreadNativeDestroy(PRTTHREADINT pThread) 140 147 { -
trunk/src/VBox/Runtime/r0drv/freebsd/thread2-r0drv-freebsd.c
r36555 r54358 99 99 100 100 101 DECLHIDDEN(void) rtThreadNativeWaitKludge(PRTTHREADINT pThread) 102 { 103 /** @todo fix RTThreadWait/RTR0Term race on freebsd. */ 104 RTThreadSleep(1); 105 } 106 107 101 108 DECLHIDDEN(void) rtThreadNativeDestroy(PRTTHREADINT pThread) 102 109 { -
trunk/src/VBox/Runtime/r0drv/haiku/thread2-r0drv-haiku.c
r43403 r54358 41 41 42 42 43 intrtThreadNativeInit(void)43 DECLHIDDEN(int) rtThreadNativeInit(void) 44 44 { 45 45 /* No TLS in Ring-0. :-/ */ … … 54 54 55 55 56 intrtThreadNativeSetPriority(PRTTHREADINT pThread, RTTHREADTYPE enmType)56 DECLHIDDEN(int) rtThreadNativeSetPriority(PRTTHREADINT pThread, RTTHREADTYPE enmType) 57 57 { 58 58 int32 iPriority; … … 82 82 83 83 84 intrtThreadNativeAdopt(PRTTHREADINT pThread)84 DECLHIDDEN(int) rtThreadNativeAdopt(PRTTHREADINT pThread) 85 85 { 86 86 return VERR_NOT_IMPLEMENTED; … … 88 88 89 89 90 void rtThreadNativeDestroy(PRTTHREADINT pThread) 90 DECLHIDDEN(void) rtThreadNativeWaitKludge(PRTTHREADINT pThread) 91 { 92 /** @todo fix RTThreadWait/RTR0Term race on freebsd. */ 93 RTThreadSleep(1); 94 } 95 96 97 DECLHIDDEN(void) rtThreadNativeDestroy(PRTTHREADINT pThread) 91 98 { 92 99 NOREF(pThread); … … 115 122 116 123 117 intrtThreadNativeCreate(PRTTHREADINT pThreadInt, PRTNATIVETHREAD pNativeThread)124 DECLHIDDEN(int) rtThreadNativeCreate(PRTTHREADINT pThreadInt, PRTNATIVETHREAD pNativeThread) 118 125 { 119 126 thread_id NativeThread; -
trunk/src/VBox/Runtime/r0drv/linux/thread2-r0drv-linux.c
r48935 r54358 103 103 104 104 105 DECLHIDDEN(void) rtThreadNativeWaitKludge(PRTTHREADINT pThread) 106 { 107 /** @todo fix RTThreadWait/RTR0Term race on linux. */ 108 RTThreadSleep(1); NOREF(pThread); 109 } 110 111 105 112 DECLHIDDEN(void) rtThreadNativeDestroy(PRTTHREADINT pThread) 106 113 { -
trunk/src/VBox/Runtime/r0drv/nt/thread2-r0drv-nt.cpp
r48935 r54358 88 88 89 89 90 DECLHIDDEN(void) rtThreadNativeWaitKludge(PRTTHREADINT pThread) 91 { 92 PVOID pvThreadObj = pThread->Core.Key; 93 NTSTATUS rcNt = KeWaitForSingleObject(pvThreadObj, Executive, KernelMode, FALSE, NULL); 94 AssertMsg(rcNt == STATUS_SUCCESS, ("rcNt=%#x\n", rcNt)); 95 } 96 97 90 98 DECLHIDDEN(void) rtThreadNativeDestroy(PRTTHREADINT pThread) 91 99 { -
trunk/src/VBox/Runtime/r0drv/os2/thread2-r0drv-os2.cpp
r48935 r54358 65 65 } 66 66 67 DECLHIDDEN(void) rtThreadNativeWaitKludge(PRTTHREADINT pThread) 68 { 69 NOREF(pThread); 70 } 71 67 72 68 73 DECLHIDDEN(void) rtThreadNativeDestroy(PRTTHREADINT pThread) -
trunk/src/VBox/Runtime/r0drv/solaris/thread2-r0drv-solaris.c
r52983 r54358 86 86 87 87 88 DECLHIDDEN(void) rtThreadNativeWaitKludge(PRTTHREADINT pThread) 89 { 90 kthread_t *pThread = (kthread_t *)pThread->Core.Key; 91 thread_join(pThread); 92 } 93 94 88 95 DECLHIDDEN(void) rtThreadNativeDestroy(PRTTHREADINT pThread) 89 96 {
Note:
See TracChangeset
for help on using the changeset viewer.