aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>2003-09-19 14:17:44 +0000
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>2003-09-19 14:17:44 +0000
commitecbdae89d44cef91fd4fc7cf0c84bf3c6857c922 (patch)
treea3d2271dd17beb07fbf63efe6b637c842df66007
parente4d1a26b8d0cc6a7b5de0048975d02ff82eadabb (diff)
parent4a43e81118fca43a1a139c6a94ee726ce4fb7b05 (diff)
downloadxen-ecbdae89d44cef91fd4fc7cf0c84bf3c6857c922.tar.gz
xen-ecbdae89d44cef91fd4fc7cf0c84bf3c6857c922.tar.bz2
xen-ecbdae89d44cef91fd4fc7cf0c84bf3c6857c922.zip
bitkeeper revision 1.439 (3f6b1008rs8VEuAtsUstwLMIIZgVFA)
Merge scramble.cl.cam.ac.uk:/auto/groups/xeno/BK/xeno.bk into scramble.cl.cam.ac.uk:/local/scratch/kaf24/xeno
-rw-r--r--xen/common/schedule.c45
1 files changed, 33 insertions, 12 deletions
diff --git a/xen/common/schedule.c b/xen/common/schedule.c
index d28b221c5f..616598a7a3 100644
--- a/xen/common/schedule.c
+++ b/xen/common/schedule.c
@@ -612,10 +612,13 @@ long schedule_timeout(long timeout)
{
struct timer_list timer;
unsigned long expire;
-
+
switch (timeout)
{
case MAX_SCHEDULE_TIMEOUT:
+ /* Sanity! This just wouldn't make sense. */
+ if ( is_idle_task(current) )
+ panic("Arbitrary sleep in idle task!");
/*
* These two special cases are useful to be comfortable in the caller.
* Nothing more. We could take MAX_SCHEDULE_TIMEOUT from one of the
@@ -624,6 +627,7 @@ long schedule_timeout(long timeout)
*/
schedule();
goto out;
+
default:
/*
* Another bit of PARANOID. Note that the retval will be 0 since no
@@ -644,17 +648,34 @@ long schedule_timeout(long timeout)
expire = timeout + jiffies;
- init_timer(&timer);
- timer.expires = expire;
- timer.data = (unsigned long) current;
- timer.function = process_timeout;
-
- add_timer(&timer);
- schedule();
- del_timer_sync(&timer);
-
- timeout = expire - jiffies;
-
+ if ( is_idle_task(current) )
+ {
+ /*
+ * If the idle task is calling in then it shouldn't ever sleep. We
+ * therefore force it to TASK_RUNNING here and busy-wait. We spin on
+ * schedule to give other domains a chance meanwhile.
+ */
+ set_current_state(TASK_RUNNING);
+ do {
+ schedule();
+ timeout = expire - jiffies;
+ }
+ while ( (timeout > 0) && is_idle_task(current) );
+ }
+ else
+ {
+ init_timer(&timer);
+ timer.expires = expire;
+ timer.data = (unsigned long) current;
+ timer.function = process_timeout;
+
+ add_timer(&timer);
+ schedule();
+ del_timer_sync(&timer);
+
+ timeout = expire - jiffies;
+ }
+
out:
return timeout < 0 ? 0 : timeout;
}