Community
cancel
Showing results for 
Search instead for 
Did you mean: 
softarts
Beginner
51 Views

look for a fast lock(free) method in 2 threads

looking for a sync method between 2 methods,does this code work?
I am afraid they have some problems :posted here:
http://software.intel.com/en-us/forums/showthread.php?t=76999&o=d&s=lr

void deActivateFD() //thread 1

{

uint32_t flg = (uint32_t) atomic_read( &fdActive );

if(flg == 0)

return;

if( emptySock() ) //read all buf from sock

atomic_set(&fdActive,0);

}

void activateFD() //thread2

{

uint32_t flg = (uint32_t) atomic_read( &fdActive );

if(flg == 1)

return;

bool tmpFdActive = fillSock()//write something to socket

if(tmpFdActive)

atomic_set(&fdActive,1);

}

2.
any one know peterson lock or lamport barkey lock? they are fit for this situation?

3. any fast sync method in TBB (for only 2 threads)? can be faster than spin_mutex,etc?
0 Kudos
1 Reply
Dmitry_Vyukov
Valued Contributor I
51 Views

Quoting softarts
looking for a sync method between 2 methods,does this code work?

It definitely works. However we can't answer as to whether it works the way you want or not, because we don't know what you want to achieve.

Reply