From b20d96a5998d8e29bcfb89c030200d891b284c00 Mon Sep 17 00:00:00 2001 From: Junjie Mao Date: Tue, 24 Mar 2015 10:20:35 +0800 Subject: [PATCH 1/4] Add a few configuration files for emacsers Signed-off-by: Junjie Mao --- .dir-locals.el | 2 ++ labcodes/lab1/.projectile | 0 labcodes/lab2/.projectile | 0 labcodes/lab3/.projectile | 0 labcodes/lab4/.projectile | 0 labcodes/lab5/.projectile | 0 labcodes/lab6/.projectile | 0 labcodes/lab7/.projectile | 0 labcodes/lab8/.projectile | 0 labcodes_answer/lab1_result/.projectile | 0 labcodes_answer/lab2_result/.projectile | 0 labcodes_answer/lab3_result/.projectile | 0 labcodes_answer/lab4_result/.projectile | 0 labcodes_answer/lab5_result/.projectile | 0 labcodes_answer/lab6_result/.projectile | 0 labcodes_answer/lab7_result/.projectile | 0 labcodes_answer/lab8_result/.projectile | 0 17 files changed, 2 insertions(+) create mode 100644 .dir-locals.el create mode 100644 labcodes/lab1/.projectile create mode 100644 labcodes/lab2/.projectile create mode 100644 labcodes/lab3/.projectile create mode 100644 labcodes/lab4/.projectile create mode 100644 labcodes/lab5/.projectile create mode 100644 labcodes/lab6/.projectile create mode 100644 labcodes/lab7/.projectile create mode 100644 labcodes/lab8/.projectile create mode 100644 labcodes_answer/lab1_result/.projectile create mode 100644 labcodes_answer/lab2_result/.projectile create mode 100644 labcodes_answer/lab3_result/.projectile create mode 100644 labcodes_answer/lab4_result/.projectile create mode 100644 labcodes_answer/lab5_result/.projectile create mode 100644 labcodes_answer/lab6_result/.projectile create mode 100644 labcodes_answer/lab7_result/.projectile create mode 100644 labcodes_answer/lab8_result/.projectile diff --git a/.dir-locals.el b/.dir-locals.el new file mode 100644 index 0000000..2676c09 --- /dev/null +++ b/.dir-locals.el @@ -0,0 +1,2 @@ +((c-mode . ((indent-tabs-mode . nil) + (c-basic-offset . 4)))) diff --git a/labcodes/lab1/.projectile b/labcodes/lab1/.projectile new file mode 100644 index 0000000..e69de29 diff --git a/labcodes/lab2/.projectile b/labcodes/lab2/.projectile new file mode 100644 index 0000000..e69de29 diff --git a/labcodes/lab3/.projectile b/labcodes/lab3/.projectile new file mode 100644 index 0000000..e69de29 diff --git a/labcodes/lab4/.projectile b/labcodes/lab4/.projectile new file mode 100644 index 0000000..e69de29 diff --git a/labcodes/lab5/.projectile b/labcodes/lab5/.projectile new file mode 100644 index 0000000..e69de29 diff --git a/labcodes/lab6/.projectile b/labcodes/lab6/.projectile new file mode 100644 index 0000000..e69de29 diff --git a/labcodes/lab7/.projectile b/labcodes/lab7/.projectile new file mode 100644 index 0000000..e69de29 diff --git a/labcodes/lab8/.projectile b/labcodes/lab8/.projectile new file mode 100644 index 0000000..e69de29 diff --git a/labcodes_answer/lab1_result/.projectile b/labcodes_answer/lab1_result/.projectile new file mode 100644 index 0000000..e69de29 diff --git a/labcodes_answer/lab2_result/.projectile b/labcodes_answer/lab2_result/.projectile new file mode 100644 index 0000000..e69de29 diff --git a/labcodes_answer/lab3_result/.projectile b/labcodes_answer/lab3_result/.projectile new file mode 100644 index 0000000..e69de29 diff --git a/labcodes_answer/lab4_result/.projectile b/labcodes_answer/lab4_result/.projectile new file mode 100644 index 0000000..e69de29 diff --git a/labcodes_answer/lab5_result/.projectile b/labcodes_answer/lab5_result/.projectile new file mode 100644 index 0000000..e69de29 diff --git a/labcodes_answer/lab6_result/.projectile b/labcodes_answer/lab6_result/.projectile new file mode 100644 index 0000000..e69de29 diff --git a/labcodes_answer/lab7_result/.projectile b/labcodes_answer/lab7_result/.projectile new file mode 100644 index 0000000..e69de29 diff --git a/labcodes_answer/lab8_result/.projectile b/labcodes_answer/lab8_result/.projectile new file mode 100644 index 0000000..e69de29 From 2d1c2001f594d420aba5c4f82470ffab9e4713f6 Mon Sep 17 00:00:00 2001 From: Junjie Mao Date: Tue, 24 Mar 2015 10:33:23 +0800 Subject: [PATCH 2/4] Create the sfs root directory if missing Signed-off-by: Junjie Mao --- .gitignore | 1 + labcodes/lab8/Makefile | 3 +++ labcodes_answer/lab8_result/Makefile | 3 +++ 3 files changed, 7 insertions(+) diff --git a/.gitignore b/.gitignore index 8621919..350a483 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ a.out *.log *.exe chytesting +disk0 \ No newline at end of file diff --git a/labcodes/lab8/Makefile b/labcodes/lab8/Makefile index d87f0a8..4aba038 100644 --- a/labcodes/lab8/Makefile +++ b/labcodes/lab8/Makefile @@ -273,6 +273,9 @@ $(foreach p,$(USER_BINS),$(eval $(call fscopy,$(p),$(SFSROOT)$(SLASH)))) $(SFSROOT): if [ ! -d "$(SFSROOT)" ]; then mkdir $(SFSROOT); fi +$(SFSROOT): + $(V)$(MKDIR) $@ + $(SFSIMG): $(SFSROOT) $(SFSBINS) | $(call totarget,mksfs) $(V)dd if=/dev/zero of=$@ bs=1M count=128 @$(call totarget,mksfs) $@ $(SFSROOT) diff --git a/labcodes_answer/lab8_result/Makefile b/labcodes_answer/lab8_result/Makefile index 0f28ca1..2ca4155 100644 --- a/labcodes_answer/lab8_result/Makefile +++ b/labcodes_answer/lab8_result/Makefile @@ -261,6 +261,9 @@ endef $(foreach p,$(USER_BINS),$(eval $(call fscopy,$(p),$(SFSROOT)$(SLASH)))) +$(SFSROOT): + $(V)$(MKDIR) $@ + $(SFSIMG): $(SFSROOT) $(SFSBINS) | $(call totarget,mksfs) $(V)dd if=/dev/zero of=$@ bs=1M count=128 @$(call totarget,mksfs) $@ $(SFSROOT) From 58815973236d3baadc2b4ccd36f77dc6648b57ce Mon Sep 17 00:00:00 2001 From: Junjie Mao Date: Tue, 24 Mar 2015 10:41:18 +0800 Subject: [PATCH 3/4] Add target run-nox- This target allows starting ucore with the specified user program in pure terminal. Signed-off-by: Junjie Mao --- .gitignore | 3 ++- labcodes/lab5/Makefile | 3 +++ labcodes/lab6/Makefile | 3 +++ labcodes/lab7/Makefile | 3 +++ labcodes/lab8/Makefile | 3 +++ labcodes_answer/lab5_result/Makefile | 3 +++ labcodes_answer/lab6_result/Makefile | 3 +++ labcodes_answer/lab7_result/Makefile | 3 +++ labcodes_answer/lab8_result/Makefile | 3 +++ 9 files changed, 26 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 350a483..5555472 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,5 @@ a.out *.log *.exe chytesting -disk0 \ No newline at end of file +disk0 +*.orig diff --git a/labcodes/lab5/Makefile b/labcodes/lab5/Makefile index d5ea58f..f416699 100644 --- a/labcodes/lab5/Makefile +++ b/labcodes/lab5/Makefile @@ -294,6 +294,9 @@ MAKEOPTS := --quiet --no-print-directory run-%: build-% $(V)$(QEMU) -parallel stdio $(QEMUOPTS) -serial null +run-nox-%: build-% + $(V)$(QEMU) -serial mon:stdio $(QEMUOPTS) -nographic + build-%: touch $(V)$(MAKE) $(MAKEOPTS) "DEFS+=-DTEST=$* -DTESTSTART=$(RUN_PREFIX)$*_out_start -DTESTSIZE=$(RUN_PREFIX)$*_out_size" diff --git a/labcodes/lab6/Makefile b/labcodes/lab6/Makefile index fe161c0..7f21bcf 100644 --- a/labcodes/lab6/Makefile +++ b/labcodes/lab6/Makefile @@ -294,6 +294,9 @@ MAKEOPTS := --quiet --no-print-directory run-%: build-% $(V)$(QEMU) -parallel stdio $(QEMUOPTS) -serial null +run-nox-%: build-% + $(V)$(QEMU) -serial mon:stdio $(QEMUOPTS) -nographic + build-%: touch $(V)$(MAKE) $(MAKEOPTS) "DEFS+=-DTEST=$* -DTESTSTART=$(RUN_PREFIX)$*_out_start -DTESTSIZE=$(RUN_PREFIX)$*_out_size" diff --git a/labcodes/lab7/Makefile b/labcodes/lab7/Makefile index 613b097..b680479 100644 --- a/labcodes/lab7/Makefile +++ b/labcodes/lab7/Makefile @@ -294,6 +294,9 @@ MAKEOPTS := --quiet --no-print-directory run-%: build-% $(V)$(QEMU) -parallel stdio $(QEMUOPTS) -serial null +run-nox-%: build-% + $(V)$(QEMU) -serial mon:stdio $(QEMUOPTS) -nographic + build-%: touch $(V)$(MAKE) $(MAKEOPTS) "DEFS+=-DTEST=$* -DTESTSTART=$(RUN_PREFIX)$*_out_start -DTESTSIZE=$(RUN_PREFIX)$*_out_size" diff --git a/labcodes/lab8/Makefile b/labcodes/lab8/Makefile index 4aba038..b2e287d 100644 --- a/labcodes/lab8/Makefile +++ b/labcodes/lab8/Makefile @@ -343,6 +343,9 @@ run-%: build-% sh-%: script-% $(V)$(QEMU) -parallel stdio $(QEMUOPTS) -serial null +run-nox-%: build-% + $(V)$(QEMU) -serial mon:stdio $(QEMUOPTS) -nographic + build-%: touch $(V)$(MAKE) $(MAKEOPTS) "DEFS+=-DTEST=$*" diff --git a/labcodes_answer/lab5_result/Makefile b/labcodes_answer/lab5_result/Makefile index 2ec80da..3ebf64c 100644 --- a/labcodes_answer/lab5_result/Makefile +++ b/labcodes_answer/lab5_result/Makefile @@ -285,6 +285,9 @@ MAKEOPTS := --quiet --no-print-directory run-%: build-% $(V)$(QEMU) -parallel stdio $(QEMUOPTS) -serial null +run-nox-%: build-% + $(V)$(QEMU) -serial mon:stdio $(QEMUOPTS) -nographic + build-%: touch $(V)$(MAKE) $(MAKEOPTS) "DEFS+=-DTEST=$* -DTESTSTART=$(RUN_PREFIX)$*_out_start -DTESTSIZE=$(RUN_PREFIX)$*_out_size" diff --git a/labcodes_answer/lab6_result/Makefile b/labcodes_answer/lab6_result/Makefile index ff4355c..4a2caf8 100644 --- a/labcodes_answer/lab6_result/Makefile +++ b/labcodes_answer/lab6_result/Makefile @@ -285,6 +285,9 @@ MAKEOPTS := --quiet --no-print-directory run-%: build-% $(V)$(QEMU) -parallel stdio $(QEMUOPTS) -serial null +run-nox-%: build-% + $(V)$(QEMU) -serial mon:stdio $(QEMUOPTS) -nographic + build-%: touch $(V)$(MAKE) $(MAKEOPTS) "DEFS+=-DTEST=$* -DTESTSTART=$(RUN_PREFIX)$*_out_start -DTESTSIZE=$(RUN_PREFIX)$*_out_size" diff --git a/labcodes_answer/lab7_result/Makefile b/labcodes_answer/lab7_result/Makefile index c5aa235..53da09a 100644 --- a/labcodes_answer/lab7_result/Makefile +++ b/labcodes_answer/lab7_result/Makefile @@ -285,6 +285,9 @@ MAKEOPTS := --quiet --no-print-directory run-%: build-% $(V)$(QEMU) -parallel stdio $(QEMUOPTS) -serial null +run-nox-%: build-% + $(V)$(QEMU) -serial mon:stdio $(QEMUOPTS) -nographic + build-%: touch $(V)$(MAKE) $(MAKEOPTS) "DEFS+=-DTEST=$* -DTESTSTART=$(RUN_PREFIX)$*_out_start -DTESTSIZE=$(RUN_PREFIX)$*_out_size" diff --git a/labcodes_answer/lab8_result/Makefile b/labcodes_answer/lab8_result/Makefile index 2ca4155..1e3e279 100644 --- a/labcodes_answer/lab8_result/Makefile +++ b/labcodes_answer/lab8_result/Makefile @@ -335,6 +335,9 @@ run-%: build-% sh-%: script-% $(V)$(QEMU) -parallel stdio $(QEMUOPTS) -serial null +run-nox-%: build-% + $(V)$(QEMU) -serial mon:stdio $(QEMUOPTS) -nographic + build-%: touch $(V)$(MAKE) $(MAKEOPTS) "DEFS+=-DTEST=$*" From d9a83bd7becdf082cfc4688e37df8b64e83a33d5 Mon Sep 17 00:00:00 2001 From: Junjie Mao Date: Tue, 24 Mar 2015 10:52:27 +0800 Subject: [PATCH 4/4] Adjust the time slice to 50ms The original time slice (200ms) is too large for the priority test to generate a satisfactory result in 20s. If we only schedule 5 times a second, there are only 100 pick_next calls to the scheduler. I believe making scheduling more frequently does little harm to the system. Actually more scheduling opportunities may also reveal bugs which are not triggered previously. Adopting smaller time slices also allows us to reduce the time spent on the priority test, which can benefit the autotesting system. Signed-off-by: Junjie Mao --- labcodes/lab6/kern/schedule/sched.h | 2 +- labcodes/lab6/user/priority.c | 2 +- labcodes/lab7/kern/schedule/sched.c | 2 +- labcodes/lab7/kern/schedule/sched.h | 2 +- labcodes/lab7/user/priority.c | 4 ++-- labcodes/lab8/kern/schedule/sched.h | 2 +- labcodes/lab8/user/priority.c | 4 ++-- labcodes_answer/lab6_result/kern/schedule/sched.h | 2 +- labcodes_answer/lab6_result/user/priority.c | 2 +- labcodes_answer/lab7_result/kern/schedule/sched.c | 2 +- labcodes_answer/lab7_result/user/priority.c | 4 ++-- labcodes_answer/lab8_result/kern/schedule/sched.c | 2 +- labcodes_answer/lab8_result/user/priority.c | 4 ++-- 13 files changed, 17 insertions(+), 17 deletions(-) diff --git a/labcodes/lab6/kern/schedule/sched.h b/labcodes/lab6/kern/schedule/sched.h index ca33799..766ac03 100644 --- a/labcodes/lab6/kern/schedule/sched.h +++ b/labcodes/lab6/kern/schedule/sched.h @@ -5,7 +5,7 @@ #include #include -#define MAX_TIME_SLICE 20 +#define MAX_TIME_SLICE 5 struct proc_struct; diff --git a/labcodes/lab6/user/priority.c b/labcodes/lab6/user/priority.c index bcbc29d..6a1cae4 100644 --- a/labcodes/lab6/user/priority.c +++ b/labcodes/lab6/user/priority.c @@ -5,7 +5,7 @@ #define TOTAL 5 /* to get enough accuracy, MAX_TIME (the running time of each process) should >1000 mseconds. */ -#define MAX_TIME 2000 +#define MAX_TIME 1000 unsigned int acc[TOTAL]; int status[TOTAL]; int pids[TOTAL]; diff --git a/labcodes/lab7/kern/schedule/sched.c b/labcodes/lab7/kern/schedule/sched.c index 8c3ff99..53c2e3c 100644 --- a/labcodes/lab7/kern/schedule/sched.c +++ b/labcodes/lab7/kern/schedule/sched.c @@ -49,7 +49,7 @@ sched_init(void) { sched_class = &default_sched_class; rq = &__rq; - rq->max_time_slice = 20; + rq->max_time_slice = 5; sched_class->init(rq); cprintf("sched class: %s\n", sched_class->name); diff --git a/labcodes/lab7/kern/schedule/sched.h b/labcodes/lab7/kern/schedule/sched.h index ca33799..766ac03 100644 --- a/labcodes/lab7/kern/schedule/sched.h +++ b/labcodes/lab7/kern/schedule/sched.h @@ -5,7 +5,7 @@ #include #include -#define MAX_TIME_SLICE 20 +#define MAX_TIME_SLICE 5 struct proc_struct; diff --git a/labcodes/lab7/user/priority.c b/labcodes/lab7/user/priority.c index d71147e..d097270 100644 --- a/labcodes/lab7/user/priority.c +++ b/labcodes/lab7/user/priority.c @@ -5,7 +5,7 @@ #define TOTAL 5 /* to get enough accuracy, MAX_TIME (the running time of each process) should >1000 mseconds. */ -#define MAX_TIME 2000 +#define MAX_TIME 1000 #define SLEEP_TIME 400 unsigned int acc[TOTAL]; int status[TOTAL]; @@ -39,7 +39,7 @@ main(void) { spin_delay(); ++ acc[i]; if(acc[i]%4000==0) { - if((time=gettime_msec())>MAX_TIME) { + if((time=gettime_msec())>MAX_TIME+SLEEP_TIME) { cprintf("child pid %d, acc %d, time %d\n",getpid(),acc[i],time); exit(acc[i]); } diff --git a/labcodes/lab8/kern/schedule/sched.h b/labcodes/lab8/kern/schedule/sched.h index ca33799..766ac03 100644 --- a/labcodes/lab8/kern/schedule/sched.h +++ b/labcodes/lab8/kern/schedule/sched.h @@ -5,7 +5,7 @@ #include #include -#define MAX_TIME_SLICE 20 +#define MAX_TIME_SLICE 5 struct proc_struct; diff --git a/labcodes/lab8/user/priority.c b/labcodes/lab8/user/priority.c index d71147e..5624ec6 100644 --- a/labcodes/lab8/user/priority.c +++ b/labcodes/lab8/user/priority.c @@ -5,7 +5,7 @@ #define TOTAL 5 /* to get enough accuracy, MAX_TIME (the running time of each process) should >1000 mseconds. */ -#define MAX_TIME 2000 +#define MAX_TIME 1000 #define SLEEP_TIME 400 unsigned int acc[TOTAL]; int status[TOTAL]; @@ -39,7 +39,7 @@ main(void) { spin_delay(); ++ acc[i]; if(acc[i]%4000==0) { - if((time=gettime_msec())>MAX_TIME) { + if((time=gettime_msec())>SLEEP_TIME+MAX_TIME) { cprintf("child pid %d, acc %d, time %d\n",getpid(),acc[i],time); exit(acc[i]); } diff --git a/labcodes_answer/lab6_result/kern/schedule/sched.h b/labcodes_answer/lab6_result/kern/schedule/sched.h index ca33799..766ac03 100644 --- a/labcodes_answer/lab6_result/kern/schedule/sched.h +++ b/labcodes_answer/lab6_result/kern/schedule/sched.h @@ -5,7 +5,7 @@ #include #include -#define MAX_TIME_SLICE 20 +#define MAX_TIME_SLICE 5 struct proc_struct; diff --git a/labcodes_answer/lab6_result/user/priority.c b/labcodes_answer/lab6_result/user/priority.c index bcbc29d..6a1cae4 100644 --- a/labcodes_answer/lab6_result/user/priority.c +++ b/labcodes_answer/lab6_result/user/priority.c @@ -5,7 +5,7 @@ #define TOTAL 5 /* to get enough accuracy, MAX_TIME (the running time of each process) should >1000 mseconds. */ -#define MAX_TIME 2000 +#define MAX_TIME 1000 unsigned int acc[TOTAL]; int status[TOTAL]; int pids[TOTAL]; diff --git a/labcodes_answer/lab7_result/kern/schedule/sched.c b/labcodes_answer/lab7_result/kern/schedule/sched.c index e272635..c0dab33 100644 --- a/labcodes_answer/lab7_result/kern/schedule/sched.c +++ b/labcodes_answer/lab7_result/kern/schedule/sched.c @@ -48,7 +48,7 @@ sched_init(void) { sched_class = &default_sched_class; rq = &__rq; - rq->max_time_slice = 20; + rq->max_time_slice = 5; sched_class->init(rq); cprintf("sched class: %s\n", sched_class->name); diff --git a/labcodes_answer/lab7_result/user/priority.c b/labcodes_answer/lab7_result/user/priority.c index d71147e..d097270 100644 --- a/labcodes_answer/lab7_result/user/priority.c +++ b/labcodes_answer/lab7_result/user/priority.c @@ -5,7 +5,7 @@ #define TOTAL 5 /* to get enough accuracy, MAX_TIME (the running time of each process) should >1000 mseconds. */ -#define MAX_TIME 2000 +#define MAX_TIME 1000 #define SLEEP_TIME 400 unsigned int acc[TOTAL]; int status[TOTAL]; @@ -39,7 +39,7 @@ main(void) { spin_delay(); ++ acc[i]; if(acc[i]%4000==0) { - if((time=gettime_msec())>MAX_TIME) { + if((time=gettime_msec())>MAX_TIME+SLEEP_TIME) { cprintf("child pid %d, acc %d, time %d\n",getpid(),acc[i],time); exit(acc[i]); } diff --git a/labcodes_answer/lab8_result/kern/schedule/sched.c b/labcodes_answer/lab8_result/kern/schedule/sched.c index e272635..c0dab33 100644 --- a/labcodes_answer/lab8_result/kern/schedule/sched.c +++ b/labcodes_answer/lab8_result/kern/schedule/sched.c @@ -48,7 +48,7 @@ sched_init(void) { sched_class = &default_sched_class; rq = &__rq; - rq->max_time_slice = 20; + rq->max_time_slice = 5; sched_class->init(rq); cprintf("sched class: %s\n", sched_class->name); diff --git a/labcodes_answer/lab8_result/user/priority.c b/labcodes_answer/lab8_result/user/priority.c index d71147e..5624ec6 100644 --- a/labcodes_answer/lab8_result/user/priority.c +++ b/labcodes_answer/lab8_result/user/priority.c @@ -5,7 +5,7 @@ #define TOTAL 5 /* to get enough accuracy, MAX_TIME (the running time of each process) should >1000 mseconds. */ -#define MAX_TIME 2000 +#define MAX_TIME 1000 #define SLEEP_TIME 400 unsigned int acc[TOTAL]; int status[TOTAL]; @@ -39,7 +39,7 @@ main(void) { spin_delay(); ++ acc[i]; if(acc[i]%4000==0) { - if((time=gettime_msec())>MAX_TIME) { + if((time=gettime_msec())>SLEEP_TIME+MAX_TIME) { cprintf("child pid %d, acc %d, time %d\n",getpid(),acc[i],time); exit(acc[i]); }