Changeset 55863 in vbox for trunk/include/iprt
- Timestamp:
- May 14, 2015 6:29:34 PM (10 years ago)
- Location:
- trunk/include/iprt
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/mangling.h
r55584 r55863 1682 1682 # define RTThreadCreateF RT_MANGLER(RTThreadCreateF) 1683 1683 # define RTThreadCreateV RT_MANGLER(RTThreadCreateV) 1684 # define RTThreadCtxHooksAreRegistered RT_MANGLER(RTThreadCtxHooksAreRegistered) /* r0drv */ 1685 # define RTThreadCtxHooksCreate RT_MANGLER(RTThreadCtxHooksCreate) /* r0drv */ 1686 # define RTThreadCtxHooksDeregister RT_MANGLER(RTThreadCtxHooksDeregister) /* r0drv */ 1687 # define RTThreadCtxHooksRegister RT_MANGLER(RTThreadCtxHooksRegister) /* r0drv */ 1688 # define RTThreadCtxHooksRelease RT_MANGLER(RTThreadCtxHooksRelease) /* r0drv */ 1689 # define RTThreadCtxHooksRetain RT_MANGLER(RTThreadCtxHooksRetain) /* r0drv */ 1684 # define RTThreadCtxHookIsEnabled RT_MANGLER(RTThreadCtxHookIsEnabled) /* r0drv */ 1685 # define RTThreadCtxHookCreate RT_MANGLER(RTThreadCtxHookCreate) /* r0drv */ 1686 # define RTThreadCtxHookDestroy RT_MANGLER(RTThreadCtxHookDestroy) /* r0drv */ 1687 # define RTThreadCtxHookDisable RT_MANGLER(RTThreadCtxHookDisable) /* r0drv */ 1688 # define RTThreadCtxHookEnable RT_MANGLER(RTThreadCtxHookEnable) /* r0drv */ 1690 1689 # define RTThreadFromNative RT_MANGLER(RTThreadFromNative) 1691 1690 # define RTThreadGetAffinity RT_MANGLER(RTThreadGetAffinity) -
trunk/include/iprt/thread.h
r55386 r55863 588 588 589 589 /** 590 * Thread -contextevents.590 * Thread context swithcing events. 591 591 */ 592 592 typedef enum RTTHREADCTXEVENT 593 593 { 594 /** This thread is about to be preempted. */ 595 RTTHREADCTXEVENT_PREEMPTING = 0, 596 /** This thread has just been resumed. */ 597 RTTHREADCTXEVENT_RESUMED, 594 /** This thread is being scheduled out on the current CPU (includes preemption, 595 * waiting, sleep and whatever else may trigger scheduling). */ 596 RTTHREADCTXEVENT_OUT = 0, 597 /** This thread is being scheduled in on the current CPU and will resume 598 * execution. */ 599 RTTHREADCTXEVENT_IN, 598 600 /** The usual 32-bit size hack. */ 599 601 RTTHREADCTXEVENT_32BIT_HACK = 0x7fffffff … … 601 603 602 604 /** 603 * Thread-context hook. 604 * 605 * @returns IPRT status code. 606 * @param enmEvent The thread-context event. 605 * Thread context switching hook callback. 606 * 607 * This hook function is called when a thread is scheduled and preempted. Check 608 * @a enmEvent to see which it is. Since the function is being called from 609 * hooks inside the scheduler, it is limited what you can do from this function. 610 * Do NOT acquire locks, sleep or yield the thread for instance. IRQ safe 611 * spinlocks are fine though. 612 * 613 * @returns IPRT status code. 614 * @param enmEvent The thread-context event. Please quitely ignore unknown 615 * events, we may add more (thread exit, ++) later. 607 616 * @param pvUser User argument. 608 *609 * @remarks This function may be called under different contexts, i.e. with610 * different locks held, with/without preemption disabled depending on611 * the event in @a enmEvent.612 617 */ 613 618 typedef DECLCALLBACK(void) FNRTTHREADCTXHOOK(RTTHREADCTXEVENT enmEvent, void *pvUser); 614 /** Pointer to a thread-contexthook. */619 /** Pointer to a context switching hook. */ 615 620 typedef FNRTTHREADCTXHOOK *PFNRTTHREADCTXHOOK; 616 621 617 622 /** 618 * Initializes a thread-context hook for the current thread. 619 * 620 * This must be called once per-thread before using RTThreadCtxHooksRegister(). 621 * 622 * @returns IPRT status code. 623 * @param phThreadCtx Where to store the thread-context handle. 624 * 625 * @remarks This must be called with preemption enabled! 626 */ 627 RTDECL(int) RTThreadCtxHooksCreate(PRTTHREADCTX phThreadCtx); 628 629 /** 630 * Retains a new reference to a thread-context hook. 631 * 632 * @returns New reference count. 633 * UINT32_MAX is returned if the handle is invalid (asserted). 634 * @param phThreadCtx Pointer to the thread-context handle. 635 * 636 * @remarks This can be called from any thread. Can be called with preemption 637 * disabled. 638 */ 639 RTDECL(uint32_t) RTThreadCtxHooksRetain(RTTHREADCTX hThreadCtx); 640 641 /** 642 * Releases a reference to a thread-context hook. 643 * 644 * @returns New reference count. 645 * @retval 0 if the thread-context hook was freed or @a hThreadCtx is 646 * NIL_RTTHREADCTX. 647 * @retval UINT32_MAX is returned if the handle is invalid (asserted). 648 * 649 * @param hThreadCtx The thread-context handle. 650 * 651 * @remarks This can be called from any thread but must be called with 652 * preemption enabled! 653 */ 654 RTDECL(uint32_t) RTThreadCtxHooksRelease(RTTHREADCTX hThreadCtx); 655 656 /** 657 * Registers a thread-context hook for the current thread to receive 658 * notifications for all supported thread-context events. 659 * 660 * @returns IPRT status code. 661 * @param hThreadCtx The thread-context handle. 662 * @param pfnThreadHook Pointer to a thread-context hook (a callback) 663 * for all thread-context events. 664 * @param pvUser User argument (optional, can be NULL). 665 * 666 * @remarks Can be called with preemption disabled. 667 */ 668 RTDECL(int) RTThreadCtxHooksRegister(RTTHREADCTX hThreadCtx, PFNRTTHREADCTXHOOK pfnThreadHook, void *pvUser); 669 670 /** 671 * Deregisters the thread-context hook for the current thread. 672 * 673 * @returns IPRT status code. 674 * @param hThreadCtx The thread-context handle. 675 * 676 * @remarks Can be called with preemption disabled. 677 */ 678 RTDECL(int) RTThreadCtxHooksDeregister(RTTHREADCTX hThreadCtx); 679 680 /** 681 * Are thread-context hooks registered for the thread? 623 * Initializes a thread context switching hook for the current thread. 624 * 625 * The hook is created as disabled, use RTThreadCtxHookEnable to enable it. 626 * 627 * @returns IPRT status code. 628 * @param phCtxHook Where to store the hook handle. 629 * @param fFlags Reserved for future extensions, must be zero. 630 * @param pfnCallback Pointer to a the hook function (callback) that 631 * should be called for all context switching events 632 * involving the current thread. 633 * @param pvUser User argument that will be passed to @a pfnCallback. 634 * @remarks Preemption must be enabled. 635 */ 636 RTDECL(int) RTThreadCtxHookCreate(PRTTHREADCTXHOOK phCtxHook, uint32_t fFlags, PFNRTTHREADCTXHOOK pfnCallback, void *pvUser); 637 638 /** 639 * Destroys a thread context switching hook. 640 * 641 * Caller must make sure the hook is disabled before the final reference is 642 * released. Recommended to call this on the owning thread, otherwise the 643 * memory backing it may on some systems only be released when the thread 644 * terminates. 645 * 646 * @returns IPRT status code. 647 * 648 * @param hCtxHook The context hook handle. NIL_RTTHREADCTXHOOK is 649 * ignored and the function will return VINF_SUCCESS. 650 * @remarks Preemption must be enabled. 651 * @remarks Do not call from FNRTTHREADCTXHOOK. 652 */ 653 RTDECL(int) RTThreadCtxHookDestroy(RTTHREADCTXHOOK hCtxHook); 654 655 /** 656 * Enables the context switching hooks for the current thread. 657 * 658 * @returns IPRT status code. 659 * @param hCtxHook The context hook handle. 660 * @remarks Should be called with preemption disabled. 661 */ 662 RTDECL(int) RTThreadCtxHookEnable(RTTHREADCTXHOOK hCtxHook); 663 664 /** 665 * Disables the thread context switching hook for the current thread. 666 * 667 * Will not assert or fail if called twice or with a NIL handle. 668 * 669 * @returns IPRT status code. 670 * @param hCtxHook The context hook handle. NIL_RTTHREADCTXHOOK is 671 * ignored and the function wil return VINF_SUCCESS. 672 * @remarks Should be called with preemption disabled. 673 * @remarks Do not call from FNRTTHREADCTXHOOK. 674 */ 675 RTDECL(int) RTThreadCtxHookDisable(RTTHREADCTXHOOK hCtxHook); 676 677 /** 678 * Is the thread context switching hook enabled? 682 679 * 683 680 * @returns true if registered, false if not supported or not registered. 684 * @param hThreadCtx The thread-context handle. 685 * 686 * @remarks Can be called from any thread (but possibility of races when 687 * it's not the current thread!) 688 */ 689 RTDECL(bool) RTThreadCtxHooksAreRegistered(RTTHREADCTX hThreadCtx); 681 * @param hCtxHook The context hook handle. NIL_RTTHREADCTXHOOK is 682 * ignored and the function will return false. 683 * 684 * @remarks Can be called from any thread, though is naturally subject to races 685 * when not called from the thread associated with the hook. 686 */ 687 RTDECL(bool) RTThreadCtxHookIsEnabled(RTTHREADCTXHOOK hCtxHook); 690 688 691 689 # endif /* IN_RING0 */ -
trunk/include/iprt/types.h
r53615 r55863 1763 1763 #define NIL_RTTHREAD 0 1764 1764 1765 /** Thread -context handle.*/1766 typedef R0PTRTYPE(struct RTTHREADCTX INT *) RTTHREADCTX;1767 /** Pointer to threadhandle. */1768 typedef RTTHREADCTX *PRTTHREADCTX;1769 /** Nil thread-contexthandle. */1770 #define NIL_RTTHREADCTX 01765 /** Thread context switching hook handle. */ 1766 typedef R0PTRTYPE(struct RTTHREADCTXHOOKINT *) RTTHREADCTXHOOK; 1767 /** Pointer to Thread context switching hook handle. */ 1768 typedef RTTHREADCTXHOOK *PRTTHREADCTXHOOK; 1769 /** Nil Thread context switching hook handle. */ 1770 #define NIL_RTTHREADCTXHOOK ((RTTHREADCTXHOOK)0) 1771 1771 1772 1772 /** A TLS index. */
Note:
See TracChangeset
for help on using the changeset viewer.