VirtualBox

Changeset 8652 in vbox for trunk/src/VBox/Runtime/r3/posix


Ignore:
Timestamp:
May 7, 2008 12:22:39 PM (17 years ago)
Author:
vboxsync
Message:

Lock counting.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/posix/semrw-posix.cpp

    r8245 r8652  
    3535#include <iprt/assert.h>
    3636#include <iprt/alloc.h>
     37#include <iprt/thread.h>
    3738#include <iprt/asm.h>
    3839#include <iprt/err.h>
     
    4445
    4546#include "internal/magics.h"
    46 
     47#include "internal/strict.h"
     48
     49
     50/*******************************************************************************
     51*   Defined Constants And Macros                                               *
     52*******************************************************************************/
    4753/** @todo move this to r3/posix/something.h. */
    4854#ifdef RT_OS_SOLARIS
     
    167173     * Check if it's the writer (implement write+read recursion).
    168174     */
     175#ifdef RTSEMRW_STRICT
     176    RTTHREAD  ThreadSelf = RTThreadSelf();
     177#endif
    169178    pthread_t Self = pthread_self();
    170179    pthread_t Writer;
     
    174183        Assert(pThis->cWriterReads < INT32_MAX);
    175184        pThis->cWriterReads++;
     185#ifdef RTSEMRW_STRICT
     186        if (ThreadSelf != NIL_RTTHREAD)
     187            RTThreadReadLockInc(ThreadSelf);
     188#endif
    176189        return VINF_SUCCESS;
    177190    }
     
    223236    }
    224237
     238#ifdef RTSEMRW_STRICT
     239    if (ThreadSelf != NIL_RTTHREAD)
     240        RTThreadReadLockInc(ThreadSelf);
     241#endif
    225242    return VINF_SUCCESS;
    226243}
     
    248265     * Check if it's the writer.
    249266     */
     267#ifdef RTSEMRW_STRICT
     268    RTTHREAD  ThreadSelf = RTThreadSelf();
     269#endif
    250270    pthread_t Self = pthread_self();
    251271    pthread_t Writer;
     
    256276                        ("pThis=%p\n", pThis), VERR_NOT_OWNER);
    257277        pThis->cWriterReads--;
     278#ifdef RTSEMRW_STRICT
     279        if (ThreadSelf != NIL_RTTHREAD)
     280            RTThreadReadLockDec(ThreadSelf);
     281#endif
    258282        return VINF_SUCCESS;
    259283    }
     
    269293    }
    270294
     295#ifdef RTSEMRW_STRICT
     296    if (ThreadSelf != NIL_RTTHREAD)
     297        RTThreadReadLockDec(ThreadSelf);
     298#endif
    271299    return VINF_SUCCESS;
    272300}
     
    344372    ATOMIC_SET_PTHREAD_T(&pThis->Writer, Self);
    345373    pThis->cWrites = 1;
     374#ifdef RTSEMRW_STRICT
     375    RTTHREAD ThreadSelf = RTThreadSelf();
     376    if (ThreadSelf != NIL_RTTHREAD)
     377        RTThreadWriteLockInc(ThreadSelf);
     378#endif
    346379    return VINF_SUCCESS;
    347380}
     
    389422    }
    390423
     424#ifdef RTSEMRW_STRICT
     425    RTTHREAD ThreadSelf = RTThreadSelf();
     426    if (ThreadSelf != NIL_RTTHREAD)
     427        RTThreadWriteLockDec(ThreadSelf);
     428#endif
    391429    return VINF_SUCCESS;
    392430}
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