Skip to content

Commit

Permalink
Merge with lab7.
Browse files Browse the repository at this point in the history
  • Loading branch information
Wei Hu committed Jun 11, 2010
2 parents 8485d34 + a439da8 commit cbd9fc2
Show file tree
Hide file tree
Showing 36 changed files with 1,378 additions and 175 deletions.
4 changes: 2 additions & 2 deletions conf/lab.mk
@@ -1,2 +1,2 @@
LAB=6
PACKAGEDATE=Fri Nov 13 02:30:19 EST 2009
LAB=7
PACKAGEDATE=Tue Nov 24 17:32:15 EST 2009
17 changes: 17 additions & 0 deletions fs/Makefrag
Expand Up @@ -21,6 +21,23 @@ FSIMGTXTFILES := fs/newmotd \
FSIMGTXTFILES := $(FSIMGTXTFILES) \
fs/index.html

USERAPPS := $(USERAPPS) \
$(OBJDIR)/user/primespipe \
$(OBJDIR)/user/sh \
$(OBJDIR)/user/testfdsharing \
$(OBJDIR)/user/testkbd \
$(OBJDIR)/user/testpipe \
$(OBJDIR)/user/testpteshare \
$(OBJDIR)/user/testshell \
$(OBJDIR)/user/testmalloc

FSIMGTXTFILES := $(FSIMGTXTFILES) \
fs/lorem \
fs/script \
fs/out \
fs/testshell.key \
fs/testshell.out \
fs/testshell.sh


FSIMGFILES := $(FSIMGTXTFILES) $(USERAPPS)
Expand Down
12 changes: 12 additions & 0 deletions fs/lorem
@@ -0,0 +1,12 @@
Lorem ipsum dolor sit amet, consectetur
adipisicing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam, quis
nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit
in voluptate velit esse cillum dolore eu
fugiat nulla pariatur. Excepteur sint
occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim
id est laborum.
1 change: 1 addition & 0 deletions fs/out
@@ -0,0 +1 @@

5 changes: 5 additions & 0 deletions fs/script
@@ -0,0 +1,5 @@
echo This is from the script.
cat lorem | num | cat
echo These are my file descriptors.
lsfd -1
echo This is the end of the script.
2 changes: 1 addition & 1 deletion fs/serv.c
Expand Up @@ -124,7 +124,7 @@ serve_open(envid_t envid, struct Fsreq_open *rq)

if (debug)
cprintf("sending success, page %08x\n", (uintptr_t) o->o_fd);
ipc_send(envid, 0, o->o_fd, PTE_P|PTE_U|PTE_W|PTE_SHARE);
ipc_send(envid, 0, o->o_fd, PTE_P|PTE_U|PTE_W);
return;
out:
ipc_send(envid, r, 0, 0);
Expand Down
69 changes: 69 additions & 0 deletions fs/testshell.key
@@ -0,0 +1,69 @@
# echo hello world | cat
hello world
# cat lorem >out
# cat out
Lorem ipsum dolor sit amet, consectetur
adipisicing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam, quis
nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit
in voluptate velit esse cillum dolore eu
fugiat nulla pariatur. Excepteur sint
occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim
id est laborum.
# cat lorem |num
1 Lorem ipsum dolor sit amet, consectetur
2 adipisicing elit, sed do eiusmod tempor
3 incididunt ut labore et dolore magna
4 aliqua. Ut enim ad minim veniam, quis
5 nostrud exercitation ullamco laboris
6 nisi ut aliquip ex ea commodo consequat.
7 Duis aute irure dolor in reprehenderit
8 in voluptate velit esse cillum dolore eu
9 fugiat nulla pariatur. Excepteur sint
10 occaecat cupidatat non proident, sunt in
11 culpa qui officia deserunt mollit anim
12 id est laborum.
# cat lorem |num |num |num |num |num
1 1 1 1 1 Lorem ipsum dolor sit amet, consectetur
2 2 2 2 2 adipisicing elit, sed do eiusmod tempor
3 3 3 3 3 incididunt ut labore et dolore magna
4 4 4 4 4 aliqua. Ut enim ad minim veniam, quis
5 5 5 5 5 nostrud exercitation ullamco laboris
6 6 6 6 6 nisi ut aliquip ex ea commodo consequat.
7 7 7 7 7 Duis aute irure dolor in reprehenderit
8 8 8 8 8 in voluptate velit esse cillum dolore eu
9 9 9 9 9 fugiat nulla pariatur. Excepteur sint
10 10 10 10 10 occaecat cupidatat non proident, sunt in
11 11 11 11 11 culpa qui officia deserunt mollit anim
12 12 12 12 12 id est laborum.
# lsfd -1
fd 0: name testshell.sh isdir 0 size 126 dev file
fd 1: name testshell.out isdir 0 size 1951 dev file
# cat script
echo This is from the script.
cat lorem | num | cat
echo These are my file descriptors.
lsfd -1
echo This is the end of the script.
# sh <script
This is from the script.
1 Lorem ipsum dolor sit amet, consectetur
2 adipisicing elit, sed do eiusmod tempor
3 incididunt ut labore et dolore magna
4 aliqua. Ut enim ad minim veniam, quis
5 nostrud exercitation ullamco laboris
6 nisi ut aliquip ex ea commodo consequat.
7 Duis aute irure dolor in reprehenderit
8 in voluptate velit esse cillum dolore eu
9 fugiat nulla pariatur. Excepteur sint
10 occaecat cupidatat non proident, sunt in
11 culpa qui officia deserunt mollit anim
12 id est laborum.
These are my file descriptors.
fd 0: name script isdir 0 size 132 dev file
fd 1: name testshell.out isdir 0 size 2780 dev file
This is the end of the script.
1 change: 1 addition & 0 deletions fs/testshell.out
@@ -0,0 +1 @@

