Changeset 47572 in vbox
- Timestamp:
- Aug 7, 2013 9:51:45 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/mangling.h
r47516 r47572 1592 1592 # define RTThreadCreateF RT_MANGLER(RTThreadCreateF) 1593 1593 # define RTThreadCreateV RT_MANGLER(RTThreadCreateV) 1594 # define RTThreadCtxHooksAreRegistered RT_MANGLER(RTThreadCtxHooksAreRegistered) /* r0drv */ 1594 1595 # define RTThreadCtxHooksCreate RT_MANGLER(RTThreadCtxHooksCreate) /* r0drv */ 1595 1596 # define RTThreadCtxHooksDeregister RT_MANGLER(RTThreadCtxHooksDeregister) /* r0drv */ -
trunk/include/iprt/thread.h
r47370 r47572 637 637 * 638 638 * @returns New reference count. 639 * @retval 0 if the thread-context hook was freed or the handle was639 * @retval 0 if the thread-context hook was freed or @a hThreadCtx is 640 640 * NIL_RTTHREADCTX. 641 641 * @retval UINT32_MAX is returned if the handle is invalid (asserted). 642 642 * 643 * @param phThreadCtx Pointer to the thread-context handle (can be 644 * NIL_RTTHREADCTX). 643 * @param hThreadCtx The thread-context handle. 645 644 * 646 645 * @remarks This can be called from any thread but must be called with … … 654 653 * 655 654 * @returns IPRT status code. 656 * @param phThreadCtx Poinner to the thread-context handle.655 * @param hThreadCtx The thread-context handle. 657 656 * @param pfnThreadHook Pointer to a thread-context hook (a callback) 658 657 * for all thread-context events. … … 667 666 * 668 667 * @returns IPRT status code. 669 * @param phThreadCtx Pointer to the thread-context handle.668 * @param hThreadCtx The thread-context handle. 670 669 * 671 670 * @remarks Can be called with preemption disabled. 672 671 */ 673 672 RTDECL(int) RTThreadCtxHooksDeregister(RTTHREADCTX hThreadCtx); 673 674 /** 675 * Are thread-context hooks registered for the thread? 676 * 677 * @returns true if registered, false if not supported or not registered. 678 * @param hThreadCtx The thread-context handle. 679 * 680 * @remarks Can be called from any thread (but possibility of races when 681 * it's not the current thread!) 682 */ 683 RTDECL(bool) RTThreadCtxHooksAreRegistered(RTTHREADCTX hThreadCtx); 674 684 675 685 # endif /* IN_RING0 */ -
trunk/src/VBox/HostDrivers/Support/SUPDrv.c
r47542 r47572 367 367 { "RTStrPrintfV", (void *)RTStrPrintfV }, 368 368 { "RTThreadCreate", (void *)RTThreadCreate }, 369 { "RTThreadCtxHooksAreRegistered", (void *)RTThreadCtxHooksAreRegistered }, 369 370 { "RTThreadCtxHooksCreate", (void *)RTThreadCtxHooksCreate }, 370 371 { "RTThreadCtxHooksDeregister", (void *)RTThreadCtxHooksDeregister }, -
trunk/src/VBox/Runtime/r0drv/generic/threadctxhooks-r0drv-generic.cpp
r47352 r47572 75 75 RT_EXPORT_SYMBOL(RTThreadCtxHooksDeregister); 76 76 77 78 RTDECL(bool) RTThreadCtxHooksAreRegistered(RTTHREADCTX hThreadCtx) 79 { 80 NOREF(hThreadCtx); 81 return false; 82 } 83 RT_EXPORT_SYMBOL(RTThreadCtxHooksAreRegistered); 84 -
trunk/src/VBox/Runtime/r0drv/linux/threadctxhooks-r0drv-linux.c
r47375 r47572 212 212 PRTTHREADCTXINT pThis = hThreadCtx; 213 213 if (pThis == NIL_RTTHREADCTX) 214 return V INF_SUCCESS;214 return VERR_INVALID_HANDLE; 215 215 AssertPtr(pThis); 216 216 AssertMsgReturn(pThis->u32Magic == RTTHREADCTXINT_MAGIC, ("pThis->u32Magic=%RX32 pThis=%p\n", pThis->u32Magic, pThis), … … 242 242 PRTTHREADCTXINT pThis = hThreadCtx; 243 243 if (pThis == NIL_RTTHREADCTX) 244 return V INF_SUCCESS;244 return VERR_INVALID_HANDLE; 245 245 AssertPtr(pThis); 246 246 AssertMsgReturn(pThis->u32Magic == RTTHREADCTXINT_MAGIC, ("pThis->u32Magic=%RX32 pThis=%p\n", pThis->u32Magic, pThis), … … 257 257 RT_EXPORT_SYMBOL(RTThreadCtxHooksDeregister); 258 258 259 260 RTDECL(bool) RTThreadCtxHooksAreRegistered(RTTHREADCTX hThreadCtx) 261 { 262 /* 263 * Validate input. 264 */ 265 PRTTHREADCTXINT pThis = hThreadCtx; 266 if (pThis == NIL_RTTHREADCTX) 267 return false; 268 AssertPtr(pThis); 269 AssertMsg(pThis->u32Magic == RTTHREADCTXINT_MAGIC, ("pThis->u32Magic=%RX32 pThis=%p\n", pThis->u32Magic, pThis)); 270 271 return pThis->fRegistered; 272 } 273 259 274 #else /* Not supported / Not needed */ 260 275 … … 300 315 RT_EXPORT_SYMBOL(RTThreadCtxHooksDeregister); 301 316 317 318 RTDECL(bool) RTThreadCtxHooksAreRegistered(RTTHREADCTX hThreadCtx) 319 { 320 NOREF(hThreadCtx); 321 return false; 322 } 323 RT_EXPORT_SYMBOL(RTThreadCtxHooksAreRegistered); 324 302 325 #endif /* Not supported / Not needed */ 303 326 -
trunk/src/VBox/Runtime/r0drv/solaris/threadctxhooks-r0drv-solaris.c
r47380 r47572 281 281 PRTTHREADCTXINT pThis = hThreadCtx; 282 282 if (pThis == NIL_RTTHREADCTX) 283 return V INF_SUCCESS;283 return VERR_INVALID_HANDLE; 284 284 AssertPtr(pThis); 285 285 AssertMsgReturn(pThis->u32Magic == RTTHREADCTXINT_MAGIC, ("pThis->u32Magic=%RX32 pThis=%p\n", pThis->u32Magic, pThis), … … 305 305 PRTTHREADCTXINT pThis = hThreadCtx; 306 306 if (pThis == NIL_RTTHREADCTX) 307 return V INF_SUCCESS;307 return VERR_INVALID_HANDLE; 308 308 AssertPtr(pThis); 309 309 AssertMsgReturn(pThis->u32Magic == RTTHREADCTXINT_MAGIC, ("pThis->u32Magic=%RX32 pThis=%p\n", pThis->u32Magic, pThis), … … 320 320 } 321 321 322 323 RTDECL(bool) RTThreadCtxHooksAreRegistered(RTTHREADCTX hThreadCtx) 324 { 325 /* 326 * Validate input. 327 */ 328 PRTTHREADCTXINT pThis = hThreadCtx; 329 if (pThis == NIL_RTTHREADCTX) 330 return false; 331 AssertPtr(pThis); 332 AssertMsg(pThis->u32Magic == RTTHREADCTXINT_MAGIC, ("pThis->u32Magic=%RX32 pThis=%p\n", pThis->u32Magic, pThis)); 333 334 return pThis->fRegistered; 335 } 336 -
trunk/src/VBox/Runtime/testcase/tstR0ThreadPreemption.cpp
r47521 r47572 299 299 } 300 300 301 bool fRegistered = RTThreadCtxHooksAreRegistered(NIL_RTTHREADCTX); 302 if (fRegistered) 303 { 304 RTStrPrintf(pszErr, cchErr, "!RTThreadCtxHooksAreRegistered returns true before creating any hooks"); 305 break; 306 } 307 301 308 RTTHREADCTX hThreadCtx; 302 309 int rc = RTThreadCtxHooksCreate(&hThreadCtx); … … 307 314 else 308 315 RTStrPrintf(pszErr, cchErr, "!RTThreadCtxHooksCreate returns %Rrc", rc); 316 break; 317 } 318 319 fRegistered = RTThreadCtxHooksAreRegistered(hThreadCtx); 320 if (fRegistered) 321 { 322 RTStrPrintf(pszErr, cchErr, "!RTThreadCtxHooksAreRegistered returns true before registering any hooks"); 323 RTThreadCtxHooksRelease(hThreadCtx); 309 324 break; 310 325 } … … 330 345 if (RT_FAILURE(rc)) 331 346 { 347 RTThreadPreemptRestore(&PreemptState); 332 348 RTMemFree(pCtxData); 333 349 RTStrPrintf(pszErr, cchErr, "!RTThreadCtxHooksRegister returns %Rrc", rc); … … 335 351 } 336 352 353 fRegistered = RTThreadCtxHooksAreRegistered(hThreadCtx); 354 if (!fRegistered) 355 { 356 RTThreadPreemptRestore(&PreemptState); 357 RTMemFree(pCtxData); 358 RTStrPrintf(pszErr, cchErr, "!RTThreadCtxHooksAreRegistered return false when hooks are supposedly registered"); 359 break; 360 } 361 337 362 RTThreadPreemptRestore(&PreemptState); 338 363 339 364 /* Check if the preempting callback has/will been invoked. */ 340 const uint32_t cMsTimeout = 8000;365 const uint32_t cMsTimeout = 10000; 341 366 const uint32_t cMsSleepGranularity = 50; 342 367 uint32_t cMsSlept = 0; 368 RTCPUID uCurrentCpuId = NIL_RTCPUID; 343 369 for (;;) 344 370 { 345 371 RTThreadPreemptDisable(&PreemptState); 346 const RTCPUIDuCurrentCpuId = RTMpCpuId();372 uCurrentCpuId = RTMpCpuId(); 347 373 RTThreadPreemptRestore(&PreemptState); 348 374 … … 359 385 if (!ASMAtomicReadBool(&pCtxData->fPreemptingInvoked)) 360 386 { 361 RTStrPrintf(pszErr, cchErr, "!tstR0ThreadCtxHooks[RTTHREADCTXEVENT_PREEMPTING] not invoked after ca. %u ms", 362 cMsSlept); 387 if (pCtxData->uSourceCpuId != uCurrentCpuId) 388 { 389 RTStrPrintf(pszErr, cchErr, 390 "!tstR0ThreadCtxHooks[RTTHREADCTXEVENT_PREEMPTING] not invoked before migrating from CPU %RU32 to %RU32", 391 pCtxData->uSourceCpuId, uCurrentCpuId); 392 } 393 else 394 { 395 RTStrPrintf(pszErr, cchErr, "!tstR0ThreadCtxHooks[RTTHREADCTXEVENT_PREEMPTING] not invoked after ca. %u ms", 396 cMsSlept); 397 } 363 398 } 364 399 else if (!pCtxData->fPreemptingSuccess) … … 391 426 RTThreadCtxHooksDeregister(hThreadCtx); 392 427 428 fRegistered = RTThreadCtxHooksAreRegistered(hThreadCtx); 429 if (fRegistered) 430 { 431 RTMemFree(pCtxData); 432 RTStrPrintf(pszErr, cchErr, "!RTThreadCtxHooksAreRegistered return true when hooks are deregistered"); 433 break; 434 } 435 393 436 Assert(RTThreadPreemptIsEnabled(NIL_RTTHREAD)); 394 437 uint32_t cRefs = RTThreadCtxHooksRelease(hThreadCtx);
Note:
See TracChangeset
for help on using the changeset viewer.