]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/mini-os.git/commitdiff
minios: add wait_event_deadline
authorKeir Fraser <keir.fraser@citrix.com>
Thu, 17 Jan 2008 14:41:12 +0000 (14:41 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Thu, 17 Jan 2008 14:41:12 +0000 (14:41 +0000)
Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
Signed-off-by: Tim Deegan <tim.deegan@eu.citrix.com>
include/wait.h

index 6bd4d0ce9569d50fec2f4bef4330c02ae2ac80ea..cbcaab3519482f103194b889356c2748ad69f689 100644 (file)
@@ -85,29 +85,31 @@ static inline void wake_up(struct wait_queue_head *head)
     local_irq_restore(flags);   \
 } while (0)
 
-#define wait_event(wq, condition) do{             \
-    unsigned long flags;                          \
-    if(condition)                                 \
-        break;                                    \
-    DEFINE_WAIT(__wait);                          \
-    for(;;)                                       \
-    {                                             \
-        /* protect the list */                    \
-        local_irq_save(flags);                    \
-        add_wait_queue(&wq, &__wait);             \
-        block(current);                           \
-        local_irq_restore(flags);                 \
-        if(condition)                             \
-            break;                                \
-        schedule();                               \
-    }                                             \
-    local_irq_save(flags);                        \
-    /* need to wake up */                         \
-    wake(current);                                \
-    remove_wait_queue(&__wait);                   \
-    local_irq_restore(flags);                     \
+#define wait_event_deadline(wq, condition, deadline) do {       \
+    unsigned long flags;                                        \
+    if(condition)                                               \
+        break;                                                  \
+    DEFINE_WAIT(__wait);                                        \
+    for(;;)                                                     \
+    {                                                           \
+        /* protect the list */                                  \
+        local_irq_save(flags);                                  \
+        add_wait_queue(&wq, &__wait);                           \
+        current->wakeup_time = deadline;                        \
+        clear_runnable(current);                                \
+        local_irq_restore(flags);                               \
+        if((condition) || (deadline && NOW() >= deadline))      \
+            break;                                              \
+        schedule();                                             \
+    }                                                           \
+    local_irq_save(flags);                                      \
+    /* need to wake up */                                       \
+    wake(current);                                              \
+    remove_wait_queue(&__wait);                                 \
+    local_irq_restore(flags);                                   \
 } while(0) 
 
+#define wait_event(wq, condition) wait_event_deadline(wq, condition, 0)