VirtualBox

Changeset 25685 in vbox for trunk/include


Ignore:
Timestamp:
Jan 7, 2010 10:03:06 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
56405
Message:

iprt,pdmcritsect: Some more lock validator code, almost there now... :-)

Location:
trunk/include/iprt
Files:
3 edited

Legend:

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

    r25645 r25685  
    102102/** If set, nesting(/recursion) is not allowed. */
    103103#define RTCRITSECT_FLAGS_NO_NESTING     UINT32_C(0x00000001)
     104/** Disables lock validation. */
     105#define RTCRITSECT_FLAGS_NO_LOCK_VAL    UINT32_C(0x00000002)
    104106
    105107#ifdef IN_RING3
     
    114116 *
    115117 * @returns iprt status code.
    116  * @param   pCritSect   Pointer to the critical section structure.
    117  * @param   fFlags      Flags, any combination of the RTCRITSECT_FLAGS \#defines.
    118  */
    119 RTDECL(int) RTCritSectInitEx(PRTCRITSECT pCritSect, uint32_t fFlags);
     118 * @param   pCritSect           Pointer to the critical section structure.
     119 * @param   fFlags              Flags, any combination of the RTCRITSECT_FLAGS
     120 *                              \#defines.
     121 * @param   hClass              The class (no reference consumed). If NIL, the
     122 *                              no lock order validation will be performed on
     123 *                              this lock.
     124 * @param   uSubClass           The sub-class.  This is used to define lock
     125 *                              order inside the same class.  If you don't know,
     126 *                              then pass RTLOCKVAL_SUB_CLASS_NONE.
     127 * @param   pszName             The lock name (optional).
     128 */
     129RTDECL(int) RTCritSectInitEx(PRTCRITSECT pCritSect, uint32_t fFlags,
     130                             RTLOCKVALCLASS hClass, uint32_t uSubClass, const char *pszName);
    120131
    121132/**
     
    125136 * @returns VERR_SEM_NESTED if nested enter on a no nesting section. (Asserted.)
    126137 * @returns VERR_SEM_DESTROYED if RTCritSectDelete was called while waiting.
    127  * @param   pCritSect   The critical section.
     138 * @param   pCritSect       The critical section.
    128139 */
    129140RTDECL(int) RTCritSectEnter(PRTCRITSECT pCritSect);
  • trunk/include/iprt/lockvalidator.h

    r25682 r25685  
    241241
    242242
    243 /** @name   Special sub-class values.
    244  * The range 16..UINT32_MAX is available to the user, the range 0..15 is
    245  * reserved for the lock validator.
    246  * @{ */
    247 /** Not allowed to be taken with any other locks in the same class.
    248   * This is the recommended value.  */
    249 #define RTLOCKVAL_SUB_CLASS_NONE        UINT32_C(0)
    250 /** Any order is allowed within the class. */
    251 #define RTLOCKVAL_SUB_CLASS_ANY         UINT32_C(1)
    252 /** The first user value. */
    253 #define RTLOCKVAL_SUB_CLASS_USER        UINT32_C(16)
    254 /** @} */
    255 
    256243/**
    257244 * Makes the two records siblings.
     
    278265 * @param   pszName             The lock name (optional).
    279266 * @param   hLock               The lock handle.
    280  */
    281 RTDECL(void) RTLockValidatorRecExclInit(PRTLOCKVALRECEXCL pRec, RTLOCKVALCLASS hClass,
    282                                         uint32_t uSubClass, const char *pszName, void *hLock);
     267 * @param   fEnabled            Pass @c false to explicitly disable lock
     268 *                              validation, otherwise @c true.
     269 */
     270RTDECL(void) RTLockValidatorRecExclInit(PRTLOCKVALRECEXCL pRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
     271                                        const char *pszName, void *hLock, bool fEnabled);
    283272/**
    284273 * Uninitialize a lock validator record previously initialized by
     
    305294 * @param   pszName             The lock name (optional).
    306295 * @param   hLock               The lock handle.
    307  */
    308 RTDECL(int)  RTLockValidatorRecExclCreate(PRTLOCKVALRECEXCL *ppRec, RTLOCKVALCLASS hClass,
    309                                           uint32_t uSubClass, const char *pszName, void *hLock);
     296 * @param   fEnabled            Pass @c false to explicitly disable lock
     297 *                              validation, otherwise @c true.
     298 */
     299RTDECL(int)  RTLockValidatorRecExclCreate(PRTLOCKVALRECEXCL *ppRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
     300                                          const char *pszName, void *hLock, bool fEnabled);
    310301
    311302/**
     
    441432 *                              pass NIL_RTTHREAD and we'll figure it out.
    442433 * @param   pSrcPos             The source position of the lock operation.
    443  */
    444 RTDECL(int)  RTLockValidatorRecExclCheckOrder(PRTLOCKVALRECEXCL pRec, RTTHREAD hThreadSelf, PCRTLOCKVALSRCPOS pSrcPos);
     434 * @param   cMillies            The timeout, in milliseconds.
     435 */
     436RTDECL(int)  RTLockValidatorRecExclCheckOrder(PRTLOCKVALRECEXCL pRec, RTTHREAD hThreadSelf,
     437                                              PCRTLOCKVALSRCPOS pSrcPos, RTMSINTERVAL cMillies);
    445438
    446439/**
     
    462455 * @param   pSrcPos             The source position of the lock operation.
    463456 * @param   fRecursiveOk        Whether it's ok to recurse.
     457 * @param   cMillies            The timeout, in milliseconds.
    464458 * @param   enmSleepState       The sleep state to enter on successful return.
    465459 * @param   fReallySleeping     Is it really going to sleep now or not.  Use
     
    468462 */
    469463RTDECL(int) RTLockValidatorRecExclCheckBlocking(PRTLOCKVALRECEXCL pRec, RTTHREAD hThreadSelf,
    470                                                 PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk,
     464                                                PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk, RTMSINTERVAL cMillies,
    471465                                                RTTHREADSTATE enmSleepState, bool fReallySleeping);
    472466
     
    480474 * @param   pSrcPos             The source position of the lock operation.
    481475 * @param   fRecursiveOk        Whether it's ok to recurse.
     476 * @param   cMillies            The timeout, in milliseconds.
    482477 * @param   enmSleepState       The sleep state to enter on successful return.
    483478 * @param   fReallySleeping     Is it really going to sleep now or not.  Use
     
    486481 */
    487482RTDECL(int) RTLockValidatorRecExclCheckOrderAndBlocking(PRTLOCKVALRECEXCL pRec, RTTHREAD hThreadSelf,
    488                                                         PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk,
     483                                                        PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk, RTMSINTERVAL cMillies,
    489484                                                        RTTHREADSTATE enmSleepState, bool fReallySleeping);
    490485
     
    506501 *                              applied to this record, clear if read-write
    507502 *                              semaphore logic should be used.
     503 * @param   fEnabled            Pass @c false to explicitly disable lock
     504 *                              validation, otherwise @c true.
    508505 */
    509506RTDECL(void) RTLockValidatorRecSharedInit(PRTLOCKVALRECSHRD pRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
    510                                           const char *pszName, void *hLock, bool fSignaller);
     507                                          const char *pszName, void *hLock, bool fSignaller, bool fEnabled);
    511508/**
    512509 * Uninitialize a lock validator record previously initialized by
     
    532529 * @param   pSrcPos             The source position of the lock operation.
    533530 */
    534 RTDECL(int)  RTLockValidatorRecSharedCheckOrder(PRTLOCKVALRECSHRD pRec, RTTHREAD hThreadSelf, PCRTLOCKVALSRCPOS pSrcPos);
     531RTDECL(int)  RTLockValidatorRecSharedCheckOrder(PRTLOCKVALRECSHRD pRec, RTTHREAD hThreadSelf,
     532                                                PCRTLOCKVALSRCPOS pSrcPos, RTMSINTERVAL cMillies);
    535533
    536534/**
     
    558556 */
    559557RTDECL(int) RTLockValidatorRecSharedCheckBlocking(PRTLOCKVALRECSHRD pRec, RTTHREAD hThreadSelf,
    560                                                   PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk,
     558                                                  PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk, RTMSINTERVAL cMillies,
    561559                                                  RTTHREADSTATE enmSleepState, bool fReallySleeping);
    562560
     
    576574 */
    577575RTDECL(int) RTLockValidatorRecSharedCheckOrderAndBlocking(PRTLOCKVALRECSHRD pRec, RTTHREAD hThreadSelf,
    578                                                           PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk,
     576                                                          PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk, RTMSINTERVAL cMillies,
    579577                                                          RTTHREADSTATE enmSleepState, bool fReallySleeping);
    580578
     
    731729 *                              itself new locking order rules (true), or if the
    732730 *                              user will teach it all it needs to know (false).
     731 * @param   fRecursionOk        Whether to allow lock recursion or not.
    733732 * @param   cMsMinDeadlock      Used to raise the sleep interval at which
    734733 *                              deadlock detection kicks in.  Minimum is 1 ms,
     
    737736 *                              order validation kicks in.  Minimum is 1 ms,
    738737 *                              while RT_INDEFINITE_WAIT will disable it.
     738 *
     739 * @remarks The properties can be modified after creation by the
     740 *          RTLockValidatorClassSet* methods.
    739741 */
    740742RTDECL(int) RTLockValidatorClassCreateEx(PRTLOCKVALCLASS phClass, PCRTLOCKVALSRCPOS pSrcPos,
    741                                          bool fAutodidact, RTMSINTERVAL cMsMinDeadlock, RTMSINTERVAL cMsMinOrder);
     743                                         bool fAutodidact, bool fRecursionOk,
     744                                         RTMSINTERVAL cMsMinDeadlock, RTMSINTERVAL cMsMinOrder);
    742745
    743746/**
  • trunk/include/iprt/types.h

    r25682 r25685  
    14951495typedef struct RTLOCKVALSRCPOS const   *PCRTLOCKVALSRCPOS;
    14961496
     1497/** @name   Special sub-class values.
     1498 * The range 16..UINT32_MAX is available to the user, the range 0..15 is
     1499 * reserved for the lock validator.
     1500 * @{ */
     1501/** Not allowed to be taken with any other locks in the same class.
     1502  * This is the recommended value.  */
     1503#define RTLOCKVAL_SUB_CLASS_NONE        UINT32_C(0)
     1504/** Any order is allowed within the class. */
     1505#define RTLOCKVAL_SUB_CLASS_ANY         UINT32_C(1)
     1506/** The first user value. */
     1507#define RTLOCKVAL_SUB_CLASS_USER        UINT32_C(16)
     1508/** @} */
     1509
    14971510
    14981511#ifdef __cplusplus
Note: See TracChangeset for help on using the changeset viewer.

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