mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
modifiy ExIsResourceAcquiredxxx
svn path=/trunk/; revision=342
This commit is contained in:
parent
e4981e3a09
commit
db7bc7b4e8
1 changed files with 46 additions and 10 deletions
|
@ -7,6 +7,26 @@
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
* Created 22/05/98
|
* Created 22/05/98
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
|
* Usage of ERESOURCE members is not documented.
|
||||||
|
* From names of members and functionnalities, we can assume :
|
||||||
|
* ActiveCount = number of threads who have access to the resource
|
||||||
|
* OwnerTable = list of threads who have shared access
|
||||||
|
* OwnerThreads[0]= thread who have exclusive access
|
||||||
|
* OwnerThreads[1]= thread who have shared access if only one thread
|
||||||
|
* else
|
||||||
|
* OwnerThread=0
|
||||||
|
* and TableSize = number of entries in the owner table
|
||||||
|
* Flag = bits : ResourceOwnedExclusive=0x80
|
||||||
|
* ResourceNeverExclusive=0x10
|
||||||
|
* ResourceReleaseByOtherThread=0x20
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define ResourceOwnedExclusive 0x80
|
||||||
|
|
||||||
|
/* INCLUDES *****************************************************************/
|
||||||
|
|
||||||
|
|
||||||
/* INCLUDES *****************************************************************/
|
/* INCLUDES *****************************************************************/
|
||||||
|
|
||||||
|
@ -78,31 +98,47 @@ NTSTATUS ExInitializeResource(PERESOURCE Resource)
|
||||||
|
|
||||||
NTSTATUS ExInitializeResourceLite(PERESOURCE Resource)
|
NTSTATUS ExInitializeResourceLite(PERESOURCE Resource)
|
||||||
{
|
{
|
||||||
Resource->NumberOfSharedWaiters = 0;
|
memset(Resource,0,sizeof(ERESOURCE));
|
||||||
Resource->NumberOfExclusiveWaiters = 0;
|
// Resource->NumberOfSharedWaiters = 0;
|
||||||
|
// Resource->NumberOfExclusiveWaiters = 0;
|
||||||
KeInitializeSpinLock(&Resource->SpinLock);
|
KeInitializeSpinLock(&Resource->SpinLock);
|
||||||
Resource->Flag=0;
|
// Resource->Flag=0;
|
||||||
Resource->ExclusiveWaiters = ExAllocatePool(NonPagedPool,
|
Resource->ExclusiveWaiters = ExAllocatePool(NonPagedPool,
|
||||||
sizeof(KEVENT));
|
sizeof(KEVENT));
|
||||||
KeInitializeEvent(Resource->ExclusiveWaiters,
|
KeInitializeEvent(Resource->ExclusiveWaiters,SynchronizationEvent,
|
||||||
SynchronizationEvent,
|
|
||||||
FALSE);
|
FALSE);
|
||||||
Resource->SharedWaiters = ExAllocatePool(NonPagedPool,
|
Resource->SharedWaiters = ExAllocatePool(NonPagedPool,
|
||||||
sizeof(KSEMAPHORE));
|
sizeof(KSEMAPHORE));
|
||||||
KeInitializeSemaphore(Resource->SharedWaiters,5,0);
|
KeInitializeSemaphore(Resource->SharedWaiters,5,0);
|
||||||
Resource->ActiveCount = 0;
|
// Resource->ActiveCount = 0;
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOLEAN ExIsResourceAcquiredExclusiveLite(PERESOURCE Resource)
|
BOOLEAN ExIsResourceAcquiredExclusiveLite(PERESOURCE Resource)
|
||||||
{
|
{
|
||||||
return(Resource->NumberOfExclusiveWaiters!=0);
|
return((Resource->Flag & ResourceOwnedExclusive)
|
||||||
|
&& Resource->OwnerThreads[0].OwnerThread==ExGetCurrentResourceThread());
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOLEAN ExIsResourceAcquiredSharedLite(PERESOURCE Resource)
|
/* note : this function is defined USHORT in nt4, but ULONG in nt5
|
||||||
|
* ULONG is more logical, since return value is number of times the resource
|
||||||
|
* is acquired by the caller, and this value is defined ULONG in
|
||||||
|
* PERESOURCE struct
|
||||||
|
*/
|
||||||
|
ULONG ExIsResourceAcquiredSharedLite(PERESOURCE Resource)
|
||||||
{
|
{
|
||||||
return(Resource->NumberOfSharedWaiters!=0);
|
long i;
|
||||||
|
if(Resource->OwnerThreads[0].OwnerThread==ExGetCurrentResourceThread())
|
||||||
|
return Resource->OwnerThreads[0].a.OwnerCount;
|
||||||
|
if(Resource->OwnerThreads[1].OwnerThread==ExGetCurrentResourceThread())
|
||||||
|
return Resource->OwnerThreads[1].a.OwnerCount;
|
||||||
|
if(!Resource->OwnerThreads[1].a.TableSize) return 0;
|
||||||
|
for(i=0;i<Resource->OwnerThreads[1].a.TableSize;i++)
|
||||||
|
{
|
||||||
|
if(Resource->OwnerTable[i].OwnerThread==ExGetCurrentResourceThread())
|
||||||
|
return Resource->OwnerTable[i].a.OwnerCount;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID ExReinitializeResourceLite(PERESOURCE Resource)
|
VOID ExReinitializeResourceLite(PERESOURCE Resource)
|
||||||
|
|
Loading…
Reference in a new issue