On 2020-04-07 10:22:03 [+0000], Andreas Hoefler wrote: > The first attempt of a solution was to use a different clock > (CLOCK_MONOTONIC), which works fine when using conditional attributes > (pthread_condattr_setclock in combination with pthread_cond_init) but > unfortunately there does not seem to be a corresponding > pthread_mutex_setclock(MISSING) for pthread_mutex_init. > > Is there an good alternative for pthread or can the pthread library > somehow be utilized for this purpose? >From glibc 2.30 announcement [0]: |* Add new POSIX-proposed pthread_cond_clockwait, pthread_mutex_clocklock, | pthread_rwlock_clockrdlock, pthread_rwlock_clockwrlock and sem_clockwait | functions. These behave similarly to their "timed" equivalents, but also | accept a clockid_t parameter to determine which clock their timeout should | be measured against. All functions allow waiting against CLOCK_MONOTONIC | and CLOCK_REALTIME. The decision of which clock to be used is made at the | time of the wait (unlike with pthread_condattr_setclock, which requires | the clock choice at initialization time). You are looking for pthread_mutex_clocklock(). [0] https://sourceware.org/legacy-ml/libc-announce/2019/msg00001.html > Thanx > Andy Sebastian