]>
git.saurik.com Git - apple/xnu.git/blob - tools/tests/execperf/run.c
10 extern char **environ
;
12 char * const *newargv
;
19 main(int argc
, char *argv
[])
21 int i
, count
, threadcount
;
29 threadcount
= atoi(argv
[1]);
30 count
= atoi(argv
[2]);
34 threads
= (pthread_t
*)calloc(threadcount
, sizeof(pthread_t
));
35 for (i
= 0; i
< threadcount
; i
++) {
36 ret
= pthread_create(&threads
[i
], NULL
, work
, (void *)(intptr_t)count
);
38 err(1, "pthread_create");
42 for (i
= 0; i
< threadcount
; i
++) {
43 ret
= pthread_join(threads
[i
], NULL
);
45 err(1, "pthread_join");
55 fprintf(stderr
, "Usage: %s <threadcount> <count> <program> [<arg1> [<arg2> ...]]\n",
63 int count
= (int)(intptr_t)arg
;
68 for (i
= 0; i
< count
; i
++) {
69 ret
= posix_spawn(&pid
, newargv
[0], NULL
, NULL
, newargv
, environ
);
71 errc(1, ret
, "posix_spawn(%s)", newargv
[0]);
74 while (-1 == waitpid(pid
, &ret
, 0)) {
76 err(1, "waitpid(%d)", pid
);
80 if (WIFSIGNALED(ret
)) {
81 errx(1, "process exited with signal %d", WTERMSIG(ret
));
82 } else if (WIFSTOPPED(ret
)) {
83 errx(1, "process stopped with signal %d", WSTOPSIG(ret
));
84 } else if (WIFEXITED(ret
)) {
85 if (WEXITSTATUS(ret
) != 42) {
86 errx(1, "process exited with unexpected exit code %d", WEXITSTATUS(ret
));
89 errx(1, "unknown exit condition %x", ret
);