Lines Matching refs:rrl

84 rrn_find(rrwlock_t *rrl)
88 if (refcount_count(&rrl->rr_linked_rcount) == 0)
92 if (rn->rn_rrl == rrl)
102 rrn_add(rrwlock_t *rrl, void *tag)
107 rn->rn_rrl = rrl;
114 * If a node is found for 'rrl', then remove the node from this
118 rrn_find_and_remove(rrwlock_t *rrl, void *tag)
123 if (refcount_count(&rrl->rr_linked_rcount) == 0)
127 if (rn->rn_rrl == rrl && rn->rn_tag == tag) {
141 rrw_init(rrwlock_t *rrl, boolean_t track_all)
143 mutex_init(&rrl->rr_lock, NULL, MUTEX_DEFAULT, NULL);
144 cv_init(&rrl->rr_cv, NULL, CV_DEFAULT, NULL);
145 rrl->rr_writer = NULL;
146 refcount_create(&rrl->rr_anon_rcount);
147 refcount_create(&rrl->rr_linked_rcount);
148 rrl->rr_writer_wanted = B_FALSE;
149 rrl->rr_track_all = track_all;
153 rrw_destroy(rrwlock_t *rrl)
155 mutex_destroy(&rrl->rr_lock);
156 cv_destroy(&rrl->rr_cv);
157 ASSERT(rrl->rr_writer == NULL);
158 refcount_destroy(&rrl->rr_anon_rcount);
159 refcount_destroy(&rrl->rr_linked_rcount);
163 rrw_enter_read_impl(rrwlock_t *rrl, boolean_t prio, void *tag)
165 mutex_enter(&rrl->rr_lock);
167 if (rrl->rr_writer == NULL && !rrl->rr_writer_wanted &&
168 !rrl->rr_track_all) {
169 rrl->rr_anon_rcount.rc_count++;
170 mutex_exit(&rrl->rr_lock);
175 ASSERT(rrl->rr_writer != curthread);
176 ASSERT(refcount_count(&rrl->rr_anon_rcount) >= 0);
178 while (rrl->rr_writer != NULL || (rrl->rr_writer_wanted &&
179 refcount_is_zero(&rrl->rr_anon_rcount) && !prio &&
180 rrn_find(rrl) == NULL))
181 cv_wait(&rrl->rr_cv, &rrl->rr_lock);
183 if (rrl->rr_writer_wanted || rrl->rr_track_all) {
185 rrn_add(rrl, tag);
186 (void) refcount_add(&rrl->rr_linked_rcount, tag);
188 (void) refcount_add(&rrl->rr_anon_rcount, tag);
190 ASSERT(rrl->rr_writer == NULL);
191 mutex_exit(&rrl->rr_lock);
195 rrw_enter_read(rrwlock_t *rrl, void *tag)
197 rrw_enter_read_impl(rrl, B_FALSE, tag);
207 rrw_enter_read_prio(rrwlock_t *rrl, void *tag)
209 rrw_enter_read_impl(rrl, B_TRUE, tag);
214 rrw_enter_write(rrwlock_t *rrl)
216 mutex_enter(&rrl->rr_lock);
217 ASSERT(rrl->rr_writer != curthread);
219 while (refcount_count(&rrl->rr_anon_rcount) > 0 ||
220 refcount_count(&rrl->rr_linked_rcount) > 0 ||
221 rrl->rr_writer != NULL) {
222 rrl->rr_writer_wanted = B_TRUE;
223 cv_wait(&rrl->rr_cv, &rrl->rr_lock);
225 rrl->rr_writer_wanted = B_FALSE;
226 rrl->rr_writer = curthread;
227 mutex_exit(&rrl->rr_lock);
231 rrw_enter(rrwlock_t *rrl, krw_t rw, void *tag)
234 rrw_enter_read(rrl, tag);
236 rrw_enter_write(rrl);
240 rrw_exit(rrwlock_t *rrl, void *tag)
242 mutex_enter(&rrl->rr_lock);
244 if (!rrl->rr_writer && rrl->rr_linked_rcount.rc_count == 0) {
245 rrl->rr_anon_rcount.rc_count--;
246 if (rrl->rr_anon_rcount.rc_count == 0)
247 cv_broadcast(&rrl->rr_cv);
248 mutex_exit(&rrl->rr_lock);
253 ASSERT(!refcount_is_zero(&rrl->rr_anon_rcount) ||
254 !refcount_is_zero(&rrl->rr_linked_rcount) ||
255 rrl->rr_writer != NULL);
257 if (rrl->rr_writer == NULL) {
259 if (rrn_find_and_remove(rrl, tag)) {
260 count = refcount_remove(&rrl->rr_linked_rcount, tag);
262 ASSERT(!rrl->rr_track_all);
263 count = refcount_remove(&rrl->rr_anon_rcount, tag);
266 cv_broadcast(&rrl->rr_cv);
268 ASSERT(rrl->rr_writer == curthread);
269 ASSERT(refcount_is_zero(&rrl->rr_anon_rcount) &&
270 refcount_is_zero(&rrl->rr_linked_rcount));
271 rrl->rr_writer = NULL;
272 cv_broadcast(&rrl->rr_cv);
274 mutex_exit(&rrl->rr_lock);
283 rrw_held(rrwlock_t *rrl, krw_t rw)
287 mutex_enter(&rrl->rr_lock);
289 held = (rrl->rr_writer == curthread);
291 held = (!refcount_is_zero(&rrl->rr_anon_rcount) ||
292 rrn_find(rrl) != NULL);
294 mutex_exit(&rrl->rr_lock);
323 rrm_init(rrmlock_t *rrl, boolean_t track_all)
328 rrw_init(&rrl->locks[i], track_all);
332 rrm_destroy(rrmlock_t *rrl)
337 rrw_destroy(&rrl->locks[i]);
341 rrm_enter(rrmlock_t *rrl, krw_t rw, void *tag)
344 rrm_enter_read(rrl, tag);
346 rrm_enter_write(rrl);
360 rrm_enter_read(rrmlock_t *rrl, void *tag)
362 rrw_enter_read(&rrl->locks[RRM_TD_LOCK()], tag);
366 rrm_enter_write(rrmlock_t *rrl)
371 rrw_enter_write(&rrl->locks[i]);
375 rrm_exit(rrmlock_t *rrl, void *tag)
379 if (rrl->locks[0].rr_writer == curthread) {
381 rrw_exit(&rrl->locks[i], tag);
383 rrw_exit(&rrl->locks[RRM_TD_LOCK()], tag);
388 rrm_held(rrmlock_t *rrl, krw_t rw)
391 return (rrw_held(&rrl->locks[0], rw));
393 return (rrw_held(&rrl->locks[RRM_TD_LOCK()], rw));