bitkeeper revision 1.424.1.1 (3f61e2afHSuo-MbsBfF4HF_JFYfgdQ)
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Fri, 12 Sep 2003 15:13:51 +0000 (15:13 +0000)
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Fri, 12 Sep 2003 15:13:51 +0000 (15:13 +0000)
sched.h, schedule.c, setup.c, process.c:
  Fix initialisation of idle tasks so that they are put on the runqueue earlier.

xen/arch/i386/process.c
xen/arch/i386/setup.c
xen/common/schedule.c
xen/include/xeno/sched.h

index 5b604ca4135b0b0cf43ae93bee6c707291645af0..8665961b1e9dd66b46d5d8b9c46731683ec1607f 100644 (file)
@@ -73,9 +73,8 @@ void cpu_idle (void)
 {
     int cpu = smp_processor_id();
 
+    /* Just some sanity to ensure that the scheduler is set up okay. */
     ASSERT(current->domain == IDLE_DOMAIN_ID);
-
-    current->has_cpu = 1;
     (void)wake_up(current);
     schedule();
 
index 2c254d51da924f56cf75647bdbf99d2480223d98..eb1e671fea065b493ccf5b9b0659d847496ac6e2 100644 (file)
@@ -271,6 +271,8 @@ void __init cpu_init(void)
     mapcache[nr] = (unsigned long *)get_free_page(GFP_KERNEL);
     clear_page(mapcache[nr]);
     *pl2e = mk_l2_pgentry(__pa(mapcache[nr]) | PAGE_HYPERVISOR);
+
+    init_idle_task();
 }
 
 static void __init do_initcalls(void)
index 94acfdc338f93d1557cc65896c3895f254b843d3..d28b221c5fbf7dc1952575287c3f6c3f9c54ba09 100644 (file)
@@ -1,22 +1,15 @@
 /* -*-  Mode:C; c-basic-offset:4; tab-width:4 -*-
  ****************************************************************************
- * (C) 2002 - Rolf Neugebauer - Intel Research Cambridge
+ * (C) 2002-2003 - Rolf Neugebauer - Intel Research Cambridge
+ * (C) 2002-2003 University of Cambridge
  ****************************************************************************
  *
- *        File: schedule.c
- *      Author: Rolf Neugebauer (neugebar@dcs.gla.ac.uk)
- *     Changes: 
- *              
- *        Date: Nov 2002
+ *        File: common/schedule.c
+ *      Author: Rolf Neugebar & Keir Fraser
  * 
- * Environment: Xen Hypervisor
  * Description: CPU scheduling
  *              implements A Borrowed Virtual Time scheduler.
  *              (see Duda & Cheriton SOSP'99)
- *
- ****************************************************************************
- * $Id: c-insert.c,v 1.7 2002/11/08 16:04:34 rn Exp $
- ****************************************************************************
  */
 
 #include <xeno/config.h>
 #define TRC(_x)
 #endif
 
-#define SCHED_HISTO
+/*#define SCHED_HISTO*/
 #ifdef SCHED_HISTO
 #define BUCKETS 31
 #endif
 
+#define MCU            (s32)MICROSECS(100)    /* Minimum unit */
+#define MCU_ADVANCE    10                     /* default weight */
+#define TIME_SLOP      (s32)MICROSECS(50)     /* allow time to slip a bit */
+static s32 ctx_allow = (s32)MILLISECS(5);     /* context switch allowance */
 
-#define MCU          (s32)MICROSECS(100)    /* Minimum unit */
-#define MCU_ADVANCE  10                     /* default weight */
-#define TIME_SLOP    (s32)MICROSECS(50)     /* allow time to slip a bit */
-static s32 ctx_allow=(s32)MILLISECS(5);     /* context switch allowance */
-
-/*****************************************************************************
- * per CPU data for the scheduler.
- *****************************************************************************/
 typedef struct schedule_data_st
 {
     spinlock_t          lock;           /* lock for protecting this */
@@ -64,61 +53,59 @@ typedef struct schedule_data_st
 #ifdef SCHED_HISTO
     u32                 hist[BUCKETS];  /* for scheduler latency histogram */
 #endif
-
 } __cacheline_aligned schedule_data_t;
 schedule_data_t schedule_data[NR_CPUS];
 
