Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.
2421 Discussions

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

softarts
Beginner
123 Views
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
123 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