ReactOS 0.4.15-dev-8219-ge8b88cf
threadSafeInit.c File Reference
#include <intrin.h>
Include dependency graph for threadSafeInit.c:

Go to the source code of this file.

Functions

int _stdcall SwitchToThread (void)
 
void _Init_thread_header (volatile int *ptss)
 
void _Init_thread_footer (volatile int *ptss)
 
void _Init_thread_abort (volatile int *ptss)
 

Variables

unsigned int _tls_array
 
unsigned int _tls_index
 
long _Init_global_epoch
 
long _Init_thread_epoch
 

Function Documentation

◆ _Init_thread_abort()

void _Init_thread_abort ( volatile int ptss)

Definition at line 56 of file threadSafeInit.c.

57{
58 /* Abort the initialization */
59 _InterlockedAnd((volatile long*)ptss, 0);
60}
volatile char *const const char modify _InterlockedAnd
Definition: intrin_ppc.h:267

◆ _Init_thread_footer()

void _Init_thread_footer ( volatile int ptss)

Definition at line 49 of file threadSafeInit.c.

50{
51 /* Initialization is complete */
53}
long __cdecl _InterlockedIncrement(_Interlocked_operand_ long volatile *_Addend)
long _Init_global_epoch

◆ _Init_thread_header()

void _Init_thread_header ( volatile int ptss)

Definition at line 29 of file threadSafeInit.c.

30{
31 while (1)
32 {
33 /* Try to acquire the first initialization lock */
34 int oldTss = _InterlockedCompareExchange((long*)ptss, -1, 0);
35 if (oldTss == -1)
36 {
37 /* Busy, wait for the other thread to do the initialization */
39 continue;
40 }
41
42 /* Either we acquired the lock and the caller will do the initializaion
43 or the initialization is complete and the caller will skip it */
44 break;
45 }
46}
long __cdecl _InterlockedCompareExchange(_Interlocked_operand_ long volatile *_Destination, long _Exchange, long _Comparand)
int _stdcall SwitchToThread(void)
Definition: thread.c:448

◆ SwitchToThread()

int _stdcall SwitchToThread ( void  )

Definition at line 448 of file thread.c.

449{
451}
NTSYSAPI NTSTATUS WINAPI NtYieldExecution(void)
Definition: thrdschd.c:744
#define STATUS_NO_YIELD_PERFORMED
Definition: ntstatus.h:150

Referenced by _Init_thread_header().

Variable Documentation

◆ _Init_global_epoch

long _Init_global_epoch

Definition at line 14 of file threadSafeInit.c.

Referenced by _Init_thread_footer().

◆ _Init_thread_epoch

long _Init_thread_epoch

Definition at line 15 of file threadSafeInit.c.

◆ _tls_array

unsigned int _tls_array

Definition at line 12 of file threadSafeInit.c.

◆ _tls_index

unsigned int _tls_index

Definition at line 13 of file threadSafeInit.c.