- Timestamp:
- Apr 2, 2019 10:23:09 AM (6 years ago)
- Location:
- trunk/src/VBox/Runtime
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/misc/thread.cpp
r76553 r77982 73 73 * Global Variables * 74 74 *********************************************************************************************************************************/ 75 /** The AVL thread containing the threads. */ 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; 75 /** Indicates whether we've been initialized or not. */ 76 static bool g_frtThreadInitialized; 79 77 #ifdef IN_RING3 80 78 /** The RW lock protecting the tree. */ 81 static RTSEMRW g_ThreadRWSem = NIL_RTSEMRW;79 static RTSEMRW g_ThreadRWSem = NIL_RTSEMRW; 82 80 #else 83 81 /** The spinlocks protecting the tree. */ 84 static RTSPINLOCK g_ThreadSpinlock = NIL_RTSPINLOCK; 85 #endif 86 /** Indicates whether we've been initialized or not. */ 87 static bool g_frtThreadInitialized; 82 static RTSPINLOCK g_ThreadSpinlock = NIL_RTSPINLOCK; 83 #endif 84 /** The AVL thread containing the threads. */ 85 static PAVLPVNODECORE g_ThreadTree; 86 /** The number of threads in the tree (for ring-0 termination kludge). */ 87 static uint32_t volatile g_cThreadInTree; 88 /** Counters for each thread type. */ 89 DECLHIDDEN(uint32_t volatile) g_acRTThreadTypeStats[RTTHREADTYPE_END]; 88 90 89 91 … … 460 462 ASMAtomicOrU32(&pThread->fIntFlags, RTTHREADINT_FLAG_IN_TREE); 461 463 if (fRc) 464 { 462 465 ASMAtomicIncU32(&g_cThreadInTree); 466 ASMAtomicIncU32(&g_acRTThreadTypeStats[pThread->enmType]); 467 } 463 468 464 469 AssertReleaseMsg(fRc, ("Lock problem? %p (%RTnthrd) %s\n", pThread, NativeThread, pThread->szName)); … … 481 486 { 482 487 PRTTHREADINT pThread2 = (PRTTHREADINT)RTAvlPVRemove(&g_ThreadTree, pThread->Core.Key); 483 #if !defined(RT_OS_OS2) /** @todo this asserts for threads created by NSPR */484 488 AssertMsg(pThread2 == pThread, ("%p(%s) != %p (%p/%s)\n", pThread2, pThread2 ? pThread2->szName : "<null>", 485 489 pThread, pThread->Core.Key, pThread->szName)); 486 #endif487 490 if (pThread2) 491 { 488 492 ASMAtomicDecU32(&g_cThreadInTree); 493 ASMAtomicDecU32(&g_acRTThreadTypeStats[pThread->enmType]); 494 } 489 495 } 490 496 -
trunk/src/VBox/Runtime/include/internal/thread.h
r77910 r77982 137 137 /** @} */ 138 138 139 /** Counters for each thread type. */ 140 extern DECLHIDDEN(uint32_t volatile) g_acRTThreadTypeStats[RTTHREADTYPE_END]; 141 139 142 140 143 /** -
trunk/src/VBox/Runtime/r3/linux/sched-linux.cpp
r77917 r77982 54 54 #include <errno.h> 55 55 #include <pthread.h> 56 #include <limits.h> 56 57 #include <sched.h> 57 58 #include <unistd.h> … … 542 543 543 544 /* 544 * Set the priority to the current value for specified thread type 545 */ 546 if (setpriority(PRIO_PROCESS, 0, pPrioPair->iCurrent)) 547 rc = RTErrConvertFromErrno(errno); 545 * Set the priority to the current value for specified thread type, but 546 * only if we have any threads of this type (caller checked - INT_MAX). 547 */ 548 if (pPrioPair->iCurrent != INT_MAX) 549 if (setpriority(PRIO_PROCESS, 0, pPrioPair->iCurrent)) 550 rc = RTErrConvertFromErrno(errno); 548 551 549 552 /* … … 572 575 static int rtSchedNativeCheckThreadTypes(const PROCPRIORITY *pCfg, bool fHavePriorityProxy) 573 576 { 574 /** @todo Only check transitions of thread types that actually are in use.575 * For the others, just check we can create threads with the new priority576 * scheme (ignoring the old). Best done by having an array of577 * per-threadtype counters in common/misc/thread.cpp. */578 577 int i = RTTHREADTYPE_END; 579 578 while (--i > RTTHREADTYPE_INVALID) … … 582 581 PrioPair.iCurrent = g_pProcessPriority->paTypes[i].iPriority + g_pProcessPriority->iDelta; 583 582 PrioPair.iNew = pCfg->paTypes[i].iPriority + pCfg->iDelta; 583 if (g_acRTThreadTypeStats[i] == 0) 584 PrioPair.iCurrent = INT_MAX; 584 585 585 586 #ifdef RT_STRICT
Note:
See TracChangeset
for help on using the changeset viewer.