mirror of
https://github.com/reactos/reactos.git
synced 2025-05-02 20:30:33 +00:00
[CSRSRV]
- Reduce number of hash collisions during bootup from 10 to 0, by choosing 257 (prime number = good) instead of 256 (power of 2 = bad) - Use ULONG for CsrpStaticThreadCount and CsrpDynamicThreadTotal to fix an MSVC warning. svn path=/trunk/; revision=59591
This commit is contained in:
parent
ca79d2f1e9
commit
1a7d645928
4 changed files with 19 additions and 17 deletions
|
@ -18,8 +18,8 @@
|
|||
|
||||
BOOLEAN (*CsrClientThreadSetup)(VOID) = NULL;
|
||||
UNICODE_STRING CsrApiPortName;
|
||||
volatile LONG CsrpStaticThreadCount;
|
||||
volatile LONG CsrpDynamicThreadTotal;
|
||||
volatile ULONG CsrpStaticThreadCount;
|
||||
volatile ULONG CsrpDynamicThreadTotal;
|
||||
extern ULONG CsrMaxApiRequestThreads;
|
||||
|
||||
/* FUNCTIONS ******************************************************************/
|
||||
|
@ -269,7 +269,7 @@ CsrpCheckRequestThreads(VOID)
|
|||
NTSTATUS Status;
|
||||
|
||||
/* Decrease the count, and see if we're out */
|
||||
if (_InterlockedDecrement(&CsrpStaticThreadCount) == 0)
|
||||
if (InterlockedDecrementUL(&CsrpStaticThreadCount) == 0)
|
||||
{
|
||||
/* Check if we've still got space for a Dynamic Thread */
|
||||
if (CsrpDynamicThreadTotal < CsrMaxApiRequestThreads)
|
||||
|
@ -289,8 +289,8 @@ CsrpCheckRequestThreads(VOID)
|
|||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
/* Increase the thread counts */
|
||||
_InterlockedIncrement(&CsrpStaticThreadCount);
|
||||
_InterlockedIncrement(&CsrpDynamicThreadTotal);
|
||||
InterlockedIncrementUL(&CsrpStaticThreadCount);
|
||||
InterlockedIncrementUL(&CsrpDynamicThreadTotal);
|
||||
|
||||
/* Add a new server thread */
|
||||
if (CsrAddStaticServerThread(hThread,
|
||||
|
@ -303,8 +303,8 @@ CsrpCheckRequestThreads(VOID)
|
|||
else
|
||||
{
|
||||
/* Failed to create a new static thread */
|
||||
_InterlockedDecrement(&CsrpStaticThreadCount);
|
||||
_InterlockedDecrement(&CsrpDynamicThreadTotal);
|
||||
InterlockedDecrementUL(&CsrpStaticThreadCount);
|
||||
InterlockedDecrementUL(&CsrpDynamicThreadTotal);
|
||||
|
||||
/* Terminate it */
|
||||
DPRINT1("Failing\n");
|
||||
|
@ -383,8 +383,8 @@ CsrApiRequestThread(IN PVOID Parameter)
|
|||
ASSERT(NT_SUCCESS(Status));
|
||||
|
||||
/* Increase the Thread Counts */
|
||||
_InterlockedIncrement(&CsrpStaticThreadCount);
|
||||
_InterlockedIncrement(&CsrpDynamicThreadTotal);
|
||||
InterlockedIncrementUL(&CsrpStaticThreadCount);
|
||||
InterlockedIncrementUL(&CsrpDynamicThreadTotal);
|
||||
}
|
||||
|
||||
/* Now start the loop */
|
||||
|
@ -513,7 +513,7 @@ CsrApiRequestThread(IN PVOID Parameter)
|
|||
}
|
||||
|
||||
/* Increase the thread count */
|
||||
_InterlockedIncrement(&CsrpStaticThreadCount);
|
||||
InterlockedIncrementUL(&CsrpStaticThreadCount);
|
||||
|
||||
/* If the response was 0xFFFFFFFF, we'll ignore it */
|
||||
if (HardErrorMsg->Response == 0xFFFFFFFF)
|
||||
|
@ -595,7 +595,7 @@ CsrApiRequestThread(IN PVOID Parameter)
|
|||
ServerDll->DispatchTable[ApiId](&ReceiveMsg, &ReplyCode);
|
||||
|
||||
/* Increase the static thread count */
|
||||
_InterlockedIncrement(&CsrpStaticThreadCount);
|
||||
InterlockedIncrementUL(&CsrpStaticThreadCount);
|
||||
}
|
||||
_SEH2_EXCEPT(CsrUnhandledExceptionFilter(_SEH2_GetExceptionInformation()))
|
||||
{
|
||||
|
@ -706,7 +706,7 @@ CsrApiRequestThread(IN PVOID Parameter)
|
|||
}
|
||||
|
||||
/* Increase the thread count */
|
||||
_InterlockedIncrement(&CsrpStaticThreadCount);
|
||||
InterlockedIncrementUL(&CsrpStaticThreadCount);
|
||||
|
||||
/* If the response was 0xFFFFFFFF, we'll ignore it */
|
||||
if (HardErrorMsg->Response == 0xFFFFFFFF)
|
||||
|
@ -818,7 +818,7 @@ CsrApiRequestThread(IN PVOID Parameter)
|
|||
ReplyMsg->Status = ServerDll->DispatchTable[ApiId](&ReceiveMsg, &ReplyCode);
|
||||
|
||||
/* Increase the static thread count */
|
||||
_InterlockedIncrement(&CsrpStaticThreadCount);
|
||||
InterlockedIncrementUL(&CsrpStaticThreadCount);
|
||||
|
||||
Teb->CsrClientThread = CurrentThread;
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ extern HANDLE hBootstrapOk;
|
|||
extern HANDLE CsrApiPort;
|
||||
extern HANDLE CsrSmApiPort;
|
||||
extern HANDLE CsrSbApiPort;
|
||||
extern LIST_ENTRY CsrThreadHashTable[256];
|
||||
extern LIST_ENTRY CsrThreadHashTable[257];
|
||||
extern PCSR_PROCESS CsrRootProcess;
|
||||
extern UNICODE_STRING CsrDirectoryName;
|
||||
extern ULONG CsrDebug;
|
||||
|
|
|
@ -55,6 +55,8 @@
|
|||
|
||||
#define ROUND_UP(n, align) ROUND_DOWN(((ULONG)n) + (align) - 1, (align))
|
||||
#define ROUND_DOWN(n, align) (((ULONG)n) & ~((align) - 1l))
|
||||
#define InterlockedIncrementUL(Value) _InterlockedIncrement((PLONG)Value)
|
||||
#define InterlockedDecrementUL(Value) _InterlockedDecrement((PLONG)Value)
|
||||
|
||||
#endif // _SRV_H
|
||||
|
||||
|
|
|
@ -14,11 +14,11 @@
|
|||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
#define CsrHashThread(t) (HandleToUlong(t)&(256 - 1))
|
||||
#define CsrHashThread(t) (HandleToUlong(t) % 257)
|
||||
|
||||
/* GLOBALS ********************************************************************/
|
||||
|
||||
LIST_ENTRY CsrThreadHashTable[256];
|
||||
LIST_ENTRY CsrThreadHashTable[257];
|
||||
|
||||
|
||||
/* PRIVATE FUNCTIONS **********************************************************/
|
||||
|
@ -581,7 +581,7 @@ CsrCreateRemoteThread(IN HANDLE hThread,
|
|||
DPRINT1("No known process for %lx\n", ClientId->UniqueProcess);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/* Make sure the thread didn't terminate */
|
||||
if (KernelTimes.ExitTime.QuadPart)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue