Skip to content

Instantly share code, notes, and snippets.

@toddlipcon
Created February 6, 2019 23:32
Show Gist options
  • Select an option

  • Save toddlipcon/c369e8683cee9306bf7bb6fd9c7ca442 to your computer and use it in GitHub Desktop.

Select an option

Save toddlipcon/c369e8683cee9306bf7bb6fd9c7ca442 to your computer and use it in GitHub Desktop.
#include <pthread.h>
#include <linux/futex.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <sys/time.h>
int main() {
#if 0
pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t cv = PTHREAD_COND_INITIALIZER;
pthread_mutex_lock(&m);
pthread_cond_wait(&cv, &m);
pthread_mutex_unlock(&m);
#else
int l = 0;
syscall(SYS_futex, &l, FUTEX_WAIT, 0, NULL);
#endif
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment