critsect.h revision 78cbab32dbc1ff1bb306f46e347c68adaf19b35e
4518N/A * IPRT - Critical Sections. 4518N/A * Copyright (C) 2006-2007 Sun Microsystems, Inc. 4518N/A * This file is part of VirtualBox Open Source Edition (OSE), as 4518N/A * you can redistribute it and/or modify it under the terms of the GNU 4518N/A * General Public License (GPL) as published by the Free Software 4518N/A * Foundation, in version 2 as it comes in the "COPYING" file of the 4518N/A * VirtualBox OSE distribution. VirtualBox OSE is distributed in the 4518N/A * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 4518N/A * The contents of this file may alternatively be used under the terms 4518N/A * of the Common Development and Distribution License Version 1.0 4518N/A * (CDDL) only, as it comes in the "COPYING.CDDL" file of the 4518N/A * VirtualBox OSE distribution, in which case the provisions of the 4518N/A * CDDL are applicable instead of those of the GPL. 4518N/A * You may elect to license modified versions of this file under the 4518N/A * terms and conditions of either the GPL or the CDDL or both. 4518N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa 4518N/A * additional information or have any questions. 4518N/A/** @defgroup grp_rt_critsect RTCritSect - Critical Sections 4518N/A /** Magic used to validate the section state. 4518N/A * RTCRITSECT_MAGIC is the value of an initialized & operational section. */ 4518N/A * -1 if the section is free. */ 4518N/A /** Number of nested enter operations performed. 4518N/A * Greater or equal to 1 if owned, 0 when free. 4518N/A /** Section flags - the RTCRITSECT_FLAGS_* \#defines. */ 4518N/A /** The semaphore to wait for. */ 4518N/A /** Data only used in strict mode for detecting and debugging deadlocks. */ 4518N/A /** Strict: The current owner thread. */ 4518N/A /** Strict: Where the section was entered. */ 4518N/A /** Strict: Where the section was entered. */ 4518N/A /** Padding for correct alignment. */ 4518N/A /** Strict: Where the section was entered. */ 4518N/A/** Pointer to a critical section. */ 4518N/A/** Pointer to a const critical section. */ 4518N/A/** RTCRITSECT::u32Magic value. */ 4518N/A/** If set, nesting(/recursion) is not allowed. */ 4518N/A * Initialize a critical section. 4518N/A * Initialize a critical section. 4518N/A * @returns iprt status code. 4518N/A * @param pCritSect Pointer to the critical section structure. 4518N/A * @param fFlags Flags, any combination of the RTCRITSECT_FLAGS \#defines. 4518N/A * Enter a critical section. 4518N/A * @returns VINF_SUCCESS on success. 4518N/A * @returns VERR_SEM_NESTED if nested enter on a no nesting section. (Asserted.) 4518N/A * @returns VERR_SEM_DESTROYED if RTCritSectDelete was called while waiting. 4518N/A * @param pCritSect The critical section. 4518N/A * Enter a critical section. 4518N/A * @returns VINF_SUCCESS on success. 4518N/A * @returns VERR_SEM_NESTED if nested enter on a no nesting section. (Asserted.) 4518N/A * @returns VERR_SEM_DESTROYED if RTCritSectDelete was called while waiting. 4518N/A * @param pCritSect The critical section. 4518N/A * @param pszFile Where we're entering the section. 4518N/A * @param uLine Where we're entering the section. 4518N/A * @param uId Where we're entering the section. 4518N/A/* in debug mode we'll redefine the enter call. */ 4518N/A * Try enter a critical section. 4518N/A * @returns VINF_SUCCESS on success. 4518N/A * @returns VERR_SEM_BUSY if the critsect was owned. 4518N/A * @returns VERR_SEM_NESTED if nested enter on a no nesting section. (Asserted.) 4518N/A * @returns VERR_SEM_DESTROYED if RTCritSectDelete was called while waiting. 4518N/A * @param pCritSect The critical section. 4518N/A * Try enter a critical section. 4518N/A * @returns VINF_SUCCESS on success. 4518N/A * @returns VERR_SEM_BUSY if the critsect was owned. 4518N/A * @returns VERR_SEM_NESTED if nested enter on a no nesting section. (Asserted.) 4518N/A * @returns VERR_SEM_DESTROYED if RTCritSectDelete was called while waiting. 4518N/A * @param pCritSect The critical section. 4518N/A * @param pszFile Where we're entering the section. 4518N/A * @param uLine Where we're entering the section. 4518N/A * @param uId Where we're entering the section. 4518N/A/* in debug mode we'll redefine the try-enter call. */ 4518N/A * Enter multiple critical sections. 4518N/A * This function will enter ALL the specified critical sections before returning. 4518N/A * @returns VINF_SUCCESS on success. 4518N/A * @returns VERR_SEM_NESTED if nested enter on a no nesting section. (Asserted.) 4518N/A * @returns VERR_SEM_DESTROYED if RTCritSectDelete was called while waiting. 4518N/A * @param cCritSects Number of critical sections in the array. 4518N/A * @param papCritSects Array of critical section pointers. 4518N/A * @remark Please note that this function will not necessarily come out favourable in a 4518N/A * fight with other threads which are using the normal RTCritSectEnter() function. 4518N/A * Therefore, avoid having to enter multiple critical sections! 4518N/A * Enter multiple critical sections. 4518N/A * This function will enter ALL the specified critical sections before returning. 4518N/A * @returns VINF_SUCCESS on success. 4518N/A * @returns VERR_SEM_NESTED if nested enter on a no nesting section. (Asserted.) 4518N/A * @returns VERR_SEM_DESTROYED if RTCritSectDelete was called while waiting. 4518N/A * @param cCritSects Number of critical sections in the array. 4518N/A * @param papCritSects Array of critical section pointers. 4518N/A * @param pszFile Where we're entering the section. 4518N/A * @param uLine Where we're entering the section. 4518N/A * @param uId Where we're entering the section. 4518N/A * @remark See RTCritSectEnterMultiple(). 4518N/A/* in debug mode we'll redefine the enter-multiple call. */ 4518N/A * Leave a critical section. 4518N/A * @param pCritSect The critical section. 4518N/A * Leave multiple critical sections. 4518N/A * @param cCritSects Number of critical sections in the array. 4518N/A * @param papCritSects Array of critical section pointers. 4518N/A * Deletes a critical section. 4518N/A * @param pCritSect The critical section. 4518N/A * Checks the caller is the owner of the critical section. 4518N/A * @returns false if not owner. 4518N/A * @param pCritSect The critical section. 4518N/A * Checks the section is owned by anyone. 4518N/A * @returns false if not owned. 4518N/A * @param pCritSect The critical section. 4518N/A * Gets the thread id of the critical section owner. 4518N/A * @returns Thread id of the owner thread if owned. 4518N/A * @returns NIL_RTNATIVETHREAD is not owned. 4518N/A * @param pCritSect The critical section. 4518N/A * Checks if a critical section is initialized or not. 4518N/A * @returns true if initialized. 4518N/A * @returns false if not initialized. 4518N/A * @param pCritSect The critical section. 4518N/A * Gets the recursion depth. 4518N/A * @returns The recursion depth. 4518N/A * @param pCritSect The Critical section 4518N/A * @returns The waiter count 4518N/A * @param pCritSect The Critical section