aboutsummaryrefslogtreecommitdiffstats
path: root/xen
diff options
context:
space:
mode:
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>2003-09-12 15:13:51 +0000
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>2003-09-12 15:13:51 +0000
commitba7bd1f062b9d9d52aabc15b6412f2446e124697 (patch)
tree7f9bb8c19ddce69a120e761ec17c6dbd01d170d1 /xen
parente2c12cbc69135bc8305bc2e652bbb80b518973f6 (diff)
downloadxen-ba7bd1f062b9d9d52aabc15b6412f2446e124697.tar.gz
xen-ba7bd1f062b9d9d52aabc15b6412f2446e124697.tar.bz2
xen-ba7bd1f062b9d9d52aabc15b6412f2446e124697.zip
bitkeeper revision 1.424.1.1 (3f61e2afHSuo-MbsBfF4HF_JFYfgdQ)
sched.h, schedule.c, setup.c, process.c: Fix initialisation of idle tasks so that they are put on the runqueue earlier.
Diffstat (limited to 'xen')
-rw-r--r--xen/arch/i386/process.c3
-rw-r--r--xen/arch/i386/setup.c2
-rw-r--r--xen/common/schedule.c83
-rw-r--r--xen/include/xeno/sched.h1
4 files changed, 47 insertions, 42 deletions
diff --git a/xen/arch/i386/process.c b/xen/arch/i386/process.c
index 5b604ca413..8665961b1e 100644
--- a/xen/arch/i386/process.c
+++ b/xen/arch/i386/process.c
@@ -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();
diff --git a/xen/arch/i386/setup.c b/xen/arch/i386/setup.c
index 2c254d51da..eb1e671fea 100644
--- a/xen/arch/i386/setup.c
+++ b/xen/arch/i386/setup.c
@@ -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)
diff --git a/xen/common/schedule.c b/xen/common/schedule.c
index 94acfdc338..d28b221c5f 100644
--- a/xen/common/schedule.c
+++ b/xen/common/schedule.c
@@ -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>
@@ -39,20 +32,16 @@
#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
****************************************************************************/
diff --git a/xen/include/xeno/sched.h b/xen/include/xeno/sched.h
index 9af0b54e12..527ceb5e6a 100644
--- a/xen/include/xeno/sched.h
+++ b/xen/include/xeno/sched.h
@@ -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);