Changeset 922c7ce in mainline
- Timestamp:
- 2005-10-01T22:51:14Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5e04b48d
- Parents:
- 941d1e9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/synch/waitq.c
r941d1e9 r922c7ce 27 27 */ 28 28 29 #include <context.h> 29 #include <synch/waitq.h> 30 #include <synch/synch.h> 31 #include <synch/spinlock.h> 30 32 #include <proc/thread.h> 31 32 #include <synch/synch.h>33 #include <synch/waitq.h>34 #include <synch/spinlock.h>35 36 33 #include <arch/asm.h> 37 34 #include <arch/types.h> 35 #include <time/timeout.h> 38 36 #include <arch.h> 39 37 #include <context.h> 40 38 #include <list.h> 41 39 42 #include <time/timeout.h> 43 40 /** Initialize wait queue 41 * 42 * Initialize wait queue. 43 * 44 * @param wq Pointer to wait queue to be initialized. 45 */ 44 46 void waitq_initialize(waitq_t *wq) 45 47 { … … 49 51 } 50 52 51 /* 52 * Called with interrupts disabled from clock() when sleep_timeout 53 * timeouts. This function is not allowed to enable interrupts. 54 * 55 * It is supposed to try to remove 'its' thread from the waitqueue; it 56 * can eventually fail to achieve this goal when these two events 57 * overlap; in that case it behaves just as though there was no 58 * timeout at all 53 /** Handle timeout during waitq_sleep_timeout() call 54 * 55 * This routine is called when waitq_sleep_timeout() timeouts. 56 * Interrupts are disabled. 57 * 58 * It is supposed to try to remove 'its' thread from the wait queue; 59 * it can eventually fail to achieve this goal when these two events 60 * overlap. In that case it behaves just as though there was no 61 * timeout at all. 62 * 63 * @param data Pointer to the thread that called waitq_sleep_timeout(). 59 64 */ 60 65 void waitq_interrupted_sleep(void *data) … … 93 98 } 94 99 95 /* 100 /** Sleep until either wakeup or timeout occurs 101 * 96 102 * This is a sleep implementation which allows itself to be 97 103 * interrupted from the sleep, restoring a failover context. 98 104 * 105 * Sleepers are organised in FIFO fashion in a structure called wait queue. 106 * 99 107 * This function is really basic in that other functions as waitq_sleep() 100 108 * and all the *_timeout() functions use it. 101 109 * 102 * The third argument controls whether only a conditional sleep 103 * (non-blocking sleep) is called for when the second argument is 0. 110 * @param wq Pointer to wait queue. 111 * @param usec Timeout value in microseconds. 112 * @param nonblocking Controls whether only a conditional sleep 113 * (non-blocking sleep) is called for when the usec argument is 0. 114 * 115 * Relation between 'usec' and 'nonblocking' is described by this table: 104 116 * 105 117 * usec | nonblocking | what happens if there is no missed_wakeup … … 109 121 * > 0 | x | blocks with timeout until timeout or wakeup 110 122 * 111 * return values: 112 * ESYNCH_WOULD_BLOCK 113 * ESYNCH_TIMEOUT 114 * ESYNCH_OK_ATOMIC 115 * ESYNCH_OK_BLOCKED 123 * @return Returns one of: ESYNCH_WOULD_BLOCK, ESYNCH_TIMEOUT, 124 * ESYNCH_OK_ATOMIC, ESYNCH_OK_BLOCKED. 125 * 126 * Meaning of the return values is described by the following chart: 127 * 128 * ESYNCH_WOULD_BLOCK Sleep failed because at the time of the call, 129 * there was no pending wakeup. 130 * ESYNCH_TIMEOUT Sleep timed out. 131 * ESYNCH_OK_ATOMIC Sleep succeeded; at the time of the call, 132 * where was a pending wakeup. 133 * ESYNCH_OK_BLOCKED Sleep succeeded; the full sleep was attempted. 116 134 */ 117 135 int waitq_sleep_timeout(waitq_t *wq, __u32 usec, int nonblocking) … … 193 211 194 212 195 /* 196 * This is the SMP- and IRQ-safe wrapper meant for general use. 197 */ 198 /* 199 * Besides its 'normal' wakeup operation, it attempts to unregister possible timeout. 213 /** Wake up first thread sleeping in a wait queue 214 * 215 * Wake up first thread sleeping in a wait queue. 216 * This is the SMP- and IRQ-safe wrapper meant for 217 * general use. 218 * 219 * Besides its 'normal' wakeup operation, it attempts 220 * to unregister possible timeout. 221 * 222 * @param wq Pointer to wait queue. 223 * @param all If this is non-zero, all sleeping threads 224 * will be woken up and missed count will be zeroed. 200 225 */ 201 226 void waitq_wakeup(waitq_t *wq, int all) … … 212 237 } 213 238 214 /* 215 * This is the internal SMP- and IRQ-unsafe version of waitq_wakeup. 216 * It assumes wq->lock is already locked. 239 /** Internal SMP- and IRQ-unsafe version of waitq_wakeup() 240 * 241 * This is the internal SMP- and IRQ-unsafe version 242 * of waitq_wakeup(). It assumes wq->lock is already 243 * locked and interrupts are already disabled. 244 * 245 * @param wq Pointer to wait queue. 246 * @param all If this is non-zero, all sleeping threads 247 * will be woken up and missed count will be zeroed. 217 248 */ 218 249 void _waitq_wakeup_unsafe(waitq_t *wq, int all)
Note:
See TracChangeset
for help on using the changeset viewer.