VirtualBox

Changeset 47199 in vbox for trunk/include/iprt


Ignore:
Timestamp:
Jul 16, 2013 3:45:42 PM (11 years ago)
Author:
vboxsync
Message:

IPRT: Kernel thread-context hooks, linux implementation. Extended tstR0ThreadPreemption testcase to test the thread-context hooks.

Location:
trunk/include/iprt
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/mangling.h

    r46639 r47199  
    15921592# define RTThreadCreateF                                RT_MANGLER(RTThreadCreateF)
    15931593# define RTThreadCreateV                                RT_MANGLER(RTThreadCreateV)
     1594# define RTThreadCtxHooksCreate                         RT_MANGLER(RTThreadCtxHooksCreate)         /* r0drv */
     1595# define RTThreadCtxHooksDeregister                     RT_MANGLER(RTThreadCtxHooksDeregister)     /* r0drv */
     1596# define RTThreadCtxHooksDestroy                        RT_MANGLER(RTThreadCtxHooksDestroy)        /* r0drv */
     1597# define RTThreadCtxHooksRegister                       RT_MANGLER(RTThreadCtxHooksRegister)       /* r0drv */
    15941598# define RTThreadFromNative                             RT_MANGLER(RTThreadFromNative)
    15951599# define RTThreadGetAffinity                            RT_MANGLER(RTThreadGetAffinity)
  • trunk/include/iprt/thread.h

    r43363 r47199  
    580580RTDECL(bool) RTThreadIsInInterrupt(RTTHREAD hThread);
    581581
     582
     583/**
     584 * Thread-context events.
     585 */
     586typedef enum RTTHREADCTXEVENT
     587{
     588    /** This thread is about to be preempted. */
     589    RTTHREADCTXEVENT_PREEMPTING = 0,
     590    /** This thread has just been resumed. */
     591    RTTHREADCTXEVENT_RESUMED,
     592    /** The usual 32-bit size hack. */
     593    RTTHREADCTXEVENT_32BIT_HACK = 0x7fffffff
     594} RTTHREADCTXEVENT;
     595
     596/**
     597 * Thread-context hook.
     598 *
     599 * @returns IPRT status code.
     600 * @param   enmEvent    The thread-context event.
     601 * @param   pvUser      User argument.
     602 *
     603 * @remarks This function may be called under different contexts, i.e. with
     604 *          different locks held, with/without preemption disabled depending on
     605 *          the event in @a enmEvent.
     606 */
     607typedef DECLCALLBACK(void) FNRTTHREADCTXHOOK(RTTHREADCTXEVENT enmEvent, void *pvUser);
     608/** Pointer to a thread-context hook. */
     609typedef FNRTTHREADCTXHOOK *PFNRTTHREADCTXHOOK;
     610
     611/**
     612 * Create a handle for a thread-context hook.
     613 *
     614 * This must be called once per-thread before using RTThreadCtxHooksRegister().
     615 *
     616 * @returns IPRT status code.
     617 * @param   phThreadCtx         Where to store the thread-context handle.
     618 */
     619RTDECL(int) RTThreadCtxHooksCreate(PRTTHREADCTX phThreadCtx);
     620
     621/**
     622 * Destroy a thread-context hook handle for the current thread.
     623 *
     624 * This will deregister any thread-context hooks registered under this handle if
     625 * required.
     626 *
     627 * @param   phThreadCtx         Pointer to the thread-context handle.
     628 */
     629RTDECL(void) RTThreadCtxHooksDestroy(RTTHREADCTX hThreadCtx);
     630
     631/**
     632 * Registers a thread-context hook for the current thread to receive
     633 * notifications for all supported thread-context events.
     634 *
     635 * @returns IPRT status code.
     636 * @param   phThreadCtx         Poinner to the thread-context handle.
     637 * @param   pfnThreadHook       Pointer to a thread-context hook (a callback)
     638 *                              for all thread-context events.
     639 * @param   pvUser              User argument (optional, can be NULL).
     640 */
     641RTDECL(int) RTThreadCtxHooksRegister(RTTHREADCTX hThreadCtx, PFNRTTHREADCTXHOOK pfnThreadHook, void *pvUser);
     642
     643/**
     644 * Deregisters a thread-context hook for the current thread.
     645 *
     646 * @returns IPRT status code.
     647 * @param   phThreadCtx         Pointer to the thread-context handle.
     648 */
     649RTDECL(int) RTThreadCtxHooksDeregister(RTTHREADCTX hThreadCtx);
     650
    582651# endif /* IN_RING0 */
    583652
  • trunk/include/iprt/types.h

    r46688 r47199  
    18251825#define NIL_RTTHREAD                                0
    18261826
     1827/** Thread-context handle.*/
     1828typedef R0PTRTYPE(struct RTTHREADCTXINT *)          RTTHREADCTX;
     1829/** Pointer to thread handle. */
     1830typedef RTTHREADCTX                                *PRTTHREADCTX;
     1831/** Nil thread-context handle. */
     1832#define NIL_RTTHREADCTX                             0
     1833
    18271834/** A TLS index. */
    18281835typedef RTHCINTPTR                                  RTTLS;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette