Created
February 6, 2019 23:32
-
-
Save toddlipcon/c369e8683cee9306bf7bb6fd9c7ca442 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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