This function actually does have to be thread-safe because its caller, FileIO_OptionalSafeInitialize, is not (and doesn't have to be since it just performs idempotent operations). Most straightforward solution is to turn alignedPool.lock into a singleton.
Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
unsigned numBusy;
} AlignedPool;
+static Atomic_Ptr alignedPoolLockStorage;
static AlignedPool alignedPool;
#endif
*
* FileIOAligned_PoolInit --
*
- * Initialize alignedPool. Must be called before FileIOAligned_PoolMalloc.
- * This is not thread-safe and must be protected from multiple entry.
+ * Initialize alignedPool. Must be called before FileIOAligned_PoolMalloc.
*
* Result:
* None.
void
FileIOAligned_PoolInit(void)
{
- ASSERT(!alignedPool.lock);
- alignedPool.lock = MXUser_CreateExclLock("alignedPoolLock", RANK_LEAF);
+ alignedPool.lock = MXUser_CreateSingletonExclLock(&alignedPoolLockStorage,
+ "alignedPoolLock",
+ RANK_LEAF);
+ ASSERT_NOT_IMPLEMENTED(alignedPool.lock);
}