mmap_exit_SRC = mmap-exit.c
mmap_shuffle_SRC = mmap-shuffle.c arc4.c cksum.c
-PROGS = $(TESTS) child-linear child-sort
+PROGS = $(TESTS) child-linear child-sort child-mm-wrt
child_linear_SRC = child-linear.c arc4.c
child_sort_SRC = child-sort.c
-
+child_mm_wrt_SRC = child-mm-wrt.c
disks: $(DISKS)
-mmap-close.dsk mmap-exit.dsk mmap-read.dsk mmap-unmap.dsk: sample.txt
+mmap-close.dsk mmap-read.dsk mmap-unmap.dsk mmap-twice.dsk: sample.txt
+page-parallel.dsk: child-linear
+page-merge-seq.dsk page-merge-par.dsk: child-sort
mmap-overlap.dsk: zeros
+mmap-exit.dsk: child-mm-wrt
zeros:
dd if=/dev/zero of=$@ bs=1024 count=6
+#include <stdio.h>
+#include <string.h>
+#ifdef PINTOS
+#include <syscall.h>
+#else
+#include "posix-compat.h"
+#endif
+#include "sample.inc"
+
#define ACTUAL ((void *) 0x10000000)
int
{
int fd;
- printf ("(mmap-write) begin\n");
+ printf ("(child-mm-wrt) begin\n");
/* Write file via mmap. */
if (!create ("sample.txt", strlen (sample)))
{
- printf ("(mmap-write) create() failed\n");
+ printf ("(child-mm-wrt) create() failed\n");
return 1;
}
fd = open ("sample.txt");
if (fd < 0)
{
- printf ("(mmap-write) open() failed\n");
+ printf ("(child-mm-wrt) open() failed\n");
return 1;
}
if (!mmap (fd, ACTUAL, strlen (sample)))
{
- printf ("(mmap-write) mmap() failed\n");
+ printf ("(child-mm-wrt) mmap() failed\n");
return 1;
}
memcpy (ACTUAL, sample, strlen (sample));
+
+ printf ("(child-mm-wrt) end\n");
+
return 234;
}
--- /dev/null
+(mmap-close) begin
+(mmap-close) end
}
read (fd, buf, strlen (sample));
- if (memcmp (ACTUAL, sample, strlen (sample)))
+ if (memcmp (buf, sample, strlen (sample)))
{
printf ("(mmap-exit) read of mmap-written file reported bad data\n");
return 1;
--- /dev/null
+(mmap-exit) begin
+(mmap-exit) run child
+(child-mm-wrt) begin
+(child-mm-wrt) end
+(mmap-exit) child finished
+(mmap-exit) end
size_t i;
int fd[2];
+#ifndef PINTOS
+ printf ("Sorry, this test won't work on POSIX,\n"
+ "because POSIX will accept overlapping mmaps.\n");
+ abort ();
+#endif
+
printf ("(mmap-overlap) begin\n");
for (i = 0; i < 2; i++)
--- /dev/null
+(mmap-overlap) begin
--- /dev/null
+(mmap-read) begin
+(mmap-read) end
--- /dev/null
+(mmap-shuffle) begin
+(mmap-shuffle) init: cksum=1573974830
+(mmap-shuffle) shuffle 0: cksum=1944930050
+(mmap-shuffle) shuffle 1: cksum=3381674432
+(mmap-shuffle) shuffle 2: cksum=3536554503
+(mmap-shuffle) shuffle 3: cksum=373089786
+(mmap-shuffle) shuffle 4: cksum=3509490433
+(mmap-shuffle) shuffle 5: cksum=4003286447
+(mmap-shuffle) shuffle 6: cksum=2956275536
+(mmap-shuffle) shuffle 7: cksum=2417689162
+(mmap-shuffle) shuffle 8: cksum=2870274961
+(mmap-shuffle) shuffle 9: cksum=3894560396
+(mmap-shuffle) end
for (i = 0; i < 2; i++)
{
- fd[i] = open ("sample");
+ fd[i] = open ("sample.txt");
if (fd[i] < 0)
{
printf ("(mmap-twice) open() %zu failed\n", i);
--- /dev/null
+(mmap-twice) begin
+(mmap-twice) end
--- /dev/null
+(mmap-write) begin
+(mmap-write) end
--- /dev/null
+(page-merge-par) begin
+page-merge-par) init
+(page-merge-par) sort chunk 0
+(page-merge-par) sort chunk 1
+(page-merge-par) sort chunk 2
+(page-merge-par) sort chunk 3
+(page-merge-par) sort chunk 4
+(page-merge-par) sort chunk 5
+(page-merge-par) sort chunk 6
+(page-merge-par) sort chunk 7
+(page-merge-par) merge
+(page-merge-par) verify
+(page-merge-par) success, buf_idx=516096
+(page-merge-par) end
close (fd);
/* Sort with subprocess. */
- pid_t child = exec ("child-sort");
+ pid_t child = exec ("child-sort buffer");
if (child == -1)
{
printf ("(page-merge-seq) exec() failed\n");
--- /dev/null
+(page-merge-seq) begin
+page-merge-seq) init
+(page-merge-seq) sort chunk 0
+(page-merge-seq) sort chunk 1
+(page-merge-seq) sort chunk 2
+(page-merge-seq) sort chunk 3
+(page-merge-seq) sort chunk 4
+(page-merge-seq) sort chunk 5
+(page-merge-seq) sort chunk 6
+(page-merge-seq) sort chunk 7
+(page-merge-seq) sort chunk 8
+(page-merge-seq) sort chunk 9
+(page-merge-seq) sort chunk 10
+(page-merge-seq) sort chunk 11
+(page-merge-seq) sort chunk 12
+(page-merge-seq) sort chunk 13
+(page-merge-seq) sort chunk 14
+(page-merge-seq) sort chunk 15
+(page-merge-seq) merge
+(page-merge-seq) verify
+(page-merge-seq) success, buf_idx=1032192
+(page-merge-seq) end
-(page-linear) begin
-(page-linear) init: cksum=3115322833
-(page-linear) shuffle 0: cksum=1691062564
-(page-linear) shuffle 1: cksum=1973575879
-(page-linear) shuffle 2: cksum=1647619479
-(page-linear) shuffle 3: cksum=96566261
-(page-linear) shuffle 4: cksum=3885786467
-(page-linear) shuffle 5: cksum=3022003332
-(page-linear) shuffle 6: cksum=3614934266
-(page-linear) shuffle 7: cksum=2704001777
-(page-linear) shuffle 8: cksum=735775156
-(page-linear) shuffle 9: cksum=1864109763
-(page-linear) end
+(page-shuffle) begin
+(page-shuffle) init: cksum=3115322833
+(page-shuffle) shuffle 0: cksum=63424829
+(page-shuffle) shuffle 1: cksum=3779635387
+(page-shuffle) shuffle 2: cksum=384449947
+(page-shuffle) shuffle 3: cksum=1883585126
+(page-shuffle) shuffle 4: cksum=2588854009
+(page-shuffle) shuffle 5: cksum=2250425557
+(page-shuffle) shuffle 6: cksum=866944104
+(page-shuffle) shuffle 7: cksum=3710004019
+(page-shuffle) shuffle 8: cksum=3936244654
+(page-shuffle) shuffle 9: cksum=2799827580
+(page-shuffle) end
--- /dev/null
+diff -up /home/blp/cs140/pintos/src/lib/debug.c.\~1.8.\~ /home/blp/cs140/pintos/src/lib/debug.c
+--- /home/blp/cs140/pintos/src/lib/debug.c.~1.8.~ 2004-09-12 13:14:11.000000000 -0700
++++ /home/blp/cs140/pintos/src/lib/debug.c 2004-10-17 00:02:32.000000000 -0700
+@@ -5,6 +5,7 @@
+ #include <stdio.h>
+ #include <string.h>
+ #ifdef KERNEL
++#include "threads/init.h"
+ #include "threads/interrupt.h"
+ #include "devices/serial.h"
+ #else
+@@ -83,7 +84,7 @@ debug_panic (const char *file, int line,
+
+ #ifdef KERNEL
+ serial_flush ();
+- for (;;);
++ power_off ();
+ #else
+ exit (1);
+ #endif
{
printf ("(pt-write-code) begin\n");
*(int *) main = 0;
+ printf ("(pt-write code) fail: writing the code segment succeeded\n");
printf ("(pt-write-code) end\n");
return 0;
}
--- /dev/null
+--- bitmap.c.~1.5.~ 2004-10-06 14:29:56.000000000 -0700
++++ bitmap.c 2004-11-03 14:35:22.000000000 -0800
+@@ -1,6 +1,7 @@
+ #include "bitmap.h"
+ #include <debug.h>
+ #include <limits.h>
++#include <random.h>
+ #include <round.h>
+ #include <stdio.h>
+ #include "threads/malloc.h"
+@@ -212,14 +213,25 @@ size_t
+ bitmap_scan (const struct bitmap *b, size_t start, size_t cnt, bool value)
+ {
+ size_t idx, last;
++ size_t n = 0, m;
+
+ ASSERT (b != NULL);
+ ASSERT (start <= b->bit_cnt);
+
+ for (idx = start, last = b->bit_cnt - cnt; idx <= last; idx++)
+ if (!contains (b, idx, idx + cnt, !value))
++ n++;
++ if (n == 0)
++ return BITMAP_ERROR;
++
++ random_init (0);
++ m = random_ulong () % n;
++
++ for (idx = start, last = b->bit_cnt - cnt; idx <= last; idx++)
++ if (!contains (b, idx, idx + cnt, !value) && m-- == 0)
+ return idx;
+- return BITMAP_ERROR;
++
++ NOT_REACHED ();
+ }
+
+ /* Finds the first group of CNT consecutive bits in B at or after