update lab1-8 codes and docs. now version is 0.2
This commit is contained in:
@@ -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);
|
||||
@@ -98,6 +99,7 @@ schedule(void) {
|
||||
local_intr_restore(intr_flag);
|
||||
}
|
||||
|
||||
// add timer to timer_list
|
||||
void
|
||||
add_timer(timer_t *timer) {
|
||||
bool intr_flag;
|
||||
@@ -120,6 +122,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 +142,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;
|
||||
|
||||
@@ -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__ */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user