Current Path : /usr/src/tools/regression/tls/ttls2/ |
FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64 |
Current File : //usr/src/tools/regression/tls/ttls2/ttls2.c |
/* $FreeBSD: release/9.1.0/tools/regression/tls/ttls2/ttls2.c 133066 2004-08-03 09:04:01Z dfr $ */ #include <stdio.h> #include <pthread.h> int __thread i; void * foo1(void *arg) { printf("thread %p, &i = %p\n", pthread_self(), &i); for (i = 0; i < 10; i++) { printf("thread %p, i = %d\n", pthread_self(), i); sleep(1); } } void * foo2(void *arg) { printf("thread %p, &i = %p\n", pthread_self(), &i); for (i = 10; i > 0; i--) { printf("thread %p, i = %d\n", pthread_self(), i); sleep(1); } } int main(int argc, char** argv) { pthread_t t1, t2; pthread_create(&t1, 0, foo1, 0); pthread_create(&t2, 0, foo2, 0); pthread_join(t1, 0); pthread_join(t2, 0); }