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 f146716 was
5013c62,
checked in by Thierry Delisle <tdelisle@…>, 7 years ago
|
added several benchmarks to measure creation, some work needs to be done on them
|
-
Property mode set to
100644
|
File size:
604 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("%lu\n", n); |
---|
17 | |
---|
18 | for (size_t i = 0; i < n; i++) { |
---|
19 | pthread_attr_t attr; |
---|
20 | if (pthread_attr_init(&attr) < 0) { |
---|
21 | return 1; |
---|
22 | } |
---|
23 | if (pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) < 0) { |
---|
24 | return 1; |
---|
25 | } |
---|
26 | pthread_t thread; |
---|
27 | if (pthread_create(&thread, &attr, foo, NULL) < 0) { |
---|
28 | return 1; |
---|
29 | } |
---|
30 | } |
---|
31 | pthread_exit(NULL); |
---|
32 | return 0; |
---|
33 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.