diff --git a/Makefile b/Makefile index fe25dc4..8012888 100644 --- a/Makefile +++ b/Makefile @@ -170,6 +170,8 @@ UPROGS=\ _usertests\ _wc\ _zombie\ + _bigtest\ + #_getcount\ fs.img: mkfs README $(UPROGS) ./mkfs fs.img README $(UPROGS) @@ -206,9 +208,9 @@ QEMUGDB = $(shell if $(QEMU) -help | grep -q '^-gdb'; \ then echo "-gdb tcp::$(GDBPORT)"; \ else echo "-s -p $(GDBPORT)"; fi) ifndef CPUS -CPUS := 2 +CPUS := 1 endif -QEMUOPTS = -hdb fs.img xv6.img -smp $(CPUS) -m 512 $(QEMUEXTRA) +QEMUOPTS = -hdb fs.img xv6.img -smp $(CPUS) -m 512 $(QEMUEXTRA) -snapshot qemu: fs.img xv6.img $(QEMU) -serial mon:stdio $(QEMUOPTS) diff --git a/bigtest.c b/bigtest.c new file mode 100644 index 0000000..6ed76fe --- /dev/null +++ b/bigtest.c @@ -0,0 +1,51 @@ +#include "types.h" +#include "stat.h" +#include "user.h" +#include "fcntl.h" + +int +main() +{ + char buf[512]; + int fd, i, sectors; + + fd = open("big.file", O_CREATE | O_WRONLY); + if(fd < 0){ + printf(2, "big: cannot open big.file for writing\n"); + exit(); + } + + sectors = 0; + while(1){ + *(int*)buf = sectors; + int cc = write(fd, buf, sizeof(buf)); + if(cc <= 0) + break; + sectors++; + if (sectors % 100 == 0) + printf(2, "."); + } + + printf(1, "\nwrote %d sectors\n", sectors); + + close(fd); + fd = open("big.file", O_RDONLY); + if(fd < 0){ + printf(2, "big: cannot re-open big.file for reading\n"); + exit(); + } + for(i = 0; i < sectors; i++){ + int cc = read(fd, buf, sizeof(buf)); + if(cc <= 0){ + printf(2, "big: read error at sector %d\n", i); + exit(); + } + if(*(int*)buf != i){ + printf(2, "big: read the wrong data (%d) for sector %d\n", + *(int*)buf, i); + exit(); + } + } + + exit(); +} diff --git a/getcount.c b/getcount.c new file mode 100644 index 0000000..1ecb5f4 --- /dev/null +++ b/getcount.c @@ -0,0 +1,19 @@ +#include "types.h" +#include "user.h" +#include "syscall.h" + +int +main(int argc, char *argv[]) +{ + printf(1, "initial fork count %d\n", getcount(SYS_fork)); + if (fork() == 0) { + printf(1, "child fork count %d\n", getcount(SYS_fork)); + printf(1, "child write count %d\n", getcount(SYS_write)); + } else { + wait(); + printf(1, "parent fork count %d\n", getcount(SYS_fork)); + printf(1, "parent write count %d\n", getcount(SYS_write)); + } + printf(1, "wait count %d\n", getcount(SYS_wait)); + exit(); +} diff --git a/mkfs.c b/mkfs.c index 4b0e329..940105e 100644 --- a/mkfs.c +++ b/mkfs.c @@ -13,10 +13,10 @@ #define static_assert(a, b) do { switch (0) case 0: case (a): ; } while (0) -int nblocks = 985; +int nblocks = 25000; int nlog = LOGSIZE; int ninodes = 200; -int size = 1024; +int size = 25045; int fsfd; struct superblock sb;