Skip to content

Commit

Permalink
fixed smuos#4 fixed smuos#5 fixed smuos#6 fixed smuos#7
Browse files Browse the repository at this point in the history
  • Loading branch information
mskmatt committed Sep 30, 2014
1 parent b158647 commit 3c5c149
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions mm.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,19 @@ int main(int argc, char *argv[]) {
for (i=0; i<length; i++) {
fprintf(stdout, "%d ", pt[i]);
}
fprintf(stdout, "\nMean: %.2f\n", mean(length, pt));
fprintf(stdout, "Median: %.2f\n", median(length, pt));
fprintf(stdout, "\n%s: FIN. \n", argv[0]);
int rc = fork();
if (rc == -1) {
fprintf(stdout, "Could not create another process.\n");
exit(0);
}
else if (rc == 0) {
fprintf(stdout, "\nMedian: %.2f", median(length, pt));
}
else if (rc > 0) {
int wc = wait(NULL); //is child finished?
fprintf(stdout, "\nMean: %.2f", mean(length, pt));
}
fprintf(stdout, "\n%s: FIN. (pid:%d)\n", argv[0], getpid());

return 0;
}

0 comments on commit 3c5c149

Please sign in to comment.