Support non-paged version of binary tree, splay tree and hash table.

svn path=/trunk/; revision=2771
This commit is contained in:
Casper Hornstrup 2002-03-23 13:53:22 +00:00
parent 716ec9c7cf
commit 59562362a8
7 changed files with 316 additions and 74 deletions

View file

@ -824,7 +824,8 @@ ExHookException (
BOOLEAN STDCALL BOOLEAN STDCALL
ExInitializeBinaryTree(IN PBINARY_TREE Tree, ExInitializeBinaryTree(IN PBINARY_TREE Tree,
IN PKEY_COMPARATOR Compare); IN PKEY_COMPARATOR Compare,
IN BOOLEAN UseNonPagedPool);
VOID STDCALL VOID STDCALL
ExDeleteBinaryTree(IN PBINARY_TREE Tree); ExDeleteBinaryTree(IN PBINARY_TREE Tree);
@ -847,7 +848,8 @@ ExRemoveBinaryTree(IN PBINARY_TREE Tree,
BOOLEAN STDCALL BOOLEAN STDCALL
ExInitializeSplayTree(IN PSPLAY_TREE Tree, ExInitializeSplayTree(IN PSPLAY_TREE Tree,
IN PKEY_COMPARATOR Compare, IN PKEY_COMPARATOR Compare,
IN BOOLEAN Weighted); IN BOOLEAN Weighted,
IN BOOLEAN UseNonPagedPool);
VOID STDCALL VOID STDCALL
ExDeleteSplayTree(IN PSPLAY_TREE Tree); ExDeleteSplayTree(IN PSPLAY_TREE Tree);
@ -874,7 +876,8 @@ ExWeightOfSplayTree(IN PSPLAY_TREE Tree,
BOOLEAN STDCALL BOOLEAN STDCALL
ExInitializeHashTable(IN PHASH_TABLE HashTable, ExInitializeHashTable(IN PHASH_TABLE HashTable,
IN ULONG HashTableSize, IN ULONG HashTableSize,
IN PKEY_COMPARATOR Compare OPTIONAL); IN PKEY_COMPARATOR Compare OPTIONAL,
IN BOOLEAN UseNonPagedPool);
VOID STDCALL VOID STDCALL
ExDeleteHashTable(IN PHASH_TABLE HashTable); ExDeleteHashTable(IN PHASH_TABLE HashTable);

View file

@ -1,4 +1,4 @@
/* $Id: extypes.h,v 1.7 2002/03/22 20:58:23 chorns Exp $ */ /* $Id: extypes.h,v 1.8 2002/03/23 13:53:21 chorns Exp $ */
#ifndef __INCLUDE_DDK_EXTYPES_H #ifndef __INCLUDE_DDK_EXTYPES_H
#define __INCLUDE_DDK_EXTYPES_H #define __INCLUDE_DDK_EXTYPES_H
@ -169,8 +169,15 @@ typedef struct _BINARY_TREE
{ {
struct _BINARY_TREE_NODE * RootNode; struct _BINARY_TREE_NODE * RootNode;
PKEY_COMPARATOR Compare; PKEY_COMPARATOR Compare;
PAGED_LOOKASIDE_LIST LookasideList; BOOLEAN UseNonPagedPool;
FAST_MUTEX Lock; union {
NPAGED_LOOKASIDE_LIST NonPaged;
PAGED_LOOKASIDE_LIST Paged;
} List;
union {
KSPIN_LOCK NonPaged;
FAST_MUTEX Paged;
} Lock;
} BINARY_TREE, *PBINARY_TREE; } BINARY_TREE, *PBINARY_TREE;
@ -181,20 +188,33 @@ typedef struct _SPLAY_TREE
struct _SPLAY_TREE_NODE * RootNode; struct _SPLAY_TREE_NODE * RootNode;
PKEY_COMPARATOR Compare; PKEY_COMPARATOR Compare;
BOOLEAN Weighted; BOOLEAN Weighted;
PAGED_LOOKASIDE_LIST LookasideList; BOOLEAN UseNonPagedPool;
FAST_MUTEX Lock; union {
NPAGED_LOOKASIDE_LIST NonPaged;
PAGED_LOOKASIDE_LIST Paged;
} List;
union {
KSPIN_LOCK NonPaged;
FAST_MUTEX Paged;
} Lock;
PVOID Reserved[4]; PVOID Reserved[4];
} SPLAY_TREE, *PSPLAY_TREE; } SPLAY_TREE, *PSPLAY_TREE;
typedef struct _HASH_TABLE typedef struct _HASH_TABLE
{ {
// Lock for this structure
FAST_MUTEX Lock;
// Size of hash table in number of bits // Size of hash table in number of bits
ULONG HashTableSize; ULONG HashTableSize;
// Use non-paged pool memory?
BOOLEAN UseNonPagedPool;
// Lock for this structure
union {
KSPIN_LOCK NonPaged;
FAST_MUTEX Paged;
} Lock;
// Pointer to array of hash buckets with splay trees // Pointer to array of hash buckets with splay trees
PSPLAY_TREE HashTrees; PSPLAY_TREE HashTrees;
} HASH_TABLE, *PHASH_TABLE; } HASH_TABLE, *PHASH_TABLE;

View file

@ -56,6 +56,42 @@ typedef struct _BINARY_TREE_NODE
#define ExpBinaryTreeNodeMore(Equality)((Equality) > 0) #define ExpBinaryTreeNodeMore(Equality)((Equality) > 0)
/*
* Lock the binary tree
*/
inline VOID
ExpLockBinaryTree(PBINARY_TREE Tree,
PKIRQL OldIrql)
{
if (Tree->UseNonPagedPool)
{
KeAcquireSpinLock(&Tree->Lock.NonPaged, OldIrql);
}
else
{
ExAcquireFastMutex(&Tree->Lock.Paged);
}
}
/*
* Unlock the binary tree
*/
inline VOID
ExpUnlockBinaryTree(PBINARY_TREE Tree,
PKIRQL OldIrql)
{
if (Tree->UseNonPagedPool)
{
KeReleaseSpinLock(&Tree->Lock.NonPaged, *OldIrql);
}
else
{
ExReleaseFastMutex(&Tree->Lock.Paged);
}
}
/* /*
* Allocate resources for a new node and initialize it. * Allocate resources for a new node and initialize it.
*/ */
@ -66,7 +102,14 @@ ExpCreateBinaryTreeNode(PBINARY_TREE Tree,
{ {
PBINARY_TREE_NODE Node; PBINARY_TREE_NODE Node;
Node = (PBINARY_TREE_NODE) ExAllocateFromPagedLookasideList(&Tree->LookasideList); if (Tree->UseNonPagedPool)
{
Node = (PBINARY_TREE_NODE) ExAllocateFromNPagedLookasideList(&Tree->List.NonPaged);
}
else
{
Node = (PBINARY_TREE_NODE) ExAllocateFromPagedLookasideList(&Tree->List.Paged);
}
if (Node) if (Node)
{ {
@ -87,7 +130,14 @@ inline VOID
ExpDestroyBinaryTreeNode(PBINARY_TREE Tree, ExpDestroyBinaryTreeNode(PBINARY_TREE Tree,
PBINARY_TREE_NODE Node) PBINARY_TREE_NODE Node)
{ {
ExFreeToPagedLookasideList(&Tree->LookasideList, Node); if (Tree->UseNonPagedPool)
{
ExFreeToNPagedLookasideList(&Tree->List.NonPaged, Node);
}
else
{
ExFreeToPagedLookasideList(&Tree->List.Paged, Node);
}
} }
@ -273,29 +323,55 @@ ExpBinaryTreeDefaultCompare(PVOID Key1,
*/ */
BOOLEAN STDCALL BOOLEAN STDCALL
ExInitializeBinaryTree(IN PBINARY_TREE Tree, ExInitializeBinaryTree(IN PBINARY_TREE Tree,
IN PKEY_COMPARATOR Compare) IN PKEY_COMPARATOR Compare,
IN BOOLEAN UseNonPagedPool)
{ {
RtlZeroMemory(Tree, sizeof(BINARY_TREE)); RtlZeroMemory(Tree, sizeof(BINARY_TREE));
Tree->Compare = (Compare == NULL) Tree->Compare = (Compare == NULL)
? ExpBinaryTreeDefaultCompare : Compare; ? ExpBinaryTreeDefaultCompare : Compare;
ExInitializePagedLookasideList( Tree->UseNonPagedPool = UseNonPagedPool;
&Tree->LookasideList, /* Lookaside list */
NULL, /* Allocate routine */
NULL, /* Free routine */
0, /* Flags */
sizeof(BINARY_TREE_NODE), /* Size of each entry */
TAG('E','X','B','T'), /* Tag */
0); /* Depth */
ExInitializeFastMutex(&Tree->Lock); if (UseNonPagedPool)
{
ExInitializeNPagedLookasideList(
&Tree->List.NonPaged, /* Lookaside list */
NULL, /* Allocate routine */
NULL, /* Free routine */
0, /* Flags */
sizeof(BINARY_TREE_NODE), /* Size of each entry */
TAG('E','X','B','T'), /* Tag */
0); /* Depth */
KeInitializeSpinLock(&Tree->Lock.NonPaged);
}
else
{
ExInitializePagedLookasideList(
&Tree->List.Paged, /* Lookaside list */
NULL, /* Allocate routine */
NULL, /* Free routine */
0, /* Flags */
sizeof(BINARY_TREE_NODE), /* Size of each entry */
TAG('E','X','B','T'), /* Tag */
0); /* Depth */
ExInitializeFastMutex(&Tree->Lock.Paged);
}
ExpBinaryTreeRootNode(Tree) = ExpCreateBinaryTreeNode(Tree, NULL, NULL); ExpBinaryTreeRootNode(Tree) = ExpCreateBinaryTreeNode(Tree, NULL, NULL);
if (ExpBinaryTreeRootNode(Tree) == NULL) if (ExpBinaryTreeRootNode(Tree) == NULL)
{ {
ExDeletePagedLookasideList(&Tree->LookasideList); if (UseNonPagedPool)
{
ExDeleteNPagedLookasideList(&Tree->List.NonPaged);
}
else
{
ExDeletePagedLookasideList(&Tree->List.Paged);
}
return FALSE; return FALSE;
} }
else else
@ -314,7 +390,14 @@ ExDeleteBinaryTree(IN PBINARY_TREE Tree)
/* Remove all nodes */ /* Remove all nodes */
ExpDeleteBinaryTree(Tree, ExpBinaryTreeRootNode(Tree)); ExpDeleteBinaryTree(Tree, ExpBinaryTreeRootNode(Tree));
ExDeletePagedLookasideList(&Tree->LookasideList); if (Tree->UseNonPagedPool)
{
ExDeleteNPagedLookasideList(&Tree->List.NonPaged);
}
else
{
ExDeletePagedLookasideList(&Tree->List.Paged);
}
} }
@ -327,10 +410,11 @@ ExInsertBinaryTree(IN PBINARY_TREE Tree,
IN PVOID Value) IN PVOID Value)
{ {
PBINARY_TREE_NODE Node; PBINARY_TREE_NODE Node;
KIRQL OldIrql;
/* FIXME: Use SEH for error reporting */ /* FIXME: Use SEH for error reporting */
ExAcquireFastMutex(&Tree->Lock); ExpLockBinaryTree(Tree, &OldIrql);
Node = ExpBinaryTreeRootNode(Tree); Node = ExpBinaryTreeRootNode(Tree);
do do
{ {
@ -348,7 +432,7 @@ ExInsertBinaryTree(IN PBINARY_TREE Tree,
ExpExpandExternalBinaryTreeNode(Tree, Node); ExpExpandExternalBinaryTreeNode(Tree, Node);
ExpBinaryTreeNodeKey(Node) = Key; ExpBinaryTreeNodeKey(Node) = Key;
ExpBinaryTreeNodeValue(Node) = Value; ExpBinaryTreeNodeValue(Node) = Value;
ExReleaseFastMutex(&Tree->Lock); ExpUnlockBinaryTree(Tree, &OldIrql);
} }
@ -361,19 +445,20 @@ ExSearchBinaryTree(IN PBINARY_TREE Tree,
OUT PVOID * Value) OUT PVOID * Value)
{ {
PBINARY_TREE_NODE Node; PBINARY_TREE_NODE Node;
KIRQL OldIrql;
ExAcquireFastMutex(&Tree->Lock); ExpLockBinaryTree(Tree, &OldIrql);
Node = ExpSearchBinaryTree(Tree, Key, ExpBinaryTreeRootNode(Tree)); Node = ExpSearchBinaryTree(Tree, Key, ExpBinaryTreeRootNode(Tree));
if (ExpIsInternalBinaryTreeNode(Node)) if (ExpIsInternalBinaryTreeNode(Node))
{ {
*Value = ExpBinaryTreeNodeValue(Node); *Value = ExpBinaryTreeNodeValue(Node);
ExReleaseFastMutex(&Tree->Lock); ExpUnlockBinaryTree(Tree, &OldIrql);
return TRUE; return TRUE;
} }
else else
{ {
ExReleaseFastMutex(&Tree->Lock); ExpUnlockBinaryTree(Tree, &OldIrql);
return FALSE; return FALSE;
} }
} }
@ -388,13 +473,15 @@ ExRemoveBinaryTree(IN PBINARY_TREE Tree,
IN PVOID * Value) IN PVOID * Value)
{ {
PBINARY_TREE_NODE Node; PBINARY_TREE_NODE Node;
KIRQL OldIrql;
ExpLockBinaryTree(Tree, &OldIrql);
ExAcquireFastMutex(&Tree->Lock);
Node = ExpSearchBinaryTree(Tree, Key, ExpBinaryTreeRootNode(Tree)); Node = ExpSearchBinaryTree(Tree, Key, ExpBinaryTreeRootNode(Tree));
if (ExpIsExternalBinaryTreeNode(Node)) if (ExpIsExternalBinaryTreeNode(Node))
{ {
ExReleaseFastMutex(&Tree->Lock); ExpUnlockBinaryTree(Tree, &OldIrql);
return FALSE; return FALSE;
} }
else else
@ -422,7 +509,7 @@ ExRemoveBinaryTree(IN PBINARY_TREE Tree,
} }
ExpRemoveAboveExternalBinaryTreeNode(Tree, Node); ExpRemoveAboveExternalBinaryTreeNode(Tree, Node);
ExReleaseFastMutex(&Tree->Lock); ExpUnlockBinaryTree(Tree, &OldIrql);
return TRUE; return TRUE;
} }
} }

View file

@ -98,6 +98,42 @@ ExpHash(PUCHAR Key,
} }
/*
* Lock the hash table
*/
inline VOID
ExpLockHashTable(PHASH_TABLE HashTable,
PKIRQL OldIrql)
{
if (HashTable->UseNonPagedPool)
{
KeAcquireSpinLock(&HashTable->Lock.NonPaged, OldIrql);
}
else
{
ExAcquireFastMutex(&HashTable->Lock.Paged);
}
}
/*
* Unlock the hash table
*/
inline VOID
ExpUnlockHashTable(PHASH_TABLE HashTable,
PKIRQL OldIrql)
{
if (HashTable->UseNonPagedPool)
{
KeReleaseSpinLock(&HashTable->Lock.NonPaged, *OldIrql);
}
else
{
ExReleaseFastMutex(&HashTable->Lock.Paged);
}
}
/* /*
* Insert a value in a hash table. * Insert a value in a hash table.
*/ */
@ -155,7 +191,8 @@ ExpRemoveHashTable(IN PHASH_TABLE HashTable,
BOOLEAN STDCALL BOOLEAN STDCALL
ExInitializeHashTable(IN PHASH_TABLE HashTable, ExInitializeHashTable(IN PHASH_TABLE HashTable,
IN ULONG HashTableSize, IN ULONG HashTableSize,
IN PKEY_COMPARATOR Compare OPTIONAL) IN PKEY_COMPARATOR Compare OPTIONAL,
IN BOOLEAN UseNonPagedPool)
{ {
BOOLEAN Status; BOOLEAN Status;
LONG Index; LONG Index;
@ -164,9 +201,18 @@ ExInitializeHashTable(IN PHASH_TABLE HashTable,
HashTable->HashTableSize = HashTableSize; HashTable->HashTableSize = HashTableSize;
ExInitializeFastMutex(&HashTable->Lock); HashTable->UseNonPagedPool = UseNonPagedPool;
HashTable->HashTrees = ExAllocatePool(PagedPool, ExpHashTableSize(HashTableSize) * sizeof(SPLAY_TREE)); if (UseNonPagedPool)
{
KeInitializeSpinLock(&HashTable->Lock.NonPaged);
HashTable->HashTrees = ExAllocatePool(NonPagedPool, ExpHashTableSize(HashTableSize) * sizeof(SPLAY_TREE));
}
else
{
ExInitializeFastMutex(&HashTable->Lock.Paged);
HashTable->HashTrees = ExAllocatePool(PagedPool, ExpHashTableSize(HashTableSize) * sizeof(SPLAY_TREE));
}
if (HashTable->HashTrees == NULL) if (HashTable->HashTrees == NULL)
{ {
@ -175,7 +221,7 @@ ExInitializeHashTable(IN PHASH_TABLE HashTable,
for (Index = 0; Index < ExpHashTableSize(HashTableSize); Index++) for (Index = 0; Index < ExpHashTableSize(HashTableSize); Index++)
{ {
Status = ExInitializeSplayTree(&HashTable->HashTrees[Index], Compare, FALSE); Status = ExInitializeSplayTree(&HashTable->HashTrees[Index], Compare, FALSE, UseNonPagedPool);
if (!Status) if (!Status)
{ {
@ -222,11 +268,13 @@ ExInsertHashTable(IN PHASH_TABLE HashTable,
IN ULONG KeyLength, IN ULONG KeyLength,
IN PVOID Value) IN PVOID Value)
{ {
KIRQL OldIrql;
/* FIXME: Use SEH for error reporting */ /* FIXME: Use SEH for error reporting */
ExAcquireFastMutex(&HashTable->Lock); ExpLockHashTable(HashTable, &OldIrql);
ExpInsertHashTable(HashTable, Key, KeyLength, Value); ExpInsertHashTable(HashTable, Key, KeyLength, Value);
ExReleaseFastMutex(&HashTable->Lock); ExpUnlockHashTable(HashTable, &OldIrql);
} }
@ -240,10 +288,11 @@ ExSearchHashTable(IN PHASH_TABLE HashTable,
OUT PVOID * Value) OUT PVOID * Value)
{ {
BOOLEAN Status; BOOLEAN Status;
KIRQL OldIrql;
ExAcquireFastMutex(&HashTable->Lock); ExpLockHashTable(HashTable, &OldIrql);
Status = ExpSearchHashTable(HashTable, Key, KeyLength, Value); Status = ExpSearchHashTable(HashTable, Key, KeyLength, Value);
ExReleaseFastMutex(&HashTable->Lock); ExpUnlockHashTable(HashTable, &OldIrql);
return Status; return Status;
} }
@ -259,10 +308,11 @@ ExRemoveHashTable(IN PHASH_TABLE HashTable,
IN PVOID * Value) IN PVOID * Value)
{ {
BOOLEAN Status; BOOLEAN Status;
KIRQL OldIrql;
ExAcquireFastMutex(&HashTable->Lock); ExpLockHashTable(HashTable, &OldIrql);
Status = ExpRemoveHashTable(HashTable, Key, KeyLength, Value); Status = ExpRemoveHashTable(HashTable, Key, KeyLength, Value);
ExReleaseFastMutex(&HashTable->Lock); ExpUnlockHashTable(HashTable, &OldIrql);
return Status; return Status;
} }

View file

@ -101,6 +101,42 @@ typedef PSPLAY_TREE_NODE (*PSPLAY_TREE_REMOVE)(PSPLAY_TREE Tree,
#define KEY_NOTUSED (PVOID)-1 #define KEY_NOTUSED (PVOID)-1
/*
* Lock the splay tree
*/
inline VOID
ExpLockSplayTree(PSPLAY_TREE Tree,
PKIRQL OldIrql)
{
if (Tree->UseNonPagedPool)
{
KeAcquireSpinLock(&Tree->Lock.NonPaged, OldIrql);
}
else
{
ExAcquireFastMutex(&Tree->Lock.Paged);
}
}
/*
* Unlock the splay tree
*/
inline VOID
ExpUnlockSplayTree(PSPLAY_TREE Tree,
PKIRQL OldIrql)
{
if (Tree->UseNonPagedPool)
{
KeReleaseSpinLock(&Tree->Lock.NonPaged, *OldIrql);
}
else
{
ExReleaseFastMutex(&Tree->Lock.Paged);
}
}
/* /*
* Allocate resources for a new node and initialize it. * Allocate resources for a new node and initialize it.
*/ */
@ -110,7 +146,14 @@ ExpCreateSplayTreeNode(PSPLAY_TREE Tree,
{ {
PSPLAY_TREE_NODE Node; PSPLAY_TREE_NODE Node;
Node = (PSPLAY_TREE_NODE) ExAllocateFromPagedLookasideList(&Tree->LookasideList); if (Tree->UseNonPagedPool)
{
Node = (PSPLAY_TREE_NODE) ExAllocateFromNPagedLookasideList(&Tree->List.NonPaged);
}
else
{
Node = (PSPLAY_TREE_NODE) ExAllocateFromPagedLookasideList(&Tree->List.Paged);
}
if (Node) if (Node)
{ {
@ -129,7 +172,14 @@ inline VOID
ExpDestroySplayTreeNode(PSPLAY_TREE Tree, ExpDestroySplayTreeNode(PSPLAY_TREE Tree,
PSPLAY_TREE_NODE Node) PSPLAY_TREE_NODE Node)
{ {
ExFreeToPagedLookasideList(&Tree->LookasideList, Node); if (Tree->UseNonPagedPool)
{
ExFreeToNPagedLookasideList(&Tree->List.NonPaged, Node);
}
else
{
ExFreeToPagedLookasideList(&Tree->List.Paged, Node);
}
} }
@ -913,7 +963,8 @@ ExpSplayTreeDefaultCompare(IN PVOID Key1,
BOOLEAN STDCALL BOOLEAN STDCALL
ExInitializeSplayTree(IN PSPLAY_TREE Tree, ExInitializeSplayTree(IN PSPLAY_TREE Tree,
IN PKEY_COMPARATOR Compare, IN PKEY_COMPARATOR Compare,
IN BOOLEAN Weighted) IN BOOLEAN Weighted,
IN BOOLEAN UseNonPagedPool)
{ {
RtlZeroMemory(Tree, sizeof(SPLAY_TREE)); RtlZeroMemory(Tree, sizeof(SPLAY_TREE));
@ -937,16 +988,34 @@ ExInitializeSplayTree(IN PSPLAY_TREE Tree,
Tree->Reserved[REMOVE_INDEX] = (PVOID) ExpRemoveSplayTreeNoWeight; Tree->Reserved[REMOVE_INDEX] = (PVOID) ExpRemoveSplayTreeNoWeight;
} }
ExInitializePagedLookasideList( Tree->UseNonPagedPool = UseNonPagedPool;
&Tree->LookasideList, /* Lookaside list */
NULL, /* Allocate routine */
NULL, /* Free routine */
0, /* Flags */
sizeof(SPLAY_TREE_NODE), /* Size of each entry */
TAG('E','X','S','T'), /* Tag */
0); /* Depth */
ExInitializeFastMutex(&Tree->Lock); if (UseNonPagedPool)
{
ExInitializeNPagedLookasideList(
&Tree->List.NonPaged, /* Lookaside list */
NULL, /* Allocate routine */
NULL, /* Free routine */
0, /* Flags */
sizeof(SPLAY_TREE_NODE), /* Size of each entry */
TAG('E','X','S','T'), /* Tag */
0); /* Depth */
KeInitializeSpinLock(&Tree->Lock.NonPaged);
}
else
{
ExInitializePagedLookasideList(
&Tree->List.Paged, /* Lookaside list */
NULL, /* Allocate routine */
NULL, /* Free routine */
0, /* Flags */
sizeof(SPLAY_TREE_NODE), /* Size of each entry */
TAG('E','X','S','T'), /* Tag */
0); /* Depth */
ExInitializeFastMutex(&Tree->Lock.Paged);
}
return TRUE; return TRUE;
} }
@ -973,7 +1042,14 @@ ExDeleteSplayTree(IN PSPLAY_TREE Tree)
} }
} }
ExDeletePagedLookasideList(&Tree->LookasideList); if (Tree->UseNonPagedPool)
{
ExDeleteNPagedLookasideList(&Tree->List.NonPaged);
}
else
{
ExDeletePagedLookasideList(&Tree->List.Paged);
}
} }
@ -987,15 +1063,16 @@ ExInsertSplayTree(IN PSPLAY_TREE Tree,
{ {
PSPLAY_TREE_NODE Node; PSPLAY_TREE_NODE Node;
PSPLAY_TREE_NODE NewNode; PSPLAY_TREE_NODE NewNode;
KIRQL OldIrql;
/* FIXME: Use SEH for error reporting */ /* FIXME: Use SEH for error reporting */
NewNode = ExpCreateSplayTreeNode(Tree, Value); NewNode = ExpCreateSplayTreeNode(Tree, Value);
ExAcquireFastMutex(&Tree->Lock); ExpLockSplayTree(Tree, &OldIrql);
Node = ExpInsertSplayTree(Tree, Key, ExpSplayTreeRootNode(Tree), NewNode); Node = ExpInsertSplayTree(Tree, Key, ExpSplayTreeRootNode(Tree), NewNode);
ExpSplayTreeRootNode(Tree) = Node; ExpSplayTreeRootNode(Tree) = Node;
ExReleaseFastMutex(&Tree->Lock); ExpUnlockSplayTree(Tree, &OldIrql);
} }
@ -1009,20 +1086,21 @@ ExSearchSplayTree(IN PSPLAY_TREE Tree,
{ {
PSPLAY_TREE_NODE Node; PSPLAY_TREE_NODE Node;
BOOLEAN Status; BOOLEAN Status;
KIRQL OldIrql;
ExAcquireFastMutex(&Tree->Lock); ExpLockSplayTree(Tree, &OldIrql);
Status = ExpSearchSplayTree(Tree, Key, ExpSplayTreeRootNode(Tree), &Node); Status = ExpSearchSplayTree(Tree, Key, ExpSplayTreeRootNode(Tree), &Node);
if (Status) if (Status)
{ {
ExpSplayTreeRootNode(Tree) = Node; ExpSplayTreeRootNode(Tree) = Node;
*Value = ExpSplayTreeNodeValue(Node); *Value = ExpSplayTreeNodeValue(Node);
ExReleaseFastMutex(&Tree->Lock); ExpUnlockSplayTree(Tree, &OldIrql);
return TRUE; return TRUE;
} }
else else
{ {
ExReleaseFastMutex(&Tree->Lock); ExpUnlockSplayTree(Tree, &OldIrql);
return FALSE; return FALSE;
} }
} }
@ -1038,11 +1116,12 @@ ExRemoveSplayTree(IN PSPLAY_TREE Tree,
{ {
PSPLAY_TREE_NODE RemovedNode; PSPLAY_TREE_NODE RemovedNode;
PSPLAY_TREE_NODE Node; PSPLAY_TREE_NODE Node;
KIRQL OldIrql;
ExAcquireFastMutex(&Tree->Lock); ExpLockSplayTree(Tree, &OldIrql);
Node = ExpRemoveSplayTree(Tree, Key, ExpSplayTreeRootNode(Tree), &RemovedNode); Node = ExpRemoveSplayTree(Tree, Key, ExpSplayTreeRootNode(Tree), &RemovedNode);
ExpSplayTreeRootNode(Tree) = Node; ExpSplayTreeRootNode(Tree) = Node;
ExReleaseFastMutex(&Tree->Lock); ExpUnlockSplayTree(Tree, &OldIrql);
if (RemovedNode != NULL) if (RemovedNode != NULL)
{ {
@ -1065,16 +1144,19 @@ BOOLEAN STDCALL
ExWeightOfSplayTree(IN PSPLAY_TREE Tree, ExWeightOfSplayTree(IN PSPLAY_TREE Tree,
OUT PULONG Weight) OUT PULONG Weight)
{ {
ExAcquireFastMutex(&Tree->Lock); KIRQL OldIrql;
ExpLockSplayTree(Tree, &OldIrql);
if (!Tree->Weighted) if (!Tree->Weighted)
{ {
ExReleaseFastMutex(&Tree->Lock); ExpUnlockSplayTree(Tree, &OldIrql);
return FALSE; return FALSE;
} }
*Weight = ExpSplayTreeNodeWeight(ExpSplayTreeRootNode(Tree)); *Weight = ExpSplayTreeNodeWeight(ExpSplayTreeRootNode(Tree));
ExReleaseFastMutex(&Tree->Lock); ExpUnlockSplayTree(Tree, &OldIrql);
return TRUE; return TRUE;
} }

View file

@ -1,4 +1,4 @@
; $Id: ntoskrnl.def,v 1.130 2002/03/22 20:58:23 chorns Exp $ ; $Id: ntoskrnl.def,v 1.131 2002/03/23 13:53:22 chorns Exp $
; ;
; reactos/ntoskrnl/ntoskrnl.def ; reactos/ntoskrnl/ntoskrnl.def
; ;
@ -93,18 +93,18 @@ ExSystemTimeToLocalTime@8
ExTryToAcquireResourceExclusiveLite@4 ExTryToAcquireResourceExclusiveLite@4
ExUnregisterCallback@4 ExUnregisterCallback@4
ExWindowStationObjectType DATA ExWindowStationObjectType DATA
ExInitializeBinaryTree@8 ExInitializeBinaryTree@12
ExDeleteBinaryTree@4 ExDeleteBinaryTree@4
ExInsertBinaryTree@12 ExInsertBinaryTree@12
ExSearchBinaryTree@12 ExSearchBinaryTree@12
ExRemoveBinaryTree@12 ExRemoveBinaryTree@12
ExInitializeSplayTree@12 ExInitializeSplayTree@16
ExDeleteSplayTree@4 ExDeleteSplayTree@4
ExInsertSplayTree@12 ExInsertSplayTree@12
ExSearchSplayTree@12 ExSearchSplayTree@12
ExRemoveSplayTree@12 ExRemoveSplayTree@12
ExWeightOfSplayTree@8 ExWeightOfSplayTree@8
ExInitializeHashTable@12 ExInitializeHashTable@16
ExDeleteHashTable@4 ExDeleteHashTable@4
ExInsertHashTable@16 ExInsertHashTable@16
ExSearchHashTable@16 ExSearchHashTable@16

View file

@ -1,4 +1,4 @@
; $Id: ntoskrnl.edf,v 1.116 2002/03/22 20:58:23 chorns Exp $ ; $Id: ntoskrnl.edf,v 1.117 2002/03/23 13:53:22 chorns Exp $
; ;
; reactos/ntoskrnl/ntoskrnl.def ; reactos/ntoskrnl/ntoskrnl.def
; ;
@ -93,18 +93,18 @@ ExSystemTimeToLocalTime=ExSystemTimeToLocalTime@8
ExTryToAcquireResourceExclusiveLite=ExTryToAcquireResourceExclusiveLite@4 ExTryToAcquireResourceExclusiveLite=ExTryToAcquireResourceExclusiveLite@4
ExUnregisterCallback=ExUnregisterCallback@4 ExUnregisterCallback=ExUnregisterCallback@4
ExWindowStationObjectType DATA ExWindowStationObjectType DATA
ExInitializeBinaryTree=ExInitializeBinaryTree@8 ExInitializeBinaryTree=ExInitializeBinaryTree@12
ExDeleteBinaryTree=ExDeleteBinaryTree@4 ExDeleteBinaryTree=ExDeleteBinaryTree@4
ExInsertBinaryTree=ExInsertBinaryTree@12 ExInsertBinaryTree=ExInsertBinaryTree@12
ExSearchBinaryTree=ExSearchBinaryTree@12 ExSearchBinaryTree=ExSearchBinaryTree@12
ExRemoveBinaryTree=ExRemoveBinaryTree@12 ExRemoveBinaryTree=ExRemoveBinaryTree@12
ExInitializeSplayTree=ExInitializeSplayTree@12 ExInitializeSplayTree=ExInitializeSplayTree@16
ExDeleteSplayTree=ExDeleteSplayTree@4 ExDeleteSplayTree=ExDeleteSplayTree@4
ExInsertSplayTree=ExInsertSplayTree@12 ExInsertSplayTree=ExInsertSplayTree@12
ExSearchSplayTree=ExSearchSplayTree@12 ExSearchSplayTree=ExSearchSplayTree@12
ExRemoveSplayTree=ExRemoveSplayTree@12 ExRemoveSplayTree=ExRemoveSplayTree@12
ExWeightOfSplayTree=ExWeightOfSplayTree@8 ExWeightOfSplayTree=ExWeightOfSplayTree@8
ExInitializeHashTable=ExInitializeHashTable@12 ExInitializeHashTable=ExInitializeHashTable@16
ExDeleteHashTable=ExDeleteHashTable@4 ExDeleteHashTable=ExDeleteHashTable@4
ExInsertHashTable=ExInsertHashTable@16 ExInsertHashTable=ExInsertHashTable@16
ExSearchHashTable=ExSearchHashTable@16 ExSearchHashTable=ExSearchHashTable@16