Rev 1116 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1116 | Rev 1152 | ||
---|---|---|---|
Line 36... | Line 36... | ||
36 | /* |
36 | /* |
37 | * Note about race conditions. |
37 | * Note about race conditions. |
38 | * Because of non-atomic nature of operations performed sequentially on the futex |
38 | * Because of non-atomic nature of operations performed sequentially on the futex |
39 | * counter and the futex wait queue, there is a race condition: |
39 | * counter and the futex wait queue, there is a race condition: |
40 | * |
40 | * |
41 | * wq->missed_wakeups == 1 && futex->count = 1 |
41 | * (wq->missed_wakeups == 1) && (futex->count = 1) |
42 | * |
42 | * |
43 | * Scenario 1 (wait queue timeout vs. futex_up()): |
43 | * Scenario 1 (wait queue timeout vs. futex_up()): |
44 | * 1. assume wq->missed_wakeups == 0 && futex->count == -1 |
44 | * 1. assume wq->missed_wakeups == 0 && futex->count == -1 |
45 | * (ie. thread A sleeping, thread B in the critical section) |
45 | * (ie. thread A sleeping, thread B in the critical section) |
46 | * 2. A receives timeout and gets removed from the wait queue |
46 | * 2. A receives timeout and gets removed from the wait queue |
Line 152... | Line 152... | ||
152 | 152 | ||
153 | /** Up the futex. |
153 | /** Up the futex. |
154 | * |
154 | * |
155 | * @param futex Futex. |
155 | * @param futex Futex. |
156 | * |
156 | * |
157 | * @return ENOENT if there is no such virtual address or futex. Otherwise zero. |
157 | * @return ENOENT if there is no such virtual address. Otherwise zero. |
158 | */ |
158 | */ |
159 | int futex_up(atomic_t *futex) |
159 | int futex_up(atomic_t *futex) |
160 | { |
160 | { |
161 | long val; |
161 | long val; |
162 | 162 |