ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change
on this file since 9cc0472 was
eb2fe4f,
checked in by Thierry Delisle <tdelisle@…>, 7 years ago
|
Some cleanu[ of the benchmark for pthread create
|
-
Property mode set to
100644
|
File size:
550 bytes
|
Line | |
---|
1 | #include <pthread.h> |
---|
2 | #include <err.h> |
---|
3 | #include <stdlib.h> |
---|
4 | #include <stdio.h> |
---|
5 | |
---|
6 | static void *foo(void *arg) { |
---|
7 | return arg; |
---|
8 | } |
---|
9 | |
---|
10 | int main(int argc, char* argv[]) { |
---|
11 | size_t n = 1000000; |
---|
12 | if( argc > 2 ) return 1; |
---|
13 | if( argc == 2 ) { |
---|
14 | n = atoi(argv[1]); |
---|
15 | } |
---|
16 | printf("create %lu pthreads ... ", n); |
---|
17 | |
---|
18 | for (size_t i = 0; i < n; i++) { |
---|
19 | pthread_t thread; |
---|
20 | if (pthread_create(&thread, NULL, foo, NULL) < 0) { |
---|
21 | perror( "failure" ); |
---|
22 | return 1; |
---|
23 | } |
---|
24 | |
---|
25 | if (pthread_join( thread, NULL) < 0) { |
---|
26 | perror( "failure" ); |
---|
27 | return 1; |
---|
28 | } |
---|
29 | } |
---|
30 | printf("finish\n"); |
---|
31 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.