253
273
RTDECL(int) RTSemFastMutexRelease(RTSEMFASTMUTEX MutexSem);
278
/** @defgroup grp_rt_sems_spin_mutex RTSemSpinMutex - Spinning Mutex Semaphores
280
* Very adaptive kind of mutex semaphore tailored for the ring-0 logger.
285
* Creates a spinning mutex semaphore.
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
292
* @param phSpinMtx Where to return the handle to the create semaphore.
293
* @param fFlags Flags, see RTSEMSPINMUTEX_FLAGS_XXX.
295
RTDECL(int) RTSemSpinMutexCreate(PRTSEMSPINMUTEX phSpinMtx, uint32_t fFlags);
297
/** @name RTSemSpinMutexCreate flags.
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)
307
* Destroys a spinning mutex semaphore.
309
* @returns iprt status code.
310
* @retval VERR_INVALID_HANDLE (or crash) if the handle is invalid. (NIL will
311
* not cause this status.)
313
* @param hSpinMtx The semaphore handle. NIL_RTSEMSPINMUTEX is ignored
314
* quietly (VINF_SUCCESS).
316
RTDECL(int) RTSemSpinMutexDestroy(RTSEMSPINMUTEX hSpinMtx);
319
* Request the spinning mutex semaphore.
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.
328
* Preemption will be disabled upon return. IRQs may also be disabled.
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
337
* @param hSpinMtx The semaphore handle.
339
RTDECL(int) RTSemSpinMutexRequest(RTSEMSPINMUTEX hSpinMtx);
342
* Like RTSemSpinMutexRequest but it won't block or spin if the semaphore is
343
* held by someone else.
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
351
* @param hSpinMtx The semaphore handle.
353
RTDECL(int) RTSemSpinMutexTryRequest(RTSEMSPINMUTEX hSpinMtx);
356
* Releases the semaphore previously acquired by RTSemSpinMutexRequest or
357
* RTSemSpinMutexTryRequest.
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.
364
* @param hSpinMtx The semaphore handle.
366
RTDECL(int) RTSemSpinMutexRelease(RTSEMSPINMUTEX hSpinMtx);
371
/** @defgroup grp_rt_sem_rw RTSemRW - Read / Write Semaphores
257
375
* Creates a read/write semaphore.