Get rid of unnecessary barrier. Improve comment.
[pintos-anon] / grading / filesys / syn-read.c
index cdc7f189b56dd3e91390b91c2c9d4ab40cd8b54c..57fd4cfcac8c6f67a0e892a291cd8f1953618441 100644 (file)
@@ -15,26 +15,14 @@ test_main (void)
 {
   pid_t children[CHILD_CNT];
   int fd;
-  int i;
 
-  check (create (filename, sizeof buf), "create \"%s\"", filename);
-  check ((fd = open (filename)) > 1, "open \"%s\"", filename);
+  CHECK (create (filename, sizeof buf), "create \"%s\"", filename);
+  CHECK ((fd = open (filename)) > 1, "open \"%s\"", filename);
   random_bytes (buf, sizeof buf);
-  check (write (fd, buf, sizeof buf) > 0, "write \"%s\"", filename);
+  CHECK (write (fd, buf, sizeof buf) > 0, "write \"%s\"", filename);
   msg ("close \"%s\"", filename);
   close (fd);
 
-  for (i = 0; i < CHILD_CNT; i++) 
-    {
-      char cmd_line[128];
-      snprintf (cmd_line, sizeof cmd_line, "child-syn-read %d", i);
-      check ((children[i] = exec (cmd_line)) != PID_ERROR,
-             "exec child %d of %d: \"%s\"", i + 1, (int) CHILD_CNT, cmd_line);
-    }
-
-  for (i = 0; i < CHILD_CNT; i++) 
-    {
-      int status = join (children[i]);
-      check (status == i, "join child %d of %d", i + 1, (int) CHILD_CNT);
-    }
+  exec_children ("child-syn-read", children, CHILD_CNT);
+  wait_children (children, CHILD_CNT);
 }