update lab1-8 codes and docs. now version is 0.2

This commit is contained in:
chyyuu
2012-08-26 18:04:26 +08:00
parent 15f7ebf37b
commit d537948e30
134 changed files with 1268 additions and 1005 deletions

View File

@@ -6,6 +6,7 @@
#include <assert.h>
#include <default_sched.h>
// the list of timer
static list_entry_t timer_list;
static struct sched_class *sched_class;
@@ -48,7 +49,7 @@ sched_init(void) {
sched_class = &default_sched_class;
rq = &__rq;
rq->max_time_slice = 20;
rq->max_time_slice = MAX_TIME_SLICE;
sched_class->init(rq);
cprintf("sched class: %s\n", sched_class->name);
@@ -120,6 +121,7 @@ add_timer(timer_t *timer) {
local_intr_restore(intr_flag);
}
// del timer from timer_list
void
del_timer(timer_t *timer) {
bool intr_flag;
@@ -139,6 +141,7 @@ del_timer(timer_t *timer) {
local_intr_restore(intr_flag);
}
// call scheduler to update tick related info, and check the timer is expired? If expired, then wakup proc
void
run_timer_list(void) {
bool intr_flag;

View File

@@ -5,17 +5,20 @@
#include <list.h>
#include <skew_heap.h>
#define MAX_TIME_SLICE 20
struct proc_struct;
typedef struct {
unsigned int expires;
struct proc_struct *proc;
list_entry_t timer_link;
unsigned int expires; //the expire time
struct proc_struct *proc; //the proc wait in this timer. If the expire time is end, then this proc will be scheduled
list_entry_t timer_link; //the timer list
} timer_t;
#define le2timer(le, member) \
to_struct((le), timer_t, member)
// init a timer
static inline timer_t *
timer_init(timer_t *timer, struct proc_struct *proc, int expires) {
timer->expires = expires;
@@ -62,9 +65,9 @@ struct run_queue {
void sched_init(void);
void wakeup_proc(struct proc_struct *proc);
void schedule(void);
void add_timer(timer_t *timer);
void del_timer(timer_t *timer);
void run_timer_list(void);
void add_timer(timer_t *timer); // add timer to timer_list
void del_timer(timer_t *timer); // del timer from timer_list
void run_timer_list(void); // call scheduler to update tick related info, and check the timer is expired? If expired, then wakup proc
#endif /* !__KERN_SCHEDULE_SCHED_H__ */