FreeRDP
|
#include <stdio.h>
#include <winpr/crt.h>
#include <winpr/crypto.h>
#include <winpr/windows.h>
#include <winpr/synch.h>
#include <winpr/sysinfo.h>
#include <winpr/thread.h>
#include <winpr/interlocked.h>
Macros | |
#define | TEST_SYNC_CRITICAL_TEST1_RUNTIME_MS 50 |
#define | TEST_SYNC_CRITICAL_TEST1_RUNS 4 |
Functions | |
static BOOL | TestSynchCritical_TriggerAndCheckRaceCondition (HANDLE OwningThread, LONG RecursionCount) |
static UINT32 | prand (UINT32 max) |
static DWORD WINAPI | TestSynchCritical_Test1 (LPVOID arg) |
static DWORD WINAPI | TestSynchCritical_Test2 (LPVOID arg) |
static DWORD WINAPI | TestSynchCritical_Main (LPVOID arg) |
int | TestSynchCritical (int argc, char *argv[]) |
Variables | |
static CRITICAL_SECTION | critical |
static LONG | gTestValueVulnerable = 0 |
static LONG | gTestValueSerialized = 0 |
#define TEST_SYNC_CRITICAL_TEST1_RUNS 4 |
#define TEST_SYNC_CRITICAL_TEST1_RUNTIME_MS 50 |
|
static |
int TestSynchCritical | ( | int | argc, |
char * | argv[] | ||
) |
We have to be able to detect dead locks in this test. At the time of writing winpr's WaitForSingleObject has not implemented timeout for thread wait
Workaround checking the value of bThreadTerminated which is passed in the thread arg
|
static |
Test SpinCount in SetCriticalSectionSpinCount, InitializeCriticalSectionEx and InitializeCriticalSectionAndSpinCount SpinCount must be forced to be zero on on uniprocessor systems and on systems where WINPR_CRITICAL_SECTION_DISABLE_SPINCOUNT is defined
Test single-threaded recursive TryEnterCriticalSection/EnterCriticalSection/LeaveCriticalSection
Test using multiple threads modifying the same value
TryEnterCriticalSection in thread must fail if we hold the lock in the main thread
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |