Changeset 75498 in vbox for trunk/src/VBox/Main/src-client
- Timestamp:
- Nov 16, 2018 12:03:41 AM (6 years ago)
- Location:
- trunk/src/VBox/Main/src-client
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/HGCM.cpp
r75497 r75498 909 909 RTStrCopy(szThreadName, sizeof(szThreadName), pszServiceName); 910 910 911 int rc = hgcmThreadCreate(&m_thread, szThreadName, hgcmServiceThread, this );911 int rc = hgcmThreadCreate(&m_thread, szThreadName, hgcmServiceThread, this, pszServiceName, pUVM); 912 912 913 913 if (RT_SUCCESS(rc)) … … 2681 2681 */ 2682 2682 2683 rc = hgcmThreadCreate(&g_hgcmThread, "MainHGCMthread", hgcmThread, NULL );2683 rc = hgcmThreadCreate(&g_hgcmThread, "MainHGCMthread", hgcmThread, NULL /*pvUser*/, NULL /*pszStatsSubDir*/, NULL /*pUVM*/); 2684 2684 2685 2685 if (RT_FAILURE(rc)) -
trunk/src/VBox/Main/src-client/HGCMThread.cpp
r69500 r75498 22 22 23 23 #include <VBox/err.h> 24 #include <VBox/vmm/stam.h> 24 25 #include <iprt/semaphore.h> 25 26 #include <iprt/thread.h> … … 119 120 HGCMTHREADHANDLE m_handle; 120 121 122 /** @name Statistics 123 * @{ */ 124 STAMCOUNTER m_StatPostMsgNoPending; 125 STAMCOUNTER m_StatPostMsgOnePending; 126 STAMCOUNTER m_StatPostMsgTwoPending; 127 STAMCOUNTER m_StatPostMsgThreePending; 128 STAMCOUNTER m_StatPostMsgManyPending; 129 /** @} */ 130 121 131 inline int Enter (void); 122 132 inline void Leave (void); … … 133 143 int WaitForTermination (void); 134 144 135 int Initialize (HGCMTHREADHANDLE handle, const char *pszThreadName, PFNHGCMTHREAD pfnThread, void *pvUser); 145 int Initialize (HGCMTHREADHANDLE handle, const char *pszThreadName, PFNHGCMTHREAD pfnThread, void *pvUser, 146 const char *pszStatsSubDir, PUVM pUVM); 136 147 137 148 int MsgAlloc (HGCMMSGHANDLE *pHandle, uint32_t u32MsgId, PFNHGCMNEWMSGALLOC pfnNewMessage); … … 264 275 } 265 276 266 int HGCMThread::Initialize (HGCMTHREADHANDLE handle, const char *pszThreadName, PFNHGCMTHREAD pfnThread, void *pvUser) 267 { 268 int rc = VINF_SUCCESS; 269 270 rc = RTSemEventMultiCreate (&m_eventThread); 277 int HGCMThread::Initialize (HGCMTHREADHANDLE handle, const char *pszThreadName, PFNHGCMTHREAD pfnThread, void *pvUser, 278 const char *pszStatsSubDir, PUVM pUVM) 279 { 280 int rc = RTSemEventMultiCreate (&m_eventThread); 271 281 272 282 if (RT_SUCCESS(rc)) … … 294 304 if (RT_SUCCESS(rc)) 295 305 { 306 /* Register statistics while the thread starts. */ 307 if (pUVM) 308 { 309 STAMR3RegisterFU(pUVM, &m_StatPostMsgNoPending, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, 310 "Times a message was appended to an empty input queue.", 311 "/HGCM/%s/PostMsg0Pending", pszStatsSubDir); 312 STAMR3RegisterFU(pUVM, &m_StatPostMsgOnePending, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, 313 "Times a message was appended to input queue with only one pending message.", 314 "/HGCM/%s/PostMsg1Pending", pszStatsSubDir); 315 STAMR3RegisterFU(pUVM, &m_StatPostMsgTwoPending, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, 316 "Times a message was appended to input queue with only one pending message.", 317 "/HGCM/%s/PostMsg2Pending", pszStatsSubDir); 318 STAMR3RegisterFU(pUVM, &m_StatPostMsgTwoPending, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, 319 "Times a message was appended to input queue with only one pending message.", 320 "/HGCM/%s/PostMsg3Pending", pszStatsSubDir); 321 STAMR3RegisterFU(pUVM, &m_StatPostMsgManyPending, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, 322 "Times a message was appended to input queue with only one pending message.", 323 "/HGCM/%s/PostMsgManyPending", pszStatsSubDir); 324 } 325 326 296 327 /* Wait until the thread is ready. */ 297 328 rc = RTThreadUserWait (thread, 30000); … … 314 345 { 315 346 Log(("hgcmThreadCreate: FAILURE: Can't create an event semaphore for a sent messages.\n")); 316 m_eventSend = 0;347 m_eventSend = NIL_RTSEMEVENTMULTI; 317 348 } 318 349 } … … 320 351 { 321 352 Log(("hgcmThreadCreate: FAILURE: Can't create an event semaphore for a hgcm worker thread.\n")); 322 m_eventThread = 0;353 m_eventThread = NIL_RTSEMEVENTMULTI; 323 354 } 324 355 … … 409 440 /* Insert the message to the queue tail. */ 410 441 pMsg->m_pNext = NULL; 411 pMsg->m_pPrev = m_pMsgInputQueueTail; 412 413 if (m_pMsgInputQueueTail) 414 { 415 m_pMsgInputQueueTail->m_pNext = pMsg; 442 HGCMMsgCore * const pPrev = m_pMsgInputQueueTail; 443 pMsg->m_pPrev = pPrev; 444 445 if (pPrev) 446 { 447 pPrev->m_pNext = pMsg; 448 if (!pPrev->m_pPrev) 449 STAM_REL_COUNTER_INC(&m_StatPostMsgOnePending); 450 else if (!pPrev->m_pPrev) 451 STAM_REL_COUNTER_INC(&m_StatPostMsgTwoPending); 452 else if (!pPrev->m_pPrev->m_pPrev) 453 STAM_REL_COUNTER_INC(&m_StatPostMsgThreePending); 454 else 455 STAM_REL_COUNTER_INC(&m_StatPostMsgManyPending); 416 456 } 417 457 else 418 458 { 419 459 m_pMsgInputQueueHead = pMsg; 460 STAM_REL_COUNTER_INC(&m_StatPostMsgNoPending); 420 461 } 421 462 … … 630 671 */ 631 672 632 int hgcmThreadCreate (HGCMTHREADHANDLE *pHandle, const char *pszThreadName, PFNHGCMTHREAD pfnThread, void *pvUser) 673 int hgcmThreadCreate (HGCMTHREADHANDLE *pHandle, const char *pszThreadName, PFNHGCMTHREAD pfnThread, void *pvUser, 674 const char *pszStatsSubDir, PUVM pUVM) 633 675 { 634 676 int rc = VINF_SUCCESS; … … 647 689 648 690 /* Initialize the object. */ 649 rc = pThread->Initialize (handle, pszThreadName, pfnThread, pvUser );691 rc = pThread->Initialize (handle, pszThreadName, pfnThread, pvUser, pszStatsSubDir, pUVM); 650 692 } 651 693 else
Note:
See TracChangeset
for help on using the changeset viewer.