Readying for CS 450 xv6 assignment
This commit is contained in:
parent
0ae596828b
commit
6e0d8f2ef6
4 changed files with 76 additions and 4 deletions
6
Makefile
6
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)
|
||||
|
|
51
bigtest.c
Normal file
51
bigtest.c
Normal file
|
@ -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();
|
||||
}
|
19
getcount.c
Normal file
19
getcount.c
Normal file
|
@ -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();
|
||||
}
|
4
mkfs.c
4
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;
|
||||
|
|
Loading…
Reference in a new issue