- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm totally confused. The codes below:
volatile LONG g_lock = 0;
DWORD g_value = 0;
VOID ThreadProc( VOID ){
while ( TRUE ){
if ( InterlockedCompareExchange(&g_lock,1,0) == 0){
if ( g_value != 0 ) //[Code 1]
g_value += 1; //[Code2]
_ASSERT( g_lock == 1 );
LONG dwBefore = InterlockedCompareExchange(&g_lock, 0 , 1);
_ASSERT( dwBefore == 1 );
}//endif
::Sleep(1)
}
}
The g_lock and g_value are two global variable, then I started 10 threads to call ThreadProc function and ran together.
when I used thread checker to launch the program , write-read race problem was gained around [Code1] and [Code2],
I'm begging some one could help me...
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm totally confused. The codes below:
volatile LONG g_lock = 0;
DWORD g_value = 0;
VOID ThreadProc( VOID ){
while ( TRUE ){
if ( InterlockedCompareExchange(&g_lock,1,0) == 0){
if ( g_value != 0 ) //[Code 1]
g_value += 1; //[Code2]
_ASSERT( g_lock == 1 );
LONG dwBefore = InterlockedCompareExchange(&g_lock, 0 , 1);
_ASSERT( dwBefore == 1 );
}//endif
::Sleep(1)
}
}
The g_lock and g_value are two global variable, then I started 10 threads to call ThreadProc function and ran together.
when I used thread checker to launch the program , write-read race problem was gained around [Code1] and [Code2],
I'm begging some one could help me...
Hi,
This "lock free" construction is a sort of user-level synchronization which is nottracked by Thread Checker. However, the Thread Checker includes the user-level synchronization API to help you gather information related to user-defined synchronization constructs. In order to make Thread Checker aware of the protected code region use _itt notifications:__itt_notify_sync_acquired and __itt_notify_sync_releasing.
You'd have to include libittnotify.h header and to link libittnotify.lib library to your project (The library is installed in
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
This "lock free" construction is a sort of user-level synchronization which is nottracked by Thread Checker. However, the Thread Checker includes the user-level synchronization API to help you gather information related to user-defined synchronization constructs. In order to make Thread Checker aware of the protected code region use _itt notifications:__itt_notify_sync_acquired and __itt_notify_sync_releasing.
You'd have to include libittnotify.h header and to link libittnotify.lib library to your project (The library is installed in
Thank u very much , It's greately helpful.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page