Rev 1787 | Rev 2071 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1787 | Rev 1888 | ||
---|---|---|---|
Line 204... | Line 204... | ||
204 | thread_register_call_me(release_spinlock, NULL); |
204 | thread_register_call_me(release_spinlock, NULL); |
205 | #endif |
205 | #endif |
206 | 206 | ||
207 | rc = _mutex_lock_timeout(&rwl->exclusive, usec, flags); |
207 | rc = _mutex_lock_timeout(&rwl->exclusive, usec, flags); |
208 | switch (rc) { |
208 | switch (rc) { |
209 | case ESYNCH_WOULD_BLOCK: |
209 | case ESYNCH_WOULD_BLOCK: |
210 | /* |
210 | /* |
211 | * release_spinlock() wasn't called |
211 | * release_spinlock() wasn't called |
212 | */ |
212 | */ |
213 | thread_register_call_me(NULL, NULL); |
213 | thread_register_call_me(NULL, NULL); |
214 | spinlock_unlock(&rwl->lock); |
214 | spinlock_unlock(&rwl->lock); |
215 | case ESYNCH_TIMEOUT: |
215 | case ESYNCH_TIMEOUT: |
216 | case ESYNCH_INTERRUPTED: |
216 | case ESYNCH_INTERRUPTED: |
217 | /* |
217 | /* |
218 | * The sleep timed out. |
218 | * The sleep timed out. |
219 | * We just restore interrupt priority level. |
219 | * We just restore interrupt priority level. |
220 | */ |
220 | */ |
221 | case ESYNCH_OK_BLOCKED: |
221 | case ESYNCH_OK_BLOCKED: |
222 | /* |
222 | /* |
223 | * We were woken with rwl->readers_in already incremented. |
223 | * We were woken with rwl->readers_in already incremented. |
224 | * Note that this arrangement avoids race condition between |
224 | * Note that this arrangement avoids race condition between |
225 | * two concurrent readers. (Race is avoided if 'exclusive' is |
225 | * two concurrent readers. (Race is avoided if 'exclusive' is |
226 | * locked at the same time as 'readers_in' is incremented. |
226 | * locked at the same time as 'readers_in' is incremented. |
227 | * Same time means both events happen atomically when |
227 | * Same time means both events happen atomically when |
228 | * rwl->lock is held.) |
228 | * rwl->lock is held.) |
229 | */ |
229 | */ |
230 | interrupts_restore(ipl); |
230 | interrupts_restore(ipl); |
231 | break; |
231 | break; |
232 | case ESYNCH_OK_ATOMIC: |
232 | case ESYNCH_OK_ATOMIC: |
233 | panic("_mutex_lock_timeout()==ESYNCH_OK_ATOMIC\n"); |
233 | panic("_mutex_lock_timeout()==ESYNCH_OK_ATOMIC\n"); |
234 | break; |
234 | break; |
235 | default: |
235 | default: |
236 | panic("invalid ESYNCH\n"); |
236 | panic("invalid ESYNCH\n"); |
237 | break; |
237 | break; |
238 | } |
238 | } |
239 | return rc; |
239 | return rc; |
240 | } |
240 | } |
241 | 241 | ||
242 | shortcut: |
242 | shortcut: |