VirtualBox

Changeset 21513 in vbox for trunk/include/iprt/semaphore.h


Ignore:
Timestamp:
Jul 12, 2009 7:17:13 PM (15 years ago)
Author:
vboxsync
Message:

iprt/semaphore.h,types.h: Defined a new semaphore type for use with the logger.

File:
1 edited

Legend:

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

    r20374 r21513  
    4343
    4444
     45/** @defgroup grp_rt_sems_event    RTSemEvent - Single Release Event Semaphores
     46 * @{ */
     47
    4548/**
    4649 * Create a event semaphore.
     
    9598RTDECL(int)  RTSemEventWaitNoResume(RTSEMEVENT EventSem, unsigned cMillies);
    9699
    97 
     100/** @} */
     101
     102
     103/** @defgroup grp_rt_sems_event_multi   RTSemEventMulti - Multiple Release Event Semaphores
     104 * @{ */
    98105
    99106/**
     
    154161RTDECL(int)  RTSemEventMultiWaitNoResume(RTSEMEVENTMULTI EventMultiSem, unsigned cMillies);
    155162
    156 
     163/** @} */
     164
     165
     166/** @defgroup grp_rt_sems_mutex     RTMutex - Mutex semaphores.
     167 *
     168 * @remarks These can be pretty heavy handed. Fast mutexes or critical sections
     169 *          is usually what you need.
     170 *
     171 * @{ */
    157172
    158173/**
     
    213228RTDECL(int)  RTSemMutexRelease(RTSEMMUTEX MutexSem);
    214229
     230/** @} */
     231
     232
     233/** @defgroup grp_rt_sems_fast_mutex    RTSemFastMutex - Fast Mutex Semaphores
     234 * @{ */
    215235
    216236/**
     
    253273RTDECL(int)  RTSemFastMutexRelease(RTSEMFASTMUTEX MutexSem);
    254274
     275/** @} */
     276
     277
     278/** @defgroup grp_rt_sems_spin_mutex RTSemSpinMutex - Spinning Mutex Semaphores
     279 *
     280 * Very adaptive kind of mutex semaphore tailored for the ring-0 logger.
     281 *
     282 * @{ */
     283
     284/**
     285 * Creates a spinning mutex semaphore.
     286 *
     287 * @returns iprt status code.
     288 * @retval  VERR_INVALID_PARAMETER on invalid flags.
     289 * @retval  VERR_NO_MEMORY if out of memory for the semaphore structure and
     290 *          handle.
     291 *
     292 * @param   phSpinMtx   Where to return the handle to the create semaphore.
     293 * @param   fFlags      Flags, see RTSEMSPINMUTEX_FLAGS_XXX.
     294 */
     295RTDECL(int) RTSemSpinMutexCreate(PRTSEMSPINMUTEX phSpinMtx, uint32_t fFlags);
     296
     297/** @name RTSemSpinMutexCreate flags.
     298 * @{ */
     299/** Always take the semaphore in a IRQ safe way.
     300 * (In plain words: always disable interrupts.) */
     301#define RTSEMSPINMUTEX_FLAGS_IRQ_SAFE       RT_BIT_32(0)
     302/** Mask of valid flags. */
     303#define RTSEMSPINMUTEX_FLAGS_VALID_MASK     UINT32_C(0x00000001)
     304/** @} */
     305
     306/**
     307 * Destroys a spinning mutex semaphore.
     308 *
     309 * @returns iprt status code.
     310 * @retval  VERR_INVALID_HANDLE (or crash) if the handle is invalid. (NIL will
     311 *          not cause this status.)
     312 *
     313 * @param   hSpinMtx    The semaphore handle. NIL_RTSEMSPINMUTEX is ignored
     314 *                      quietly (VINF_SUCCESS).
     315 */
     316RTDECL(int) RTSemSpinMutexDestroy(RTSEMSPINMUTEX hSpinMtx);
     317
     318/**
     319 * Request the spinning mutex semaphore.
     320 *
     321 * This may block if the context we're called in allows this. If not it will
     322 * spin. If called in an interrupt context, we will only spin if the current
     323 * owner isn't interrupted. Also, on some systems it is not always possible to
     324 * wake up blocking threads in all contexts, so, which will either be indicated
     325 * by returning VERR_SEM_BAD_CONTEXT or by temporarily switching the semaphore
     326 * into pure spinlock state.
     327 *
     328 * Preemption will be disabled upon return. IRQs may also be disabled.
     329 *
     330 * @returns iprt status code.
     331 * @retval  VERR_SEM_BAD_CONTEXT if the context it's called in isn't suitable
     332 *          for releasing it if someone is sleeping on it.
     333 * @retval  VERR_SEM_DESTROYED if destroyed.
     334 * @retval  VERR_SEM_NESTED if held by the caller. Asserted.
     335 * @retval  VERR_INVALID_HANDLE if the handle is invalid. Asserted
     336 *
     337 * @param   hSpinMtx    The semaphore handle.
     338 */
     339RTDECL(int) RTSemSpinMutexRequest(RTSEMSPINMUTEX hSpinMtx);
     340
     341/**
     342 * Like RTSemSpinMutexRequest but it won't block or spin if the semaphore is
     343 * held by someone else.
     344 *
     345 * @returns iprt status code.
     346 * @retval  VERR_SEM_BUSY if held by someone else.
     347 * @retval  VERR_SEM_DESTROYED if destroyed.
     348 * @retval  VERR_SEM_NESTED if held by the caller. Asserted.
     349 * @retval  VERR_INVALID_HANDLE if the handle is invalid. Asserted
     350 *
     351 * @param   hSpinMtx    The semaphore handle.
     352 */
     353RTDECL(int) RTSemSpinMutexTryRequest(RTSEMSPINMUTEX hSpinMtx);
     354
     355/**
     356 * Releases the semaphore previously acquired by RTSemSpinMutexRequest or
     357 * RTSemSpinMutexTryRequest.
     358 *
     359 * @returns iprt status code.
     360 * @retval  VERR_SEM_DESTROYED if destroyed.
     361 * @retval  VERR_NOT_OWNER if not owner. Asserted.
     362 * @retval  VERR_INVALID_HANDLE if the handle is invalid. Asserted.
     363 *
     364 * @param   hSpinMtx    The semaphore handle.
     365 */
     366RTDECL(int) RTSemSpinMutexRelease(RTSEMSPINMUTEX hSpinMtx);
     367
     368/** @} */
     369
     370
     371/** @defgroup grp_rt_sem_rw             RTSemRW - Read / Write Semaphores
     372 * @{ */
    255373
    256374/**
     
    365483RTDECL(uint32_t) RTSemRWGetWriterReadRecursion(RTSEMRW RWSem);
    366484
    367 
     485/** @} */
     486
     487
     488/** @defgroup grp_rt_sems_pingpong      RTSemPingPong - Ping-Pong Construct
     489 * @{ */
    368490
    369491/**
     
    524646}
    525647
     648/** @} */
    526649
    527650/** @} */
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