projects
/
pintos-anon
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Move problem 1-2 (join) into project 2 as the "wait" system call.
[pintos-anon]
/
grading
/
vm
/
page-merge-par.c
diff --git
a/grading/vm/page-merge-par.c
b/grading/vm/page-merge-par.c
index dd24576b5dc34c6e9579956e141432f3adfe4537..36f7840bdf68b88053726690548e2e08fcaa344f 100644
(file)
--- a/
grading/vm/page-merge-par.c
+++ b/
grading/vm/page-merge-par.c
@@
-5,9
+5,12
@@
#else
#include "posix-compat.h"
#endif
#else
#include "posix-compat.h"
#endif
-#include "arc4.h"
+#include "
../lib/
arc4.h"
-#define CHUNK_SIZE (63 * 1024) /* Max file size. */
+/* This is the max file size for an older version of the Pintos
+ file system that had 126 direct blocks each pointing to a
+ single disk sector. We could raise it now. */
+#define CHUNK_SIZE (126 * 512)
#define CHUNK_CNT 8 /* Number of chunks. */
#define DATA_SIZE (CHUNK_CNT * CHUNK_SIZE) /* Buffer size. */
#define CHUNK_CNT 8 /* Number of chunks. */
#define DATA_SIZE (CHUNK_CNT * CHUNK_SIZE) /* Buffer size. */
@@
-32,7
+35,7
@@
init (void)
/* Sort each chunk of buf1 using a subprocess. */
static void
/* Sort each chunk of buf1 using a subprocess. */
static void
-sort (void)
+sort
_chunks
(void)
{
pid_t children[CHUNK_CNT];
size_t i;
{
pid_t children[CHUNK_CNT];
size_t i;
@@
-46,7
+49,7
@@
sort (void)
printf ("(page-merge-par) sort chunk %zu\n", i);
/* Write this chunk to a file. */
printf ("(page-merge-par) sort chunk %zu\n", i);
/* Write this chunk to a file. */
- snprintf (fn, sizeof fn, "buf%
d
", i);
+ snprintf (fn, sizeof fn, "buf%
zu
", i);
create (fn, CHUNK_SIZE);
fd = open (fn);
if (fd < 0)
create (fn, CHUNK_SIZE);
fd = open (fn);
if (fd < 0)
@@
-72,14
+75,14
@@
sort (void)
char fn[128];
int fd;
char fn[128];
int fd;
- if (
join
(children[i]) != 123)
+ if (
wait
(children[i]) != 123)
{
{
- printf ("(page-merge-par)
join
(exec()) returned bad value\n");
+ printf ("(page-merge-par)
wait
(exec()) returned bad value\n");
exit (1);
}
/* Read chunk back from file. */
exit (1);
}
/* Read chunk back from file. */
- snprintf (fn, sizeof fn, "buf%
d
", i);
+ snprintf (fn, sizeof fn, "buf%
zu
", i);
fd = open (fn);
if (fd < 0)
{
fd = open (fn);
if (fd < 0)
{
@@
-159,7
+162,7
@@
main (void)
{
printf ("(page-merge-par) begin\n");
init ();
{
printf ("(page-merge-par) begin\n");
init ();
- sort ();
+ sort
_chunks
();
merge ();
verify ();
printf ("(page-merge-par) end\n");
merge ();
verify ();
printf ("(page-merge-par) end\n");