-
Notifications
You must be signed in to change notification settings - Fork 302
Open
Description
The answer to 12.16 is wrong because the homework states that creates and reaps n joinable peer threads
and the solution to this should be:
#include "csapp.h"
void *thread(void *vargp);
#define DEFAULT 4
int main(int argc, char* argv[]) {
int N;
if (argc > 2)
unix_error("too many param");
else if (argc == 2)
N = atoi(argv[1]);
else
N = DEFAULT;
int i;
pthread_t tid;
for (i = 0; i < N; i++) {
Pthread_create(&tid, NULL, thread, NULL);
}
for(i = 0; i < N; i++) {
Pthread_join(tid[i], NULL);
}
}
void *thread(void *vargp) {
printf("Hello, world\n");
return NULL;
}
CodeMan1729
Metadata
Metadata
Assignees
Labels
No labels