-struct ac_timer     v_timer;        /* scheduling timer  */
+struct ac_timer v_timer;        /* scheduling timer  */
 static void virt_timer(unsigned long foo);
 static void dump_rqueue(struct list_head *queue, char *name);
 
 
-/*****************************************************************************
- * Some convenience functions
- *****************************************************************************/
-/* add a task to the head of the runqueue */
 static inline void __add_to_runqueue_head(struct task_struct * p)
-{
-    
+{    
     list_add(&p->run_list, &schedule_data[p->processor].runqueue);
 }
-/* add a task to the tail of the runqueue */
+
 static inline void __add_to_runqueue_tail(struct task_struct * p)
 {
     list_add_tail(&p->run_list, &schedule_data[p->processor].runqueue);
 }
 
-/* remove a task from runqueue  */
 static inline void __del_from_runqueue(struct task_struct * p)
 {
     list_del(&p->run_list);
     p->run_list.next = NULL;
 }
-/* is task on run queue?  */
+
 static inline int __task_on_runqueue(struct task_struct *p)
 {
-    return (p->run_list.next != NULL);
+    return p->run_list.next != NULL;
 }
 
 #define next_domain(p) \\
         list_entry((p)->run_list.next, struct task_struct, run_list)
 
-/* calculate evt  */
 static void __calc_evt(struct task_struct *p)
 {
     s_time_t now = NOW();
-    if (p->warpback) {
-        if (((now - p->warped) < p->warpl) &&
-            ((now - p->uwarped) > p->warpu)) {
+    if ( p->warpback ) 
+    {
+        if ( ((now - p->warped) < p->warpl) &&
+             ((now - p->uwarped) > p->warpu) )
+        {
             /* allowed to warp */
             p->evt = p->avt - p->warp;
-        } else {
+        } 
+        else 
+        {
             /* warped for too long -> unwarp */
             p->evt      = p->avt;
             p->uwarped  = now;
             p->warpback = 0;
         }
-    } else {
+    } 
+    else 
+    {
         p->evt = p->avt;
     }
 }
@@ -132,11 +119,14 @@ void sched_add_domain(struct task_struct *p)
     p->state       = TASK_SUSPENDED;
     p->mcu_advance = MCU_ADVANCE;
 
-    if (p->domain == IDLE_DOMAIN_ID) {
+    if ( p->domain == IDLE_DOMAIN_ID )
+    {
         p->avt = 0xffffffff;
         p->evt = 0xffffffff;
         schedule_data[p->processor].idle = p;
-    } else {
+    } 
+    else 
+    {
         /* set avt end evt to system virtual time */
         p->avt         = schedule_data[p->processor].svt;
         p->evt         = schedule_data[p->processor].svt;
@@ -154,6 +144,19 @@ void sched_rem_domain(struct task_struct *p)
 }
 
 
+void init_idle_task(void)
+{
+    unsigned long flags;
+    struct task_struct *p = current;
+    spin_lock_irqsave(&schedule_data[p->processor].lock, flags);
+    p->has_cpu = 1;
+    p->state = TASK_RUNNING;
+    if ( !__task_on_runqueue(p) )
+        __add_to_runqueue_head(p);
+    spin_unlock_irqrestore(&schedule_data[p->processor].lock, flags);
+}
+
+
 /****************************************************************************
  * wake up a domain which had been sleeping
  ****************************************************************************/
index 9af0b54e1239613f13efa5dcec1a7492d55368aa..527ceb5e6a951e8a90d8faeed01c1066a6f84f7a 100644 (file)
@@ -271,6 +271,7 @@ void sched_rem_domain(struct task_struct *p);
 long sched_bvtctl(unsigned long ctx_allow);
 long sched_adjdom(int dom, unsigned long mcu_adv, unsigned long warp, 
                   unsigned long warpl, unsigned long warpu);
+void init_idle_task(void);
 int  wake_up(struct task_struct *p);
 long schedule_timeout(long timeout);
 long do_yield(void);