Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The symbol is mentionned there: </p> <p><a href="http://elias.rhi.hi.is/libc/Mutexes.html" rel="noreferrer">http://elias.rhi.hi.is/libc/Mutexes.html</a></p> <p>"LinuxThreads supports only one mutex attribute: the mutex type, which is either PTHREAD_MUTEX_ADAPTIVE_NP for "fast" mutexes, PTHREAD_MUTEX_RECURSIVE_NP for "recursive" mutexes, PTHREAD_MUTEX_TIMED_NP for "timed" mutexes, or PTHREAD_MUTEX_ERRORCHECK_NP for "error checking" mutexes. As the NP suffix indicates, this is a non-portable extension to the POSIX standard and should not be employed in portable programs.</p> <p>The mutex type determines what happens if a thread attempts to lock a mutex it already owns with pthread_mutex_lock. If the mutex is of the "fast" type, pthread_mutex_lock simply suspends the calling thread forever. If the mutex is of the "error checking" type, pthread_mutex_lock returns immediately with the error code EDEADLK. If the mutex is of the "recursive" type, the call to pthread_mutex_lock returns immediately with a success return code. The number of times the thread owning the mutex has locked it is recorded in the mutex. The owning thread must call pthread_mutex_unlock the same number of times before the mutex returns to the unlocked state.</p> <p>The default mutex type is "timed", that is, PTHREAD_MUTEX_TIMED_NP."</p> <p>EDIT: updated with info found by jthill (thanks!)</p> <p>A little more info on the mutex flags and the PTHREAD_MUTEX_ADAPTIVE_NP can be found <a href="http://lkml.indiana.edu/hypermail/linux/kernel/0103.1/0030.html" rel="noreferrer">here</a>:</p> <p>"The PTHRED_MUTEX_ADAPTIVE_NP is a new mutex that is intended for high throughput at the sacrifice of fairness and even CPU cycles. This mutex does not transfer ownership to a waiting thread, but rather allows for competition. Also, over an SMP kernel, the lock operation uses spinning to retry the lock to avoid the cost of immediate descheduling."</p> <p>Which basically suggest the following: in case where high thoughput is desirable, such mutex can be implemented requiring extra considerations from the thread logic due to it's very nature. You will have to design an algorithm that can use these properties resulting in high throughput. Something that load balances itself from within (as opposed to "from the kernel") where order of execution is unimportant. </p> <p>There was a very good book for linux/unix multithreading programming which name escapes me. If I find it I'll update.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload