summaryrefslogtreecommitdiff
path: root/src/VBox/Runtime/generic/semrw-lockless-generic.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/VBox/Runtime/generic/semrw-lockless-generic.cpp')
-rw-r--r--src/VBox/Runtime/generic/semrw-lockless-generic.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/VBox/Runtime/generic/semrw-lockless-generic.cpp b/src/VBox/Runtime/generic/semrw-lockless-generic.cpp
index 3da9d6fe..27a37c06 100644
--- a/src/VBox/Runtime/generic/semrw-lockless-generic.cpp
+++ b/src/VBox/Runtime/generic/semrw-lockless-generic.cpp
@@ -1,10 +1,10 @@
/* $Id: semrw-lockless-generic.cpp $ */
/** @file
- * IPRT Testcase - RTSemXRoads, generic implementation.
+ * IPRT - Read-Write Semaphore, Generic, lockless variant.
*/
/*
- * Copyright (C) 2009 Oracle Corporation
+ * Copyright (C) 2009-2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -51,8 +51,10 @@ typedef struct RTSEMRWINTERNAL
{
/** Magic value (RTSEMRW_MAGIC). */
uint32_t volatile u32Magic;
- uint32_t u32Padding; /**< alignment padding.*/
- /* The state variable.
+ /** Indicates whether hEvtRead needs resetting. */
+ bool volatile fNeedReset;
+
+ /** The state variable.
* All accesses are atomic and it bits are defined like this:
* Bits 0..14 - cReads.
* Bit 15 - Unused.
@@ -68,7 +70,8 @@ typedef struct RTSEMRWINTERNAL
RTNATIVETHREAD volatile hNativeWriter;
/** The number of reads made by the current writer. */
uint32_t volatile cWriterReads;
- /** The number of reads made by the current writer. */
+ /** The number of recursions made by the current writer. (The initial grabbing
+ * of the lock counts as the first one.) */
uint32_t volatile cWriteRecursions;
/** What the writer threads are blocking on. */
@@ -76,8 +79,6 @@ typedef struct RTSEMRWINTERNAL
/** What the read threads are blocking on when waiting for the writer to
* finish. */
RTSEMEVENTMULTI hEvtRead;
- /** Indicates whether hEvtRead needs resetting. */
- bool volatile fNeedReset;
#ifdef RTSEMRW_STRICT
/** The validator record for the writer. */
@@ -494,7 +495,7 @@ RTDECL(int) RTSemRWReleaseRead(RTSEMRW hRWSem)
c--;
if ( c > 0
- || (u64State & RTSEMRW_CNT_RD_MASK) == 0)
+ || (u64State & RTSEMRW_CNT_WD_MASK) == 0)
{
/* Don't change the direction. */
u64State &= ~RTSEMRW_CNT_RD_MASK;
@@ -888,7 +889,7 @@ RTDECL(bool) RTSemRWIsReadOwner(RTSEMRW hRWSem, bool fWannaHear)
*/
RTNATIVETHREAD hNativeSelf = RTThreadNativeSelf();
RTNATIVETHREAD hWriter;
- ASMAtomicUoReadHandle(&pThis->hWriter, &hWriter);
+ ASMAtomicUoReadHandle(&pThis->hNativeWriter, &hWriter);
return hWriter == hNativeSelf;
}