Lines Matching +full:lock +full:- +full:status

2  * Copyright 2013-2015 Samy Al Bahra.
33 * non-TSO architectures with TM support.
41 * skip_-prefixed counters represent the number of consecutive
42 * elisions to forfeit. retry_-prefixed counters represent the
45 * _busy: Lock was busy
97 unsigned int status) in _ck_elide_fallback() argument
100 st->n_fallback++; in _ck_elide_fallback()
104 if (st->skip != 0) in _ck_elide_fallback()
107 if (status & CK_PR_RTM_EXPLICIT) { in _ck_elide_fallback()
108 if (CK_PR_RTM_CODE(status) == CK_ELIDE_LOCK_BUSY) { in _ck_elide_fallback()
109 st->skip = c->skip_busy; in _ck_elide_fallback()
110 *retry = c->retry_busy; in _ck_elide_fallback()
114 st->skip = c->skip_other; in _ck_elide_fallback()
118 if ((status & CK_PR_RTM_RETRY) && in _ck_elide_fallback()
119 (status & CK_PR_RTM_CONFLICT)) { in _ck_elide_fallback()
120 st->skip = c->skip_conflict; in _ck_elide_fallback()
121 *retry = c->retry_conflict; in _ck_elide_fallback()
130 st->skip = USHRT_MAX; in _ck_elide_fallback()
136 * N - Namespace of elision implementation.
137 * T - Typename of mutex.
138 * L_P - Lock predicate, returns false if resource is available.
139 * L - Function to call if resource is unavailable of transaction aborts.
140 * U_P - Unlock predicate, returns false if elision failed.
141 * U - Function to call if transaction failed.
145 ck_elide_##N##_lock_adaptive(T *lock, \
152 if (CK_CC_UNLIKELY(st->skip != 0)) { \
153 st->skip--; \
157 retry = c->retry_conflict; \
159 unsigned int status = ck_pr_rtm_begin(); \
160 if (status == CK_PR_RTM_STARTED) { \
161 if (L_P(lock) == true) \
167 hint = _ck_elide_fallback(&retry, st, c, status); \
172 while (--retry != 0) { \
173 if (L_P(lock) == false) \
184 } while (CK_CC_LIKELY(--retry > 0)); \
187 L(lock); \
191 ck_elide_##N##_unlock_adaptive(struct ck_elide_stat *st, T *lock) \
194 if (U_P(lock) == false) { \
196 st->skip = 0; \
197 st->n_elide++; \
199 U(lock); \
205 ck_elide_##N##_lock(T *lock) \
209 L(lock); \
213 if (L_P(lock) == true) \
219 ck_elide_##N##_unlock(T *lock) \
222 if (U_P(lock) == false) { \
225 U(lock); \
233 ck_elide_##N##_trylock(T *lock) \
239 if (TL_P(lock) == true) \
247 * elision wrappers directly calls into the user-specified lock operations.
249 * are paid (typically a storage cost that is a function of lock objects and
254 ck_elide_##N##_lock_adaptive(T *lock, \
261 L(lock); \
266 T *lock) \
270 U(lock); \
274 ck_elide_##N##_lock(T *lock) \
277 L(lock); \
281 ck_elide_##N##_unlock(T *lock) \
284 U(lock); \
290 ck_elide_##N##_trylock(T *lock) \
293 return TL_P(lock); \
298 * Best-effort elision lock operations. First argument is name (N)
306 #define CK_ELIDE_LOCK(NAME, LOCK) ck_elide_##NAME##_lock(LOCK) argument
307 #define CK_ELIDE_UNLOCK(NAME, LOCK) ck_elide_##NAME##_unlock(LOCK) argument
308 #define CK_ELIDE_TRYLOCK(NAME, LOCK) ck_elide_##NAME##_trylock(LOCK) argument
311 * Adaptive elision lock operations. In addition to name and pointer
312 * to the lock, you must pass in a pointer to an initialized
313 * ck_elide_config structure along with a per-thread stat structure.
315 #define CK_ELIDE_LOCK_ADAPTIVE(NAME, STAT, CONFIG, LOCK) \ argument
316 ck_elide_##NAME##_lock_adaptive(LOCK, STAT, CONFIG)
318 #define CK_ELIDE_UNLOCK_ADAPTIVE(NAME, STAT, LOCK) \ argument
319 ck_elide_##NAME##_unlock_adaptive(STAT, LOCK)