- Used a fast mutex for the client id structure.

svn path=/trunk/; revision=11846
This commit is contained in:
Hartmut Birr 2004-11-27 19:41:55 +00:00
parent ae233008f1
commit 7eacfe074f
2 changed files with 7 additions and 26 deletions

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: ps.h,v 1.75 2004/11/20 16:46:05 weiden Exp $
/* $Id: ps.h,v 1.76 2004/11/27 19:41:55 hbirr Exp $
*
* FILE: ntoskrnl/ke/kthread.c
* PURPOSE: Process manager definitions
@ -653,7 +653,7 @@ typedef struct _CID_OBJECT
LONG ref;
HANDLE Handle;
LIST_ENTRY Entry;
LONG Lock;
FAST_MUTEX Lock;
union
{
struct _EPROCESS *Process;

View file

@ -1,4 +1,4 @@
/* $Id: cid.c,v 1.2 2004/10/12 20:00:40 navaraf Exp $
/* $Id: cid.c,v 1.3 2004/11/27 19:41:55 hbirr Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -66,7 +66,7 @@ PsCreateCidHandle(PVOID Object, POBJECT_TYPE ObjectType, PHANDLE Handle)
if(cido != NULL)
{
cido->ref = 1;
cido->Lock = 0;
ExInitializeFastMutex(&cido->Lock);
cido->Obj.Object = Object;
KeAcquireSpinLock(&CidLock, &oldIrql);
@ -147,35 +147,16 @@ PsLockCidHandle(HANDLE CidHandle, POBJECT_TYPE ObjectType)
if(Found != NULL)
{
ULONG Attempt = 0;
for (;;)
{
if(InterlockedCompareExchange(&Found->Lock, 1, 0) == 0)
{
/* got the lock, bail */
break;
}
if(Attempt++ >= 1)
{
/* wait a little longer */
KeDelayExecutionThread(KernelMode, FALSE, &LongDelay);
}
else
{
/* try again, just wait shortly */
KeDelayExecutionThread(KernelMode, FALSE, &ShortDelay);
}
}
ExAcquireFastMutex(&Found->Lock);
}
return Found;
}
VOID
PsUnlockCidObject(PCID_OBJECT CidObject)
{
InterlockedExchange(&CidObject->Lock, 0);
ExReleaseFastMutex(&CidObject->Lock);
PspDereferenceCidObject(CidObject);
}