ia64/xen-unstable

changeset 16735:1101ca828ad9

minios: add wait_event_deadline

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
Signed-off-by: Tim Deegan <tim.deegan@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jan 17 14:41:12 2008 +0000 (2008-01-17)
parents a26aee4a1522
children 8f6640070a86
files extras/mini-os/include/wait.h
line diff
     1.1 --- a/extras/mini-os/include/wait.h	Thu Jan 17 14:40:55 2008 +0000
     1.2 +++ b/extras/mini-os/include/wait.h	Thu Jan 17 14:41:12 2008 +0000
     1.3 @@ -85,29 +85,31 @@ static inline void wake_up(struct wait_q
     1.4      local_irq_restore(flags);   \
     1.5  } while (0)
     1.6  
     1.7 -#define wait_event(wq, condition) do{             \
     1.8 -    unsigned long flags;                          \
     1.9 -    if(condition)                                 \
    1.10 -        break;                                    \
    1.11 -    DEFINE_WAIT(__wait);                          \
    1.12 -    for(;;)                                       \
    1.13 -    {                                             \
    1.14 -        /* protect the list */                    \
    1.15 -        local_irq_save(flags);                    \
    1.16 -        add_wait_queue(&wq, &__wait);             \
    1.17 -        block(current);                           \
    1.18 -        local_irq_restore(flags);                 \
    1.19 -        if(condition)                             \
    1.20 -            break;                                \
    1.21 -        schedule();                               \
    1.22 -    }                                             \
    1.23 -    local_irq_save(flags);                        \
    1.24 -    /* need to wake up */                         \
    1.25 -    wake(current);                                \
    1.26 -    remove_wait_queue(&__wait);                   \
    1.27 -    local_irq_restore(flags);                     \
    1.28 +#define wait_event_deadline(wq, condition, deadline) do {       \
    1.29 +    unsigned long flags;                                        \
    1.30 +    if(condition)                                               \
    1.31 +        break;                                                  \
    1.32 +    DEFINE_WAIT(__wait);                                        \
    1.33 +    for(;;)                                                     \
    1.34 +    {                                                           \
    1.35 +        /* protect the list */                                  \
    1.36 +        local_irq_save(flags);                                  \
    1.37 +        add_wait_queue(&wq, &__wait);                           \
    1.38 +        current->wakeup_time = deadline;                        \
    1.39 +        clear_runnable(current);                                \
    1.40 +        local_irq_restore(flags);                               \
    1.41 +        if((condition) || (deadline && NOW() >= deadline))      \
    1.42 +            break;                                              \
    1.43 +        schedule();                                             \
    1.44 +    }                                                           \
    1.45 +    local_irq_save(flags);                                      \
    1.46 +    /* need to wake up */                                       \
    1.47 +    wake(current);                                              \
    1.48 +    remove_wait_queue(&__wait);                                 \
    1.49 +    local_irq_restore(flags);                                   \
    1.50  } while(0) 
    1.51  
    1.52 +#define wait_event(wq, condition) wait_event_deadline(wq, condition, 0) 
    1.53  
    1.54  
    1.55