use c11 thread emulate library on Mesa 3D Graphics Library
my local gcc 4.9.2 is not support to "threads.h" yet.
$ make gcc -Wall -std=c11 main.c -pthread main.c:2:21: fatal error: threads.h: No such file or directory #include <threads.h> ^ compilation terminated. Makefile:5: recipe for target 'test' failed make: *** [test] Error 1 $ gcc --version gcc (Debian 4.9.2-10) 4.9.2 Copyright (C) 2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
but Mesa 3D included emulate thread library. and tried it.
source code to github
misc-lang-snippet/c/c11threads at master · murasesyuka/misc-lang-snippet · GitHub
run result
$ ./a.out thrd_current()vim is 139907333428992 thrd_current()vim is 139907341821696 0 : 0 1 : 2 2 : 1 3 : 0 4 : 2 5 : 1 thrd_current()vim is 139907358607104 6 : 2 7 : 1 8 : 0 thrd_current()vim is 139907350214400 9 : 2 10 : 1 11 : 0