1 #define _XOPEN_SOURCE 700
9 void *emptyfunc(void *dummy) {
13 void bench_pthread_createjoin_serial1(int N) {
19 pthread_create(&td, 0, emptyfunc, 0);
20 pthread_join(td, &dummy);
24 void bench_pthread_createjoin_serial2(int N) {
29 for (j=0; j<N/(sizeof td/sizeof *td); j++) {
30 for (i=0; i<sizeof td/sizeof *td; i++)
31 pthread_create(td+i, 0, emptyfunc, 0);
32 for (i=0; i<sizeof td/sizeof *td; i++)
33 pthread_join(td[i], &dummy);
37 void bench_pthread_create_serial1(int N) {
43 pthread_attr_init(&attr);
44 pthread_attr_setstacksize(&attr, 16384);
45 for (j=0; j<N/(sizeof td/sizeof *td); j++) {
46 for (i=0; i<sizeof td/sizeof *td; i++)
47 pthread_create(td+i, &attr, emptyfunc, 0);
49 for (i=0; i<sizeof td/sizeof *td; i++)
50 pthread_join(td[i], &dummy);
56 void *lockunlock(void *mut)
59 for (i=0; i<lockN; i++) {
60 pthread_mutex_lock(mut);
61 pthread_mutex_unlock(mut);
66 void bench_pthread_uselesslock(int N) {
68 pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
72 pthread_create(&td, 0, lockunlock, &mut);
73 pthread_join(td, &dummy);
76 void bench_pthread_createjoin_min1(int N) {
82 pthread_attr_init(&a);
83 pthread_attr_setstacksize(&a, sysconf(_SC_PAGESIZE));
84 pthread_attr_setguardsize(&a, 0);
86 pthread_create(&td, &a, emptyfunc, 0);
87 pthread_join(td, &dummy);
91 void bench_pthread_createjoin_min2(int N) {
97 pthread_attr_init(&a);
98 pthread_attr_setstacksize(&a, sysconf(_SC_PAGESIZE));
99 pthread_attr_setguardsize(&a, 0);
100 for (j=0; j<N/(sizeof td/sizeof *td); j++) {
101 for (i=0; i<sizeof td/sizeof *td; i++)
102 pthread_create(td+i, &a, emptyfunc, 0);
103 for (i=0; i<sizeof td/sizeof *td; i++)
104 pthread_join(td[i], &dummy);