X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Ftests%2Ffilesys%2Fextended%2Fchild-syn-rw.c;h=0e2217df58da7e4272ffd9ce40a0926d099213d1;hb=59f738d500f51ffc5f487344865b8bed69c26281;hp=6334bda0b1077d97707df098c44a9f30b87d277c;hpb=615bf3b3d2a8573ed6fb9ddc0055745e163ac999;p=pintos-anon diff --git a/src/tests/filesys/extended/child-syn-rw.c b/src/tests/filesys/extended/child-syn-rw.c index 6334bda..0e2217d 100644 --- a/src/tests/filesys/extended/child-syn-rw.c +++ b/src/tests/filesys/extended/child-syn-rw.c @@ -1,3 +1,12 @@ +/* Child process for syn-rw. + Reads from a file created by our parent process, which is + growing it. We loop until we've read the whole file + successfully. Many iterations through the loop will return 0 + bytes, because the file has not grown in the meantime. That + is, we are "busy waiting" for the file to grow. + (This test could be improved by adding a "yield" system call + and calling yield whenever we receive a 0-byte read.) */ + #include #include #include @@ -24,17 +33,17 @@ main (int argc, const char *argv[]) random_init (0); random_bytes (buf1, sizeof buf1); - CHECK ((fd = open (filename)) > 1, "open \"%s\"", filename); + CHECK ((fd = open (file_name)) > 1, "open \"%s\"", file_name); ofs = 0; while (ofs < sizeof buf2) { int bytes_read = read (fd, buf2 + ofs, sizeof buf2 - ofs); CHECK (bytes_read >= -1 && bytes_read <= (int) (sizeof buf2 - ofs), "%zu-byte read on \"%s\" returned invalid value of %d", - sizeof buf2 - ofs, filename, bytes_read); + sizeof buf2 - ofs, file_name, bytes_read); if (bytes_read > 0) { - compare_bytes (buf2 + ofs, buf1 + ofs, bytes_read, ofs, filename); + compare_bytes (buf2 + ofs, buf1 + ofs, bytes_read, ofs, file_name); ofs += bytes_read; } }