Changes in src/benchmark/create_pthrd.c [5013c62:eb2fe4f]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/benchmark/create_pthrd.c
r5013c62 reb2fe4f 14 14 n = atoi(argv[1]); 15 15 } 16 printf(" %lu\n", n);16 printf("create %lu pthreads ... ", n); 17 17 18 18 for (size_t i = 0; i < n; i++) { 19 pthread_attr_t attr; 20 if (pthread_attr_init(&attr) < 0) { 19 pthread_t thread; 20 if (pthread_create(&thread, NULL, foo, NULL) < 0) { 21 perror( "failure" ); 21 22 return 1; 22 23 } 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) { 24 25 if (pthread_join( thread, NULL) < 0) { 26 perror( "failure" ); 28 27 return 1; 29 28 } 30 29 } 31 pthread_exit(NULL); 32 return 0; 30 printf("finish\n"); 33 31 }
Note:
See TracChangeset
for help on using the changeset viewer.