I’m wondering if it is possible to implement the following logical under Linux and using POSIX thread library.
given a mutex
if (I can get the mutex) {
lock the mutex
call fun A
unlcok the mutex
}
else {
call fun B
}
I’m new to thread programming under Linux, so just use the pseudo-code to show the logic of the code snippet I’m looking for.
You’re looking for pthread_mutex_trylock