Rev 1248 | Rev 1702 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1248 | Rev 1502 | ||
---|---|---|---|
Line 87... | Line 87... | ||
87 | * Acquire reader/writer lock for reading. |
87 | * Acquire reader/writer lock for reading. |
88 | * Timeout and willingness to block may be specified. |
88 | * Timeout and willingness to block may be specified. |
89 | * |
89 | * |
90 | * @param rwl Reader/Writer lock. |
90 | * @param rwl Reader/Writer lock. |
91 | * @param usec Timeout in microseconds. |
91 | * @param usec Timeout in microseconds. |
92 | * @param trylock Switches between blocking and non-blocking mode. |
92 | * @param flags Specify mode of operation. |
93 | * |
93 | * |
94 | * For exact description of possible combinations of |
94 | * For exact description of possible combinations of |
95 | * @usec and @trylock, see comment for waitq_sleep_timeout(). |
95 | * usec and flags, see comment for waitq_sleep_timeout(). |
96 | * |
96 | * |
97 | * @return See comment for waitq_sleep_timeout(). |
97 | * @return See comment for waitq_sleep_timeout(). |
98 | */ |
98 | */ |
99 | int _rwlock_write_lock_timeout(rwlock_t *rwl, __u32 usec, int trylock) |
99 | int _rwlock_write_lock_timeout(rwlock_t *rwl, __u32 usec, int flags) |
100 | { |
100 | { |
101 | ipl_t ipl; |
101 | ipl_t ipl; |
102 | int rc; |
102 | int rc; |
103 | 103 | ||
104 | ipl = interrupts_disable(); |
104 | ipl = interrupts_disable(); |
Line 109... | Line 109... | ||
109 | 109 | ||
110 | /* |
110 | /* |
111 | * Writers take the easy part. |
111 | * Writers take the easy part. |
112 | * They just need to acquire the exclusive mutex. |
112 | * They just need to acquire the exclusive mutex. |
113 | */ |
113 | */ |
114 | rc = _mutex_lock_timeout(&rwl->exclusive, usec, trylock); |
114 | rc = _mutex_lock_timeout(&rwl->exclusive, usec, flags); |
115 | if (SYNCH_FAILED(rc)) { |
115 | if (SYNCH_FAILED(rc)) { |
116 | 116 | ||
117 | /* |
117 | /* |
118 | * Lock operation timed out. |
118 | * Lock operation timed out or was interrupted. |
119 | * The state of rwl is UNKNOWN at this point. |
119 | * The state of rwl is UNKNOWN at this point. |
120 | * No claims about its holder can be made. |
120 | * No claims about its holder can be made. |
121 | */ |
121 | */ |
122 | 122 | ||
123 | ipl = interrupts_disable(); |
123 | ipl = interrupts_disable(); |
Line 141... | Line 141... | ||
141 | * Acquire reader/writer lock for writing. |
141 | * Acquire reader/writer lock for writing. |
142 | * Timeout and willingness to block may be specified. |
142 | * Timeout and willingness to block may be specified. |
143 | * |
143 | * |
144 | * @param rwl Reader/Writer lock. |
144 | * @param rwl Reader/Writer lock. |
145 | * @param usec Timeout in microseconds. |
145 | * @param usec Timeout in microseconds. |
146 | * @param trylock Switches between blocking and non-blocking mode. |
146 | * @param flags Select mode of operation. |
147 | * |
147 | * |
148 | * For exact description of possible combinations of |
148 | * For exact description of possible combinations of |
149 | * usec and trylock, see comment for waitq_sleep_timeout(). |
149 | * usec and flags, see comment for waitq_sleep_timeout(). |
150 | * |
150 | * |
151 | * @return See comment for waitq_sleep_timeout(). |
151 | * @return See comment for waitq_sleep_timeout(). |
152 | */ |
152 | */ |
153 | int _rwlock_read_lock_timeout(rwlock_t *rwl, __u32 usec, int trylock) |
153 | int _rwlock_read_lock_timeout(rwlock_t *rwl, __u32 usec, int flags) |
154 | { |
154 | { |
155 | int rc; |
155 | int rc; |
156 | ipl_t ipl; |
156 | ipl_t ipl; |
157 | 157 | ||
158 | ipl = interrupts_disable(); |
158 | ipl = interrupts_disable(); |
Line 197... | Line 197... | ||
197 | thread_register_call_me(release_spinlock, &rwl->lock); |
197 | thread_register_call_me(release_spinlock, &rwl->lock); |
198 | #else |
198 | #else |
199 | thread_register_call_me(release_spinlock, NULL); |
199 | thread_register_call_me(release_spinlock, NULL); |
200 | #endif |
200 | #endif |
201 | 201 | ||
202 | rc = _mutex_lock_timeout(&rwl->exclusive, usec, trylock); |
202 | rc = _mutex_lock_timeout(&rwl->exclusive, usec, flags); |
203 | switch (rc) { |
203 | switch (rc) { |
204 | case ESYNCH_WOULD_BLOCK: |
204 | case ESYNCH_WOULD_BLOCK: |
205 | /* |
205 | /* |
206 | * release_spinlock() wasn't called |
206 | * release_spinlock() wasn't called |
207 | */ |
207 | */ |
208 | thread_register_call_me(NULL, NULL); |
208 | thread_register_call_me(NULL, NULL); |
209 | spinlock_unlock(&rwl->lock); |
209 | spinlock_unlock(&rwl->lock); |
210 | case ESYNCH_TIMEOUT: |
210 | case ESYNCH_TIMEOUT: |
- | 211 | case ESYNCH_INTERRUPTED: |
|
211 | /* |
212 | /* |
212 | * The sleep timeouted. |
213 | * The sleep timed out. |
213 | * We just restore interrupt priority level. |
214 | * We just restore interrupt priority level. |
214 | */ |
215 | */ |
215 | case ESYNCH_OK_BLOCKED: |
216 | case ESYNCH_OK_BLOCKED: |
216 | /* |
217 | /* |
217 | * We were woken with rwl->readers_in already incremented. |
218 | * We were woken with rwl->readers_in already incremented. |