ia64/xen-unstable
changeset 390:87ad003d8f24
bitkeeper revision 1.184.1.3 (3ead17b9bSG1IOFbiQcgNCIoozp7XQ)
virtual time warping (not tested)
virtual time warping (not tested)
author | rn@wyvis.research.intel-research.net |
---|---|
date | Mon Apr 28 11:59:53 2003 +0000 (2003-04-28) |
parents | f03519d93921 |
children | 561ef4670036 |
files | xen/common/schedule.c xen/include/xeno/sched.h |
line diff
1.1 --- a/xen/common/schedule.c Mon Apr 28 10:58:45 2003 +0000 1.2 +++ b/xen/common/schedule.c Mon Apr 28 11:59:53 2003 +0000 1.3 @@ -46,6 +46,7 @@ 1.4 1.5 1.6 #define MCU (s32)MICROSECS(100) /* Minimum unit */ 1.7 +#define MCU_ADVANCE 10 /* default weight */ 1.8 #define TIME_SLOP (s32)MICROSECS(50) /* allow time to slip a bit */ 1.9 static s32 ctx_allow=(s32)MILLISECS(5); /* context switch allowance */ 1.10 1.11 @@ -102,13 +103,34 @@ static inline int __task_on_runqueue(str 1.12 #define next_domain(p) \\ 1.13 list_entry((p)->run_list.next, struct task_struct, run_list) 1.14 1.15 +/* calculate evt */ 1.16 +static void __calc_evt(struct task_struct *p) 1.17 +{ 1.18 + s_time_t now = NOW(); 1.19 + if (p->warpback) { 1.20 + if (((now - p->warped) < p->warpl) && 1.21 + ((now - p->uwarped) > p->warpu)) { 1.22 + /* allowed to warp */ 1.23 + p->evt = p->avt - p->warp; 1.24 + } else { 1.25 + /* warped for too long -> unwarp */ 1.26 + p->evt = p->avt; 1.27 + p->uwarped = now; 1.28 + p->warpback = 0; 1.29 + } 1.30 + } else { 1.31 + p->evt = p->avt; 1.32 + } 1.33 +} 1.34 + 1.35 + 1.36 /****************************************************************************** 1.37 * Add and remove a domain 1.38 ******************************************************************************/ 1.39 void sched_add_domain(struct task_struct *p) 1.40 { 1.41 p->state = TASK_SUSPENDED; 1.42 - p->mcu_advance = 10; 1.43 + p->mcu_advance = MCU_ADVANCE; 1.44 1.45 if (p->domain == IDLE_DOMAIN_ID) { 1.46 p->avt = 0xffffffff; 1.47 @@ -118,7 +140,11 @@ void sched_add_domain(struct task_struct 1.48 /* set avt end evt to system virtual time */ 1.49 p->avt = schedule_data[p->processor].svt; 1.50 p->evt = schedule_data[p->processor].svt; 1.51 - /* RN: XXX BVT fill in other bits */ 1.52 + /* set some default values here */ 1.53 + p->warpback = 0; 1.54 + p->warp = 0; 1.55 + p->warpl = 0; 1.56 + p->warpu = 0; 1.57 } 1.58 } 1.59 1.60 @@ -138,16 +164,23 @@ int wake_up(struct task_struct *p) 1.61 1.62 spin_lock_irqsave(&schedule_data[p->processor].lock, flags); 1.63 1.64 + /* XXX RN: should we warp here? Might be a good idea to also boost a 1.65 + * domain which currently is unwarped and on run queue and 1.66 + * the receives an event. */ 1.67 if ( __task_on_runqueue(p) ) goto out; 1.68 1.69 p->state = TASK_RUNNING; 1.70 __add_to_runqueue_head(p); 1.71 + //__add_to_runqueue_tail(p); 1.72 1.73 /* set the BVT parameters */ 1.74 if (p->avt < schedule_data[p->processor].svt) 1.75 p->avt = schedule_data[p->processor].svt; 1.76 1.77 - p->evt = p->avt; /* RN: XXX BVT deal with warping here */ 1.78 + /* deal with warping here */ 1.79 + p->warpback = 1; 1.80 + p->warped = NOW(); 1.81 + __calc_evt(p); 1.82 1.83 #ifdef SCHED_HISTO 1.84 p->wokenup = NOW(); 1.85 @@ -165,6 +198,7 @@ int wake_up(struct task_struct *p) 1.86 long do_yield(void) 1.87 { 1.88 current->state = TASK_INTERRUPTIBLE; 1.89 + current->warpback = 0; /* XXX should only do this when blocking */ 1.90 schedule(); 1.91 return 0; 1.92 } 1.93 @@ -281,7 +315,6 @@ asmlinkage void schedule(void) 1.94 now = NOW(); 1.95 1.96 /* remove timer, if till on list */ 1.97 - //if (active_ac_timer(&schedule_data[this_cpu].s_timer)) 1.98 rem_ac_timer(&schedule_data[this_cpu].s_timer); 1.99 1.100 /* deschedule the current domain */ 1.101 @@ -301,7 +334,9 @@ asmlinkage void schedule(void) 1.102 mcus = ranfor/MCU; 1.103 if (ranfor % MCU) mcus ++; /* always round up */ 1.104 prev->avt += mcus * prev->mcu_advance; 1.105 - prev->evt = prev->avt; /* RN: XXX BVT deal with warping here */ 1.106 + 1.107 + /* recalculate evt */ 1.108 + __calc_evt(prev); 1.109 1.110 /* dequeue */ 1.111 __del_from_runqueue(prev);
2.1 --- a/xen/include/xeno/sched.h Mon Apr 28 10:58:45 2003 +0000 2.2 +++ b/xen/include/xeno/sched.h Mon Apr 28 11:59:53 2003 +0000 2.3 @@ -110,11 +110,12 @@ struct task_struct { 2.4 unsigned long mcu_advance; /* inverse of weight */ 2.5 s32 avt; /* actual virtual time */ 2.6 s32 evt; /* effective virtual time */ 2.7 + int warpback; /* warp? */ 2.8 long warp; /* virtual time warp */ 2.9 long warpl; /* warp limit */ 2.10 long warpu; /* unwarp time requirement */ 2.11 - long warped; /* time it ran warped last time */ 2.12 - long uwarped; /* time it ran unwarped last time */ 2.13 + s_time_t warped; /* time it ran warped last time */ 2.14 + s_time_t uwarped; /* time it ran unwarped last time */ 2.15 2.16 /* Network I/O */ 2.17 net_vif_t *net_vif_list[MAX_DOMAIN_VIFS];