Changeset b3f8fb7 in mainline for kernel/generic/src/synch/waitq.c


Ignore:
Timestamp:
2007-01-28T13:25:49Z (17 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8e8c1a5
Parents:
1ba41c5
Message:

huge type system cleanup
remove cyclical type dependencies across multiple header files
many minor coding style fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/synch/waitq.c

    r1ba41c5 rb3f8fb7  
    5050#include <arch/asm.h>
    5151#include <arch/types.h>
    52 #include <typedefs.h>
    5352#include <time/timeout.h>
    5453#include <arch.h>
     
    118117}
    119118
    120 /** Interrupt sleeping thread.
    121  *
    122  * This routine attempts to interrupt a thread from its sleep in a waitqueue.
    123  * If the thread is not found sleeping, no action is taken.
    124  *
    125  * @param t Thread to be interrupted.
    126  */
    127 void waitq_interrupt_sleep(thread_t *t)
    128 {
    129         waitq_t *wq;
    130         bool do_wakeup = false;
    131         ipl_t ipl;
    132 
    133         ipl = interrupts_disable();
    134         spinlock_lock(&threads_lock);
    135         if (!thread_exists(t))
    136                 goto out;
    137 
    138 grab_locks:
    139         spinlock_lock(&t->lock);
    140         if ((wq = t->sleep_queue)) {            /* assignment */
    141                 if (!(t->sleep_interruptible)) {
    142                         /*
    143                          * The sleep cannot be interrupted.
    144                          */
    145                         spinlock_unlock(&t->lock);
    146                         goto out;
    147                 }
    148                        
    149                 if (!spinlock_trylock(&wq->lock)) {
    150                         spinlock_unlock(&t->lock);
    151                         goto grab_locks;        /* avoid deadlock */
    152                 }
    153 
    154                 if (t->timeout_pending && timeout_unregister(&t->sleep_timeout))
    155                         t->timeout_pending = false;
    156 
    157                 list_remove(&t->wq_link);
    158                 t->saved_context = t->sleep_interruption_context;
    159                 do_wakeup = true;
    160                 t->sleep_queue = NULL;
    161                 spinlock_unlock(&wq->lock);
    162         }
    163         spinlock_unlock(&t->lock);
    164 
    165         if (do_wakeup)
    166                 thread_ready(t);
    167 
    168 out:
    169         spinlock_unlock(&threads_lock);
    170         interrupts_restore(ipl);
    171 }
    172119
    173120/** Sleep until either wakeup, timeout or interruption occurs
     
    426373         * (the link belongs to the wait queue), but because
    427374         * of synchronization with waitq_timeouted_sleep()
    428          * and waitq_interrupt_sleep().
     375         * and thread_interrupt_sleep().
    429376         *
    430377         * In order for these two functions to work, the following
Note: See TracChangeset for help on using the changeset viewer.