#include "field.h"
#include "excep.h"
#include "eeconfig.h"
-#include "rwlock.h"
#include "runtimehandles.h"
#include "customattribute.h"
#include "debugdebugger.h"
#include "comdelegate.h"
#include "appdomain.hpp"
#include "perfcounters.h"
-#include "rwlock.h"
#ifdef FEATURE_IPCMAN
#include "ipcmanagerinterface.h"
#endif // FEATURE_IPCMAN
g_pEEShutDownEvent = new CLREvent();
g_pEEShutDownEvent->CreateManualEvent(FALSE);
-#ifdef FEATURE_RWLOCK
- // Initialize RWLocks
- CRWLock::ProcessInit();
-#endif // FEATURE_RWLOCK
#ifdef FEATURE_IPCMAN
#include "eeconfig.h"
#include "dbginterface.h"
#include "ceemain.h"
-#include "rwlock.h"
#include "hosting.h"
#include "eepolicy.h"
#include "clrex.h"
FCFuncEnd()
-#ifdef FEATURE_RWLOCK
-FCFuncStart(gRWLockFuncs)
- FCFuncElement("AcquireReaderLockInternal", CRWLock::StaticAcquireReaderLockPublic)
- FCFuncElement("AcquireWriterLockInternal", CRWLock::StaticAcquireWriterLockPublic)
- FCFuncElement("ReleaseReaderLockInternal", CRWLock::StaticReleaseReaderLockPublic)
- FCFuncElement("ReleaseWriterLockInternal", CRWLock::StaticReleaseWriterLockPublic)
- FCFuncElement("FCallUpgradeToWriterLock", CRWLock::StaticDoUpgradeToWriterLockPublic)
- FCFuncElement("DowngradeFromWriterLockInternal", CRWLock::StaticDowngradeFromWriterLock)
- FCFuncElement("FCallReleaseLock", CRWLock::StaticDoReleaseLock)
- FCFuncElement("RestoreLockInternal", CRWLock::StaticRestoreLockPublic)
- FCFuncElement("PrivateGetIsReaderLockHeld", CRWLock::StaticIsReaderLockHeld)
- FCFuncElement("PrivateGetIsWriterLockHeld", CRWLock::StaticIsWriterLockHeld)
- FCFuncElement("PrivateGetWriterSeqNum", CRWLock::StaticGetWriterSeqNum)
- FCFuncElement("AnyWritersSince", CRWLock::StaticAnyWritersSince)
- FCFuncElement("PrivateInitialize", CRWLock::StaticPrivateInitialize)
- FCFuncElement("PrivateDestruct", CRWLock::StaticPrivateDestruct)
-FCFuncEnd()
-#endif // FEATURE_RWLOCK
FCClassElement("PunkSafeHandle", "System.Reflection.Emit", gSymWrapperCodePunkSafeHandleFuncs)
-#ifdef FEATURE_RWLOCK
-FCClassElement("ReaderWriterLock", "System.Threading", gRWLockFuncs)
-#endif // FEATURE_RWLOCK
FCClassElement("RegisteredWaitHandleSafe", "System.Threading", gRegisteredWaitHandleFuncs)
#ifdef FEATURE_COMINTEROP
#ifdef FEATURE_COMINTEROP_MANAGED_ACTIVATION
#include "debugdebugger.h"
#include "assemblyname.hpp"
#include "assemblynative.hpp"
-#include "rwlock.h"
#include "comthreadpool.h"
#include "comwaithandle.h"
#include "nativeoverlapped.h"
DEFINE_CLASS(PROPERTY_INFO, Reflection, PropertyInfo)
-#ifdef FEATURE_RWLOCK
-DEFINE_CLASS_U(Threading, ReaderWriterLock, CRWLock)
-DEFINE_FIELD_U(_hWriterEvent, CRWLock, _hWriterEvent)
-DEFINE_FIELD_U(_hReaderEvent, CRWLock, _hReaderEvent)
-DEFINE_FIELD_U(_hObjectHandle, CRWLock, _hObjectHandle)
-DEFINE_FIELD_U(_dwState, CRWLock, _dwState)
-DEFINE_FIELD_U(_dwULockID, CRWLock, _dwULockID)
-DEFINE_FIELD_U(_dwLLockID, CRWLock, _dwLLockID)
-DEFINE_FIELD_U(_dwWriterID, CRWLock, _dwWriterID)
-DEFINE_FIELD_U(_dwWriterSeqNum, CRWLock, _dwWriterSeqNum)
-DEFINE_FIELD_U(_wWriterLevel, CRWLock, _wWriterLevel)
-#endif // FEATURE_RWLOCK
-
-
DEFINE_CLASS(METADATA_IMPORT, Reflection, MetadataImport)
DEFINE_METHOD(METADATA_IMPORT, THROW_ERROR, ThrowError, SM_Int_RetVoid)
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-
-//
-//+-------------------------------------------------------------------
-//
-// File: RWLock.h
-//
-// Contents: Reader writer lock implementation that supports the
-// following features
-// 1. Cheap enough to be used in large numbers
-// such as per object synchronization.
-// 2. Supports timeout. This is a valuable feature
-// to detect deadlocks
-// 3. Supports caching of events. The allows
-// the events to be moved from least contentious
-// regions to the most contentious regions.
-// In other words, the number of events needed by
-// Reader-Writer lockls is bounded by the number
-// of threads in the process.
-// 4. Supports nested locks by readers and writers
-// 5. Supports spin counts for avoiding context switches
-// on multi processor machines.
-// 6. Supports functionality for upgrading to a writer
-// lock with a return argument that indicates
-// intermediate writes. Downgrading from a writer
-// lock restores the state of the lock.
-// 7. Supports functionality to Release Lock for calling
-// app code. RestoreLock restores the lock state and
-// indicates intermediate writes.
-// 8. Recovers from most common failures such as creation of
-// events. In other words, the lock mainitains consistent
-// internal state and remains usable
-//
-// Classes: CRWLock,
-// CStaticRWLock
-//
-//--------------------------------------------------------------------
-
-#ifdef FEATURE_RWLOCK
-#ifndef _RWLOCK_H_
-#define _RWLOCK_H_
-#include "common.h"
-#include "threads.h"
-
-// If you do define this, make sure you define this in managed as well.
-//#define RWLOCK_STATISTICS 0
-
-extern DWORD gdwDefaultTimeout;
-extern DWORD gdwDefaultSpinCount;
-
-
-//+-------------------------------------------------------------------
-//
-// Struct: LockCookie
-//
-// Synopsis: Lock cookies returned to the client
-//
-//+-------------------------------------------------------------------
-typedef struct {
- DWORD dwFlags;
- DWORD dwWriterSeqNum;
- WORD wReaderLevel;
- WORD wWriterLevel;
- DWORD dwThreadID;
-} LockCookie;
-
-#endif // _RWLOCK_H_
-
-#endif // FEATURE_RWLOCK
-
#include "fcall.h"
#include "qcall.h"
#include "cgensys.h"
-#include "rwlock.h"
#define SPFLAGSASSERTION 0x01
#define SPFLAGSUNMANAGEDCODE 0x02
#include "corhost.h"
#include "synch.h"
-#include "rwlock.h"
void CLREventBase::CreateAutoEvent (BOOL bInitialState // If TRUE, initial state is signalled
)
}
}
-#ifdef FEATURE_RWLOCK
-void CLREventBase::CreateRWLockWriterEvent (BOOL bInitialState, // If TRUE, initial state is signalled
- CRWLock *pRWLock
- )
-{
- CONTRACTL
- {
- THROWS;
- GC_NOTRIGGER;
- // disallow creation of Crst before EE starts
- PRECONDITION((g_fEEStarted));
- PRECONDITION((m_handle == INVALID_HANDLE_VALUE));
- PRECONDITION((GetThread() != NULL));
- PRECONDITION((!IsOSEvent()));
- }
- CONTRACTL_END;
-
- SetAutoEvent();
-
- {
- HANDLE h = UnsafeCreateEvent(NULL,FALSE,bInitialState,NULL);
- if (h == NULL) {
- ThrowOutOfMemory();
- }
- m_handle = h;
- }
-
- SetInDeadlockDetection();
-}
-
-void CLREventBase::CreateRWLockReaderEvent (BOOL bInitialState, // If TRUE, initial state is signalled
- CRWLock *pRWLock
- )
-{
- CONTRACTL
- {
- THROWS;
- GC_NOTRIGGER;
- // disallow creation of Crst before EE starts
- PRECONDITION((g_fEEStarted));
- PRECONDITION((m_handle == INVALID_HANDLE_VALUE));
- PRECONDITION((GetThread() != NULL));
- PRECONDITION((!IsOSEvent()));
- }
- CONTRACTL_END;
-
- IHostSyncManager *pManager = CorHost2::GetHostSyncManager();
- if (pManager == NULL) {
- HANDLE h = UnsafeCreateEvent(NULL,TRUE,bInitialState,NULL);
- if (h == NULL) {
- ThrowOutOfMemory();
- }
- m_handle = h;
- }
- else {
- IHostManualEvent *pEvent;
- HRESULT hr;
- SIZE_T cookie = (SIZE_T)pRWLock->GetObjectHandle();
- BEGIN_SO_TOLERANT_CODE_CALLING_HOST(GetThread());
- hr = pManager->CreateRWLockReaderEvent(bInitialState, cookie, &pEvent);
- END_SO_TOLERANT_CODE_CALLING_HOST;
- if (hr != S_OK) {
- _ASSERTE (hr == E_OUTOFMEMORY);
- ThrowOutOfMemory();
- }
- m_handle = (HANDLE)pEvent;
- }
-
- SetInDeadlockDetection();
-}
-#endif // FEATURE_RWLOCK
void CLREventBase::CreateOSAutoEvent (BOOL bInitialState // If TRUE, initial state is signalled
void CreateMonitorEvent(SIZE_T Cookie); // robust against initialization races - for exclusive use by AwareLock
-#ifdef FEATURE_RWLOCK
- void CreateRWLockReaderEvent(BOOL bInitialState, CRWLock* pRWLock);
- void CreateRWLockWriterEvent(BOOL bInitialState, CRWLock* pRWLock);
-#endif
// Create an Event that is not host aware
void CreateOSAutoEvent (BOOL bInitialState);