Created
March 2, 2018 04:39
-
-
Save dimalinux/72f714ced08c634f3b6b90b05ff1fe03 to your computer and use it in GitHub Desktop.
Revisions
-
dimalinux created this gist
Mar 2, 2018 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ #include <stdio.h> #include <stdint.h> #include <time.h> #include <unistd.h> #include <sys/syscall.h> #include <linux/futex.h> int futex_sleep (time_t seconds, long nanoseconds) { uint32_t futexWord = 0; struct timespec timeout = { seconds, nanoseconds }; return syscall (SYS_futex, &futexWord, FUTEX_WAIT, futexWord, &timeout, NULL, 0); } int main () { time_t secs = 2; printf ("Before futex_sleep for %ld seconds\n", secs); futex_sleep (2, 0); printf ("After futex_sleep\n"); return 0; }