Rev 68 | Rev 385 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 68 | Rev 153 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Reader/Writer locks |
- | |
3 | */ |
- | |
4 | - | ||
5 | /* |
- | |
6 | * Copyright (C) 2001-2004 Jakub Jermar |
2 | * Copyright (C) 2001-2004 Jakub Jermar |
7 | * All rights reserved. |
3 | * All rights reserved. |
8 | * |
4 | * |
9 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
10 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
11 | * are met: |
7 | * are met: |
12 | * |
8 | * |
13 | * - Redistributions of source code must retain the above copyright |
9 | * - Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. |
10 | * notice, this list of conditions and the following disclaimer. |
15 | * - Redistributions in binary form must reproduce the above copyright |
11 | * - Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in the |
12 | * notice, this list of conditions and the following disclaimer in the |
17 | * documentation and/or other materials provided with the distribution. |
13 | * documentation and/or other materials provided with the distribution. |
18 | * - The name of the author may not be used to endorse or promote products |
14 | * - The name of the author may not be used to endorse or promote products |
19 | * derived from this software without specific prior written permission. |
15 | * derived from this software without specific prior written permission. |
20 | * |
16 | * |
21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
22 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
23 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
24 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
26 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
30 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
31 | */ |
27 | */ |
- | 28 | ||
- | 29 | ||
- | 30 | /* |
|
- | 31 | * Reader/Writer locks |
|
- | 32 | */ |
|
32 | 33 | ||
33 | /* |
34 | /* |
34 | * These locks are not recursive. |
35 | * These locks are not recursive. |
35 | * Neither readers nor writers will suffer starvation. |
36 | * Neither readers nor writers will suffer starvation. |
36 | * |
37 | * |
37 | * If there is a writer followed by a reader waiting for the rwlock |
38 | * If there is a writer followed by a reader waiting for the rwlock |
38 | * and the writer times out, all leading readers are automatically woken up |
39 | * and the writer times out, all leading readers are automatically woken up |
39 | * and allowed in. |
40 | * and allowed in. |
40 | */ |
41 | */ |
41 | 42 | ||
42 | /* |
43 | /* |
43 | * NOTE ON rwlock_holder_type |
44 | * NOTE ON rwlock_holder_type |
44 | * This field is set on an attempt to acquire the exclusive mutex |
45 | * This field is set on an attempt to acquire the exclusive mutex |
45 | * to the respective value depending whether the caller is a reader |
46 | * to the respective value depending whether the caller is a reader |
46 | * or a writer. The field is examined only if the thread had been |
47 | * or a writer. The field is examined only if the thread had been |
47 | * previously blocked on the exclusive mutex. Thus it is save |
48 | * previously blocked on the exclusive mutex. Thus it is save |
48 | * to store the rwlock type in the thread structure, because |
49 | * to store the rwlock type in the thread structure, because |
49 | * each thread can block on only one rwlock at a time. |
50 | * each thread can block on only one rwlock at a time. |
50 | */ |
51 | */ |
51 | 52 | ||
52 | #include <synch/synch.h> |
53 | #include <synch/synch.h> |
53 | #include <synch/rwlock.h> |
54 | #include <synch/rwlock.h> |
54 | #include <synch/spinlock.h> |
55 | #include <synch/spinlock.h> |
55 | #include <synch/mutex.h> |
56 | #include <synch/mutex.h> |
56 | #include <synch/waitq.h> |
57 | #include <synch/waitq.h> |
57 | 58 | ||
58 | #include <list.h> |
59 | #include <list.h> |
59 | #include <typedefs.h> |
60 | #include <typedefs.h> |
60 | #include <arch/asm.h> |
61 | #include <arch/asm.h> |
61 | #include <arch.h> |
62 | #include <arch.h> |
62 | #include <proc/thread.h> |
63 | #include <proc/thread.h> |
63 | #include <panic.h> |
64 | #include <panic.h> |
64 | 65 | ||
65 | #define ALLOW_ALL 0 |
66 | #define ALLOW_ALL 0 |
66 | #define ALLOW_READERS_ONLY 1 |
67 | #define ALLOW_READERS_ONLY 1 |
67 | 68 | ||
68 | static void let_others_in(rwlock_t *rwl, int readers_only); |
69 | static void let_others_in(rwlock_t *rwl, int readers_only); |
69 | static void release_spinlock(void *arg); |
70 | static void release_spinlock(void *arg); |
70 | 71 | ||
71 | void rwlock_initialize(rwlock_t *rwl) { |
72 | void rwlock_initialize(rwlock_t *rwl) { |
72 | spinlock_initialize(&rwl->lock); |
73 | spinlock_initialize(&rwl->lock); |
73 | mutex_initialize(&rwl->exclusive); |
74 | mutex_initialize(&rwl->exclusive); |
74 | rwl->readers_in = 0; |
75 | rwl->readers_in = 0; |
75 | } |
76 | } |
76 | 77 | ||
77 | int _rwlock_write_lock_timeout(rwlock_t *rwl, __u32 usec, int trylock) |
78 | int _rwlock_write_lock_timeout(rwlock_t *rwl, __u32 usec, int trylock) |
78 | { |
79 | { |
79 | pri_t pri; |
80 | pri_t pri; |
80 | int rc; |
81 | int rc; |
81 | 82 | ||
82 | pri = cpu_priority_high(); |
83 | pri = cpu_priority_high(); |
83 | spinlock_lock(&THREAD->lock); |
84 | spinlock_lock(&THREAD->lock); |
84 | THREAD->rwlock_holder_type = RWLOCK_WRITER; |
85 | THREAD->rwlock_holder_type = RWLOCK_WRITER; |
85 | spinlock_unlock(&THREAD->lock); |
86 | spinlock_unlock(&THREAD->lock); |
86 | cpu_priority_restore(pri); |
87 | cpu_priority_restore(pri); |
87 | 88 | ||
88 | /* |
89 | /* |
89 | * Writers take the easy part. |
90 | * Writers take the easy part. |
90 | * They just need to acquire the exclusive mutex. |
91 | * They just need to acquire the exclusive mutex. |
91 | */ |
92 | */ |
92 | rc = _mutex_lock_timeout(&rwl->exclusive, usec, trylock); |
93 | rc = _mutex_lock_timeout(&rwl->exclusive, usec, trylock); |
93 | if (SYNCH_FAILED(rc)) { |
94 | if (SYNCH_FAILED(rc)) { |
94 | 95 | ||
95 | /* |
96 | /* |
96 | * Lock operation timed out. |
97 | * Lock operation timed out. |
97 | * The state of rwl is UNKNOWN at this point. |
98 | * The state of rwl is UNKNOWN at this point. |
98 | * No claims about its holder can be made. |
99 | * No claims about its holder can be made. |
99 | */ |
100 | */ |
100 | 101 | ||
101 | pri = cpu_priority_high(); |
102 | pri = cpu_priority_high(); |
102 | spinlock_lock(&rwl->lock); |
103 | spinlock_lock(&rwl->lock); |
103 | /* |
104 | /* |
104 | * Now when rwl is locked, we can inspect it again. |
105 | * Now when rwl is locked, we can inspect it again. |
105 | * If it is held by some readers already, we can let |
106 | * If it is held by some readers already, we can let |
106 | * readers from the head of the wait queue in. |
107 | * readers from the head of the wait queue in. |
107 | */ |
108 | */ |
108 | if (rwl->readers_in) |
109 | if (rwl->readers_in) |
109 | let_others_in(rwl, ALLOW_READERS_ONLY); |
110 | let_others_in(rwl, ALLOW_READERS_ONLY); |
110 | spinlock_unlock(&rwl->lock); |
111 | spinlock_unlock(&rwl->lock); |
111 | cpu_priority_restore(pri); |
112 | cpu_priority_restore(pri); |
112 | } |
113 | } |
113 | 114 | ||
114 | return rc; |
115 | return rc; |
115 | } |
116 | } |
116 | 117 | ||
117 | int _rwlock_read_lock_timeout(rwlock_t *rwl, __u32 usec, int trylock) |
118 | int _rwlock_read_lock_timeout(rwlock_t *rwl, __u32 usec, int trylock) |
118 | { |
119 | { |
119 | int rc; |
120 | int rc; |
120 | pri_t pri; |
121 | pri_t pri; |
121 | 122 | ||
122 | pri = cpu_priority_high(); |
123 | pri = cpu_priority_high(); |
123 | spinlock_lock(&THREAD->lock); |
124 | spinlock_lock(&THREAD->lock); |
124 | THREAD->rwlock_holder_type = RWLOCK_READER; |
125 | THREAD->rwlock_holder_type = RWLOCK_READER; |
125 | spinlock_unlock(&THREAD->lock); |
126 | spinlock_unlock(&THREAD->lock); |
126 | 127 | ||
127 | spinlock_lock(&rwl->lock); |
128 | spinlock_lock(&rwl->lock); |
128 | 129 | ||
129 | /* |
130 | /* |
130 | * Find out whether we can get what we want without blocking. |
131 | * Find out whether we can get what we want without blocking. |
131 | */ |
132 | */ |
132 | rc = mutex_trylock(&rwl->exclusive); |
133 | rc = mutex_trylock(&rwl->exclusive); |
133 | if (SYNCH_FAILED(rc)) { |
134 | if (SYNCH_FAILED(rc)) { |
134 | 135 | ||
135 | /* |
136 | /* |
136 | * 'exclusive' mutex is being held by someone else. |
137 | * 'exclusive' mutex is being held by someone else. |
137 | * If the holder is a reader and there is no one |
138 | * If the holder is a reader and there is no one |
138 | * else waiting for it, we can enter the critical |
139 | * else waiting for it, we can enter the critical |
139 | * section. |
140 | * section. |
140 | */ |
141 | */ |
141 | 142 | ||
142 | if (rwl->readers_in) { |
143 | if (rwl->readers_in) { |
143 | spinlock_lock(&rwl->exclusive.sem.wq.lock); |
144 | spinlock_lock(&rwl->exclusive.sem.wq.lock); |
144 | if (list_empty(&rwl->exclusive.sem.wq.head)) { |
145 | if (list_empty(&rwl->exclusive.sem.wq.head)) { |
145 | /* |
146 | /* |
146 | * We can enter. |
147 | * We can enter. |
147 | */ |
148 | */ |
148 | spinlock_unlock(&rwl->exclusive.sem.wq.lock); |
149 | spinlock_unlock(&rwl->exclusive.sem.wq.lock); |
149 | goto shortcut; |
150 | goto shortcut; |
150 | } |
151 | } |
151 | spinlock_unlock(&rwl->exclusive.sem.wq.lock); |
152 | spinlock_unlock(&rwl->exclusive.sem.wq.lock); |
152 | } |
153 | } |
153 | 154 | ||
154 | /* |
155 | /* |
155 | * In order to prevent a race condition when a reader |
156 | * In order to prevent a race condition when a reader |
156 | * could block another reader at the head of the waitq, |
157 | * could block another reader at the head of the waitq, |
157 | * we register a function to unlock rwl->lock |
158 | * we register a function to unlock rwl->lock |
158 | * after this thread is put asleep. |
159 | * after this thread is put asleep. |
159 | */ |
160 | */ |
160 | thread_register_call_me(release_spinlock, &rwl->lock); |
161 | thread_register_call_me(release_spinlock, &rwl->lock); |
161 | 162 | ||
162 | rc = _mutex_lock_timeout(&rwl->exclusive, usec, trylock); |
163 | rc = _mutex_lock_timeout(&rwl->exclusive, usec, trylock); |
163 | switch (rc) { |
164 | switch (rc) { |
164 | case ESYNCH_WOULD_BLOCK: |
165 | case ESYNCH_WOULD_BLOCK: |
165 | /* |
166 | /* |
166 | * release_spinlock() wasn't called |
167 | * release_spinlock() wasn't called |
167 | */ |
168 | */ |
168 | thread_register_call_me(NULL, NULL); |
169 | thread_register_call_me(NULL, NULL); |
169 | spinlock_unlock(&rwl->lock); |
170 | spinlock_unlock(&rwl->lock); |
170 | case ESYNCH_TIMEOUT: |
171 | case ESYNCH_TIMEOUT: |
171 | /* |
172 | /* |
172 | * The sleep timeouted. |
173 | * The sleep timeouted. |
173 | * We just restore the cpu priority. |
174 | * We just restore the cpu priority. |
174 | */ |
175 | */ |
175 | case ESYNCH_OK_BLOCKED: |
176 | case ESYNCH_OK_BLOCKED: |
176 | /* |
177 | /* |
177 | * We were woken with rwl->readers_in already incremented. |
178 | * We were woken with rwl->readers_in already incremented. |
178 | * Note that this arrangement avoids race condition between |
179 | * Note that this arrangement avoids race condition between |
179 | * two concurrent readers. (Race is avoided if 'exclusive' is |
180 | * two concurrent readers. (Race is avoided if 'exclusive' is |
180 | * locked at the same time as 'readers_in' is incremented. |
181 | * locked at the same time as 'readers_in' is incremented. |
181 | * Same time means both events happen atomically when |
182 | * Same time means both events happen atomically when |
182 | * rwl->lock is held.) |
183 | * rwl->lock is held.) |
183 | */ |
184 | */ |
184 | cpu_priority_restore(pri); |
185 | cpu_priority_restore(pri); |
185 | break; |
186 | break; |
186 | case ESYNCH_OK_ATOMIC: |
187 | case ESYNCH_OK_ATOMIC: |
187 | panic("_mutex_lock_timeout()==ESYNCH_OK_ATOMIC"); |
188 | panic("_mutex_lock_timeout()==ESYNCH_OK_ATOMIC"); |
188 | break; |
189 | break; |
189 | dafault: |
190 | dafault: |
190 | panic("invalid ESYNCH"); |
191 | panic("invalid ESYNCH"); |
191 | break; |
192 | break; |
192 | } |
193 | } |
193 | return rc; |
194 | return rc; |
194 | } |
195 | } |
195 | 196 | ||
196 | shortcut: |
197 | shortcut: |
197 | 198 | ||
198 | /* |
199 | /* |
199 | * We can increment readers_in only if we didn't go to sleep. |
200 | * We can increment readers_in only if we didn't go to sleep. |
200 | * For sleepers, rwlock_let_others_in() will do the job. |
201 | * For sleepers, rwlock_let_others_in() will do the job. |
201 | */ |
202 | */ |
202 | rwl->readers_in++; |
203 | rwl->readers_in++; |
203 | 204 | ||
204 | spinlock_unlock(&rwl->lock); |
205 | spinlock_unlock(&rwl->lock); |
205 | cpu_priority_restore(pri); |
206 | cpu_priority_restore(pri); |
206 | 207 | ||
207 | return ESYNCH_OK_ATOMIC; |
208 | return ESYNCH_OK_ATOMIC; |
208 | } |
209 | } |
209 | 210 | ||
210 | void rwlock_write_unlock(rwlock_t *rwl) |
211 | void rwlock_write_unlock(rwlock_t *rwl) |
211 | { |
212 | { |
212 | pri_t pri; |
213 | pri_t pri; |
213 | 214 | ||
214 | pri = cpu_priority_high(); |
215 | pri = cpu_priority_high(); |
215 | spinlock_lock(&rwl->lock); |
216 | spinlock_lock(&rwl->lock); |
216 | let_others_in(rwl, ALLOW_ALL); |
217 | let_others_in(rwl, ALLOW_ALL); |
217 | spinlock_unlock(&rwl->lock); |
218 | spinlock_unlock(&rwl->lock); |
218 | cpu_priority_restore(pri); |
219 | cpu_priority_restore(pri); |
219 | 220 | ||
220 | } |
221 | } |
221 | 222 | ||
222 | void rwlock_read_unlock(rwlock_t *rwl) |
223 | void rwlock_read_unlock(rwlock_t *rwl) |
223 | { |
224 | { |
224 | pri_t pri; |
225 | pri_t pri; |
225 | 226 | ||
226 | pri = cpu_priority_high(); |
227 | pri = cpu_priority_high(); |
227 | spinlock_lock(&rwl->lock); |
228 | spinlock_lock(&rwl->lock); |
228 | if (!--rwl->readers_in) |
229 | if (!--rwl->readers_in) |
229 | let_others_in(rwl, ALLOW_ALL); |
230 | let_others_in(rwl, ALLOW_ALL); |
230 | spinlock_unlock(&rwl->lock); |
231 | spinlock_unlock(&rwl->lock); |
231 | cpu_priority_restore(pri); |
232 | cpu_priority_restore(pri); |
232 | } |
233 | } |
233 | 234 | ||
234 | 235 | ||
235 | /* |
236 | /* |
236 | * Must be called with rwl->lock locked. |
237 | * Must be called with rwl->lock locked. |
237 | * Must be called with cpu_priority_high'ed. |
238 | * Must be called with cpu_priority_high'ed. |
238 | */ |
239 | */ |
239 | /* |
240 | /* |
240 | * If readers_only is false: (unlock scenario) |
241 | * If readers_only is false: (unlock scenario) |
241 | * Let the first sleeper on 'exclusive' mutex in, no matter |
242 | * Let the first sleeper on 'exclusive' mutex in, no matter |
242 | * whether it is a reader or a writer. If there are more leading |
243 | * whether it is a reader or a writer. If there are more leading |
243 | * readers in line, let each of them in. |
244 | * readers in line, let each of them in. |
244 | * |
245 | * |
245 | * Otherwise: (timeout scenario) |
246 | * Otherwise: (timeout scenario) |
246 | * Let all leading readers in. |
247 | * Let all leading readers in. |
247 | */ |
248 | */ |
248 | void let_others_in(rwlock_t *rwl, int readers_only) |
249 | void let_others_in(rwlock_t *rwl, int readers_only) |
249 | { |
250 | { |
250 | rwlock_type_t type = RWLOCK_NONE; |
251 | rwlock_type_t type = RWLOCK_NONE; |
251 | thread_t *t = NULL; |
252 | thread_t *t = NULL; |
252 | int one_more = 1; |
253 | int one_more = 1; |
253 | 254 | ||
254 | spinlock_lock(&rwl->exclusive.sem.wq.lock); |
255 | spinlock_lock(&rwl->exclusive.sem.wq.lock); |
255 | 256 | ||
256 | if (!list_empty(&rwl->exclusive.sem.wq.head)) |
257 | if (!list_empty(&rwl->exclusive.sem.wq.head)) |
257 | t = list_get_instance(rwl->exclusive.sem.wq.head.next, thread_t, wq_link); |
258 | t = list_get_instance(rwl->exclusive.sem.wq.head.next, thread_t, wq_link); |
258 | do { |
259 | do { |
259 | if (t) { |
260 | if (t) { |
260 | spinlock_lock(&t->lock); |
261 | spinlock_lock(&t->lock); |
261 | type = t->rwlock_holder_type; |
262 | type = t->rwlock_holder_type; |
262 | spinlock_unlock(&t->lock); |
263 | spinlock_unlock(&t->lock); |
263 | } |
264 | } |
264 | 265 | ||
265 | /* |
266 | /* |
266 | * If readers_only is true, we wake all leading readers |
267 | * If readers_only is true, we wake all leading readers |
267 | * if and only if rwl is locked by another reader. |
268 | * if and only if rwl is locked by another reader. |
268 | * Assumption: readers_only ==> rwl->readers_in |
269 | * Assumption: readers_only ==> rwl->readers_in |
269 | */ |
270 | */ |
270 | if (readers_only && (type != RWLOCK_READER)) |
271 | if (readers_only && (type != RWLOCK_READER)) |
271 | break; |
272 | break; |
272 | 273 | ||
273 | 274 | ||
274 | if (type == RWLOCK_READER) { |
275 | if (type == RWLOCK_READER) { |
275 | /* |
276 | /* |
276 | * Waking up a reader. |
277 | * Waking up a reader. |
277 | * We are responsible for incrementing rwl->readers_in for it. |
278 | * We are responsible for incrementing rwl->readers_in for it. |
278 | */ |
279 | */ |
279 | rwl->readers_in++; |
280 | rwl->readers_in++; |
280 | } |
281 | } |
281 | 282 | ||
282 | /* |
283 | /* |
283 | * Only the last iteration through this loop can increment |
284 | * Only the last iteration through this loop can increment |
284 | * rwl->exclusive.sem.wq.missed_wakeup's. All preceeding |
285 | * rwl->exclusive.sem.wq.missed_wakeup's. All preceeding |
285 | * iterations will wake up a thread. |
286 | * iterations will wake up a thread. |
286 | */ |
287 | */ |
287 | /* We call the internal version of waitq_wakeup, which |
288 | /* We call the internal version of waitq_wakeup, which |
288 | * relies on the fact that the waitq is already locked. |
289 | * relies on the fact that the waitq is already locked. |
289 | */ |
290 | */ |
290 | _waitq_wakeup_unsafe(&rwl->exclusive.sem.wq, WAKEUP_FIRST); |
291 | _waitq_wakeup_unsafe(&rwl->exclusive.sem.wq, WAKEUP_FIRST); |
291 | 292 | ||
292 | t = NULL; |
293 | t = NULL; |
293 | if (!list_empty(&rwl->exclusive.sem.wq.head)) { |
294 | if (!list_empty(&rwl->exclusive.sem.wq.head)) { |
294 | t = list_get_instance(rwl->exclusive.sem.wq.head.next, thread_t, wq_link); |
295 | t = list_get_instance(rwl->exclusive.sem.wq.head.next, thread_t, wq_link); |
295 | if (t) { |
296 | if (t) { |
296 | spinlock_lock(&t->lock); |
297 | spinlock_lock(&t->lock); |
297 | if (t->rwlock_holder_type != RWLOCK_READER) |
298 | if (t->rwlock_holder_type != RWLOCK_READER) |
298 | one_more = 0; |
299 | one_more = 0; |
299 | spinlock_unlock(&t->lock); |
300 | spinlock_unlock(&t->lock); |
300 | } |
301 | } |
301 | } |
302 | } |
302 | } while ((type == RWLOCK_READER) && t && one_more); |
303 | } while ((type == RWLOCK_READER) && t && one_more); |
303 | 304 | ||
304 | spinlock_unlock(&rwl->exclusive.sem.wq.lock); |
305 | spinlock_unlock(&rwl->exclusive.sem.wq.lock); |
305 | } |
306 | } |
306 | 307 | ||
307 | void release_spinlock(void *arg) |
308 | void release_spinlock(void *arg) |
308 | { |
309 | { |
309 | spinlock_unlock((spinlock_t *) arg); |
310 | spinlock_unlock((spinlock_t *) arg); |
310 | } |
311 | } |
311 | 312 |