FreeRDP
TestSynchCritical.c File Reference
#include <stdio.h>
#include <winpr/crt.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 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
 

Macro Definition Documentation

◆ TEST_SYNC_CRITICAL_TEST1_RUNS

#define TEST_SYNC_CRITICAL_TEST1_RUNS   4

◆ TEST_SYNC_CRITICAL_TEST1_RUNTIME_MS

#define TEST_SYNC_CRITICAL_TEST1_RUNTIME_MS   50

Function Documentation

◆ TestSynchCritical()

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

Here is the call graph for this function:

◆ TestSynchCritical_Main()

static DWORD WINAPI TestSynchCritical_Main ( LPVOID  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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TestSynchCritical_Test1()

static DWORD WINAPI TestSynchCritical_Test1 ( LPVOID  arg)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TestSynchCritical_Test2()

static DWORD WINAPI TestSynchCritical_Test2 ( LPVOID  arg)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TestSynchCritical_TriggerAndCheckRaceCondition()

static BOOL TestSynchCritical_TriggerAndCheckRaceCondition ( HANDLE  OwningThread,
LONG  RecursionCount 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ critical

CRITICAL_SECTION critical
static

◆ gTestValueSerialized

LONG gTestValueSerialized = 0
static

◆ gTestValueVulnerable

LONG gTestValueVulnerable = 0
static