Skip to content

Commit

Permalink
Use monotonic clock in unix port of condvar
Browse files Browse the repository at this point in the history
  • Loading branch information
bjsowa committed Sep 15, 2024
1 parent 7049dcc commit 72d794f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/system/unix/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,12 @@ int8_t _z_mutex_try_lock(_z_mutex_t *m) { _Z_CHECK_SYS_ERR(pthread_mutex_trylock
int8_t _z_mutex_unlock(_z_mutex_t *m) { _Z_CHECK_SYS_ERR(pthread_mutex_unlock(m)); }

/*------------------ Condvar ------------------*/
int8_t _z_condvar_init(_z_condvar_t *cv) { _Z_CHECK_SYS_ERR(pthread_cond_init(cv, 0)); }
int8_t _z_condvar_init(_z_condvar_t *cv) {
pthread_condattr_t attr;
pthread_condattr_init(&attr);
pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);
_Z_CHECK_SYS_ERR(pthread_cond_init(cv, &attr));
}

int8_t _z_condvar_drop(_z_condvar_t *cv) { _Z_CHECK_SYS_ERR(pthread_cond_destroy(cv)); }

Expand Down

0 comments on commit 72d794f

Please sign in to comment.