Current Path : /usr/src/tools/regression/tls/ttls4/ |
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/ttls4/ttls4.c |
/* * This program tests if a new thread's initial tls data * is clean. * * David Xu <davidxu@freebsd.org> * * $FreeBSD: release/9.1.0/tools/regression/tls/ttls4/ttls4.c 145468 2005-04-24 00:17:30Z davidxu $ */ #include <stdio.h> #include <pthread.h> #include <unistd.h> int __thread n; void *f1(void *arg) { if (n != 0) { printf("bug, n == %d \n", n); exit(1); } n = 1; return (0); } int main() { pthread_t td; int i; for (i = 0; i < 1000; ++i) { pthread_create(&td, NULL, f1, NULL); pthread_join(td, NULL); } sleep(2); for (i = 0; i < 1000; ++i) { pthread_create(&td, NULL, f1, NULL); pthread_join(td, NULL); } return (0); }