Bladeren bron

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 <junjie.mao@hotmail.com>
main
Junjie Mao 9 jaren geleden
bovenliggende
commit
d9a83bd7be
13 gewijzigde bestanden met toevoegingen van 17 en 17 verwijderingen
  1. +1
    -1
      labcodes/lab6/kern/schedule/sched.h
  2. +1
    -1
      labcodes/lab6/user/priority.c
  3. +1
    -1
      labcodes/lab7/kern/schedule/sched.c
  4. +1
    -1
      labcodes/lab7/kern/schedule/sched.h
  5. +2
    -2
      labcodes/lab7/user/priority.c
  6. +1
    -1
      labcodes/lab8/kern/schedule/sched.h
  7. +2
    -2
      labcodes/lab8/user/priority.c
  8. +1
    -1
      labcodes_answer/lab6_result/kern/schedule/sched.h
  9. +1
    -1
      labcodes_answer/lab6_result/user/priority.c
  10. +1
    -1
      labcodes_answer/lab7_result/kern/schedule/sched.c
  11. +2
    -2
      labcodes_answer/lab7_result/user/priority.c
  12. +1
    -1
      labcodes_answer/lab8_result/kern/schedule/sched.c
  13. +2
    -2
      labcodes_answer/lab8_result/user/priority.c

+ 1
- 1
labcodes/lab6/kern/schedule/sched.h Bestand weergeven

@ -5,7 +5,7 @@
#include <list.h>
#include <skew_heap.h>
#define MAX_TIME_SLICE 20
#define MAX_TIME_SLICE 5
struct proc_struct;

+ 1
- 1
labcodes/lab6/user/priority.c Bestand weergeven

@ -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];

+ 1
- 1
labcodes/lab7/kern/schedule/sched.c Bestand weergeven

@ -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);

+ 1
- 1
labcodes/lab7/kern/schedule/sched.h Bestand weergeven

@ -5,7 +5,7 @@
#include <list.h>
#include <skew_heap.h>
#define MAX_TIME_SLICE 20
#define MAX_TIME_SLICE 5
struct proc_struct;

+ 2
- 2
labcodes/lab7/user/priority.c Bestand weergeven

@ -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]);
}

+ 1
- 1
labcodes/lab8/kern/schedule/sched.h Bestand weergeven

@ -5,7 +5,7 @@
#include <list.h>
#include <skew_heap.h>
#define MAX_TIME_SLICE 20
#define MAX_TIME_SLICE 5
struct proc_struct;

+ 2
- 2
labcodes/lab8/user/priority.c Bestand weergeven

@ -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]);
}

+ 1
- 1
labcodes_answer/lab6_result/kern/schedule/sched.h Bestand weergeven

@ -5,7 +5,7 @@
#include <list.h>
#include <skew_heap.h>
#define MAX_TIME_SLICE 20
#define MAX_TIME_SLICE 5
struct proc_struct;

+ 1
- 1
labcodes_answer/lab6_result/user/priority.c Bestand weergeven

@ -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];

+ 1
- 1
labcodes_answer/lab7_result/kern/schedule/sched.c Bestand weergeven

@ -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);

+ 2
- 2
labcodes_answer/lab7_result/user/priority.c Bestand weergeven

@ -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]);
}

+ 1
- 1
labcodes_answer/lab8_result/kern/schedule/sched.c Bestand weergeven

@ -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);

+ 2
- 2
labcodes_answer/lab8_result/user/priority.c Bestand weergeven

@ -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]);
}

Laden…
Annuleren
Opslaan