8 changes: 8 additions & 0 deletions fs/testshell.sh
@@ -0,0 +1,8 @@
echo hello world | cat
cat lorem >out
cat out
cat lorem |num
cat lorem |num |num |num |num |num
lsfd -1
cat script
sh <script
5 changes: 3 additions & 2 deletions grade-functions.sh
Expand Up @@ -16,6 +16,7 @@ pts=5
timeout=30
preservefs=n
qemu=`$make -s --no-print-directory which-qemu`
brkfn=readline

echo_n () {
# suns can't echo -n, and Mac OS X can't echo "x\c"
Expand All @@ -26,7 +27,7 @@ echo_n () {
run () {
# Find the address of the kernel readline function,
# which the kernel monitor uses to read commands interactively.
brkaddr=`grep 'readline$' obj/kern/kernel.sym | sed -e's/ .*$//g'`
brkaddr=`grep " $brkfn\$" obj/kern/kernel.sym | sed -e's/ .*$//g'`
#echo "brkaddr $brkaddr"

# Generate a unique GDB port
Expand All @@ -48,7 +49,7 @@ run () {
) > jos.in

sleep 1
gdb -batch -nx -x jos.in > /dev/null
gdb -batch -nx -x jos.in > /dev/null 2>&1
t1=`date +%s.%N 2>/dev/null`
time=`echo "scale=1; ($t1-$t0)/1" | sed 's/.N/.0/g' | bc 2>/dev/null`
time="(${time}s)"
Expand Down
60 changes: 60 additions & 0 deletions grade-lab7.sh
@@ -0,0 +1,60 @@
#!/bin/sh

qemuopts="-hda obj/kern/kernel.img -hdb obj/fs/fs.img -net user -net nic,model=i82559er"
. ./grade-functions.sh
brkfn=cons_getc


$make
run

score=0

# 10 points - run-testpteshare
pts=10
runtest1 -tag 'PTE_SHARE [testpteshare]' testpteshare \
'fork handles PTE_SHARE right' \
'spawn handles PTE_SHARE right' \

# 10 points - run-testfdsharing
pts=10
runtest1 -tag 'fd sharing [testfdsharing]' testfdsharing \
'read in parent succeeded' \
'read in child succeeded' \
'write to file data page succeeded'

# 20 points - run-icode
pts=20
runtest1 -tag 'updated file system switch [icode]' icode \
'icode: read /motd' \
'This is /motd, the message of the day.' \
'icode: spawn /init' \
'init: running' \
'init: data seems okay' \
'icode: exiting' \
'init: bss seems okay' \
"init: args: 'init' 'initarg1' 'initarg2'" \
'init: running sh' \

# 20 points - run-testshell
pts=20
timeout=60
runtest1 -tag 'shell [testshell]' testshell \
'shell ran correctly' \

# 10 points - run-primespipe
pts=10
timeout=120
echo 'The primespipe test has up to 2 minutes to complete. Be patient.'
runtest1 -tag 'primespipe' primespipe \
! 1 2 3 ! 4 5 ! 6 7 ! 8 ! 9 \
! 10 11 ! 12 13 ! 14 ! 15 ! 16 17 ! 18 19 \
! 20 ! 21 ! 22 23 ! 24 ! 25 ! 26 ! 27 ! 28 29 \
! 30 31 ! 32 ! 33 ! 34 ! 35 ! 36 37 ! 38 ! 39 \
541 1009 1097

echo "Score: $score/70"

if [ $score -lt 70 ]; then
exit 1
fi
12 changes: 12 additions & 0 deletions inc/lib.h
Expand Up @@ -134,6 +134,18 @@ int pageref(void *addr);
envid_t spawn(const char *program, const char **argv);
envid_t spawnl(const char *program, const char *arg0, ...);

// console.c
void cputchar(int c);
int getchar(void);
int iscons(int fd);
int opencons(void);

// pipe.c
int pipe(int pipefds[2]);
int pipeisclosed(int pipefd);

// wait.c
void wait(envid_t env);

/* File open modes */
#define O_RDONLY 0x0000 /* open for reading only */
Expand Down
1 change: 1 addition & 0 deletions inc/trap.h
Expand Up @@ -32,6 +32,7 @@
// Hardware IRQ numbers. We receive these as (IRQ_OFFSET+IRQ_WHATEVER)
#define IRQ_TIMER 0
#define IRQ_KBD 1
#define IRQ_SERIAL 4
#define IRQ_SPURIOUS 7
#define IRQ_IDE 14
#define IRQ_ERROR 19
Expand Down
19 changes: 11 additions & 8 deletions kern/Makefrag
Expand Up @@ -39,16 +39,19 @@ KERN_SRCFILES += kern/e100.c \
# Only build files if they exist.
KERN_SRCFILES := $(wildcard $(KERN_SRCFILES))

KERN_BINFILES := user/idle \
# Binary program images to embed within the kernel.
KERN_BINFILES := user/icode \
user/idle \
user/pingpong \
user/primes \
user/faultregs \
user/writemotd \
user/icode \
user/testtime \
user/httpd \
user/echosrv \
user/echotest \
user/testpteshare \
user/testfdsharing \
user/testpipe \
user/testpiperace \
user/testpiperace2 \
user/primespipe \
user/testkbd \
user/testshell \
fs/fs \
net/ns

Expand Down
8 changes: 6 additions & 2 deletions kern/init.c
Expand Up @@ -63,10 +63,14 @@ i386_init(void)
ENV_CREATE2(TEST, TESTSIZE);
#else
// Touch all you want.
// ENV_CREATE(user_echosrv);
// ENV_CREATE(user_httpd);
ENV_CREATE(user_icode);
// ENV_CREATE(user_pipereadeof);
// ENV_CREATE(user_pipewriteeof);
#endif

// Should not be necessary - drain keyboard because interrupt has given up.
kbd_intr();


// Schedule and run the first user environment!
sched_yield();
Expand Down
3 changes: 3 additions & 0 deletions kern/trap.c
Expand Up @@ -166,6 +166,9 @@ trap_dispatch(struct Trapframe *tf)
return;
}

//// Lab 7: Handle keyboard interrupts.


default:
// Unexpected trap: The user process or the kernel has a bug.
print_trapframe(tf);
Expand Down
3 changes: 3 additions & 0 deletions lib/Makefrag
Expand Up @@ -28,6 +28,9 @@ LIB_SRCFILES := $(LIB_SRCFILES) \
lib/sockets.c \
lib/nsipc.c \
lib/malloc.c
LIB_SRCFILES := $(LIB_SRCFILES) \
lib/pipe.c \
lib/wait.c

LIB_OBJFILES := $(patsubst lib/%.c, $(OBJDIR)/lib/%.o, $(LIB_SRCFILES))
LIB_OBJFILES := $(patsubst lib/%.S, $(OBJDIR)/lib/%.o, $(LIB_OBJFILES))
Expand Down

0 comments on commit cbd9fc2

Please sign in to comment.