projects
/
pintos-anon
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Talk about write() to stdout more.
[pintos-anon]
/
grading
/
vm
/
page-merge-seq.c
diff --git
a/grading/vm/page-merge-seq.c
b/grading/vm/page-merge-seq.c
index 3abe9e26726a0f189bd8022f19a85cea541abff5..203ca9cd25ac42b6ad34da57c3983eaf3c851365 100644
(file)
--- a/
grading/vm/page-merge-seq.c
+++ b/
grading/vm/page-merge-seq.c
@@
-3,12
+3,14
@@
#ifdef PINTOS
#include <syscall.h>
#else
#ifdef PINTOS
#include <syscall.h>
#else
-#include <unistd.h>
-#include <fcntl.h>
+#include "posix-compat.h"
#endif
#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 16 /* Number of chunks. */
#define DATA_SIZE (CHUNK_CNT * CHUNK_SIZE) /* Buffer size. */
#define CHUNK_CNT 16 /* Number of chunks. */
#define DATA_SIZE (CHUNK_CNT * CHUNK_SIZE) /* Buffer size. */
@@
-37,9
+39,7
@@
sort (void)
{
size_t i;
{
size_t i;
-#ifdef PINTOS
create ("buffer", CHUNK_SIZE);
create ("buffer", CHUNK_SIZE);
-#endif
for (i = 0; i < CHUNK_CNT; i++)
{
int fd;
for (i = 0; i < CHUNK_CNT; i++)
{
int fd;
@@
-47,11
+47,8
@@
sort (void)
printf ("(page-merge-seq) sort chunk %zu\n", i);
/* Write this chunk to a file. */
printf ("(page-merge-seq) sort chunk %zu\n", i);
/* Write this chunk to a file. */
-#ifdef PINTOS
fd = open ("buffer");
fd = open ("buffer");
-#else
- fd = open ("buffer", O_WRONLY | O_CREAT, 0660);
-#endif
+
if (fd < 0)
{
printf ("(page-merge-seq) open() failed\n");
if (fd < 0)
{
printf ("(page-merge-seq) open() failed\n");
@@
-61,28
+58,20
@@
sort (void)
close (fd);
/* Sort with subprocess. */
close (fd);
/* Sort with subprocess. */
-#ifdef PINTOS
- pid_t child = exec ("child-sort");
+ pid_t child = exec ("child-sort buffer");
if (child == -1)
{
printf ("(page-merge-seq) exec() failed\n");
exit (1);
}
if (child == -1)
{
printf ("(page-merge-seq) exec() failed\n");
exit (1);
}
- if (join (child) !=
0x
123)
+ if (join (child) != 123)
{
printf ("(page-merge-seq) join(exec()) returned bad value\n");
exit (1);
}
{
printf ("(page-merge-seq) join(exec()) returned bad value\n");
exit (1);
}
-#else
- system ("./child-sort");
-#endif
/* Read chunk back from file. */
/* Read chunk back from file. */
-#ifdef PINTOS
fd = open ("buffer");
fd = open ("buffer");
-#else
- fd = open ("buffer", O_RDONLY);
-#endif
if (fd < 0)
{
printf ("(page-merge-seq) open() failed\n");
if (fd < 0)
{
printf ("(page-merge-seq) open() failed\n");