Lines Matching refs:l

61 rwst_enter_common(rwstlock_t *l, krw_t rw, int flags)  in rwst_enter_common()  argument
67 mutex_enter(&l->rwst_lock); in rwst_enter_common()
69 while (RWST_WRITE_HELD(l) || in rwst_enter_common()
70 (rw != RW_READER_STARVEWRITER && RWST_WRITE_WANTED(l))) { in rwst_enter_common()
73 mutex_exit(&l->rwst_lock); in rwst_enter_common()
79 if (RWST_WRITE_HELD(l)) { in rwst_enter_common()
84 readers = l->rwst_count; in rwst_enter_common()
87 if (!RWST_READ_WAIT(l, flags)) { in rwst_enter_common()
88 mutex_exit(&l->rwst_lock); in rwst_enter_common()
92 LOCKSTAT_RECORD4(LS_RW_ENTER_BLOCK, l, sleep_time, rw, in rwst_enter_common()
95 RWST_READ_ENTER(l); in rwst_enter_common()
96 LOCKSTAT_RECORD(LS_RW_ENTER_ACQUIRE, l, rw); in rwst_enter_common()
99 while (RWST_HELD(l)) { in rwst_enter_common()
101 mutex_exit(&l->rwst_lock); in rwst_enter_common()
106 if (RWST_WRITE_HELD(l)) { in rwst_enter_common()
111 readers = l->rwst_count; in rwst_enter_common()
114 if (!RWST_WRITE_WAIT(l, flags)) { in rwst_enter_common()
115 if (!RWST_WRITE_HELD(l) && in rwst_enter_common()
116 !RWST_WRITE_WANTED(l)) in rwst_enter_common()
117 RWST_READ_WAKE_ALL(l); in rwst_enter_common()
118 mutex_exit(&l->rwst_lock); in rwst_enter_common()
122 LOCKSTAT_RECORD4(LS_RW_ENTER_BLOCK, l, sleep_time, rw, in rwst_enter_common()
125 RWST_WRITE_ENTER(l); in rwst_enter_common()
126 LOCKSTAT_RECORD(LS_RW_ENTER_ACQUIRE, l, rw); in rwst_enter_common()
128 mutex_exit(&l->rwst_lock); in rwst_enter_common()
133 rwst_exit(rwstlock_t *l) in rwst_exit() argument
135 mutex_enter(&l->rwst_lock); in rwst_exit()
136 if (RWST_WRITE_HELD(l)) { in rwst_exit()
137 LOCKSTAT_RECORD(LS_RW_EXIT_RELEASE, l, RW_WRITER); in rwst_exit()
138 RWST_WRITE_EXIT(l); in rwst_exit()
140 ASSERT(RWST_READ_HELD(l)); in rwst_exit()
141 LOCKSTAT_RECORD(LS_RW_EXIT_RELEASE, l, RW_READER); in rwst_exit()
142 RWST_READ_EXIT(l); in rwst_exit()
144 if (!RWST_WRITE_WANTED(l)) in rwst_exit()
145 RWST_READ_WAKE_ALL(l); in rwst_exit()
146 else if (!RWST_HELD(l)) in rwst_exit()
147 RWST_WRITE_WAKE_ONE(l); in rwst_exit()
148 mutex_exit(&l->rwst_lock); in rwst_exit()
152 rwst_enter(rwstlock_t *l, krw_t rw) in rwst_enter() argument
154 (void) rwst_enter_common(l, rw, 0); in rwst_enter()
158 rwst_enter_sig(rwstlock_t *l, krw_t rw) in rwst_enter_sig() argument
160 return (rwst_enter_common(l, rw, RWST_SIG)); in rwst_enter_sig()
164 rwst_tryenter(rwstlock_t *l, krw_t rw) in rwst_tryenter() argument
166 return (rwst_enter_common(l, rw, RWST_TRYENTER)); in rwst_tryenter()
170 rwst_lock_held(rwstlock_t *l, krw_t rw) in rwst_lock_held() argument
173 return (RWST_READ_HELD(l)); in rwst_lock_held()
175 return (RWST_WRITE_OWNER(l)); in rwst_lock_held()
180 rwst_init(rwstlock_t *l, char *name, krw_type_t krw_t, void *arg) in rwst_init() argument
182 l->rwst_count = 0; in rwst_init()
183 mutex_init(&l->rwst_lock, NULL, MUTEX_DEFAULT, NULL); in rwst_init()
184 cv_init(&l->rwst_rcv, NULL, CV_DEFAULT, NULL); in rwst_init()
185 cv_init(&l->rwst_wcv, NULL, CV_DEFAULT, NULL); in rwst_init()
189 rwst_destroy(rwstlock_t *l) in rwst_destroy() argument
191 ASSERT(l->rwst_count == 0); in rwst_destroy()
192 mutex_destroy(&l->rwst_lock); in rwst_destroy()
193 cv_destroy(&l->rwst_rcv); in rwst_destroy()
194 cv_destroy(&l->rwst_wcv); in rwst_destroy()
198 rwst_owner(rwstlock_t *l) in rwst_owner() argument
200 return (RWST_OWNER(l)); in rwst_owner()