Lines Matching refs:p
41 static void mutex_cleanup(struct mutex_info* p);
42 static Bool mutex_is_locked(struct mutex_info* const p);
43 static void mutex_delete_thread(struct mutex_info* p, const DrdThreadId tid);
68 void DRD_(mutex_initialize)(struct mutex_info* const p, in DRD_()
72 tl_assert(p->a1 == mutex); in DRD_()
74 p->cleanup = (void(*)(DrdClientobj*))mutex_cleanup; in DRD_()
75 p->delete_thread in DRD_()
77 p->mutex_type = mutex_type; in DRD_()
78 p->recursion_count = 0; in DRD_()
79 p->ignore_ordering = False; in DRD_()
80 p->owner = DRD_INVALID_THREADID; in DRD_()
81 p->last_locked_segment = 0; in DRD_()
82 p->acquiry_time_ms = 0; in DRD_()
83 p->acquired_at = 0; in DRD_()
88 struct mutex_info* p = DRD_(mutex_get)(mutex); in DRD_() local
93 p ? DRD_(mutex_type_name)(p->mutex_type) : "(?)", in DRD_()
96 if (p) { in DRD_()
97 p->ignore_ordering = True; in DRD_()
104 static void mutex_cleanup(struct mutex_info* p) in mutex_cleanup() argument
106 tl_assert(p); in mutex_cleanup()
111 DRD_(mutex_get_typename)(p), p->a1, in mutex_cleanup()
112 p ? p->recursion_count : -1, in mutex_cleanup()
113 p ? p->owner : DRD_INVALID_THREADID); in mutex_cleanup()
115 if (mutex_is_locked(p)) in mutex_cleanup()
118 p->a1, p->recursion_count, p->owner }; in mutex_cleanup()
126 DRD_(sg_put)(p->last_locked_segment); in mutex_cleanup()
127 p->last_locked_segment = 0; in mutex_cleanup()
161 struct mutex_info* p; in DRD_() local
164 p = &(DRD_(clientobj_get)(mutex, ClientMutex)->mutex); in DRD_()
165 if (p) in DRD_()
167 if (mutex_type == mutex_type_unknown || p->mutex_type == mutex_type) in DRD_()
168 return p; in DRD_()
182 p = &(DRD_(clientobj_add)(mutex, ClientMutex)->mutex); in DRD_()
183 DRD_(mutex_initialize)(p, mutex, mutex_type); in DRD_()
184 return p; in DRD_()
197 struct mutex_info* p; in DRD_() local
211 p = DRD_(mutex_get)(mutex); in DRD_()
212 if (p) in DRD_()
216 p->a1, p->recursion_count, p->owner }; in DRD_()
222 p->mutex_type = mutex_type; in DRD_()
223 return p; in DRD_()
225 p = DRD_(mutex_get_or_allocate)(mutex, mutex_type); in DRD_()
227 return p; in DRD_()
233 struct mutex_info* p; in DRD_() local
235 p = DRD_(mutex_get)(mutex); in DRD_()
236 if (p == 0) in DRD_()
254 struct mutex_info* p; in DRD_() local
256 p = DRD_(mutex_get_or_allocate)(mutex, mutex_type); in DRD_()
257 if (p && mutex_type == mutex_type_unknown) in DRD_()
258 mutex_type = p->mutex_type; in DRD_()
264 p ? DRD_(mutex_get_typename)(p) : "(?)", in DRD_()
265 mutex, p ? p->recursion_count : -1, in DRD_()
266 p ? p->owner : DRD_INVALID_THREADID); in DRD_()
268 if (p == 0) in DRD_()
274 tl_assert(p); in DRD_()
283 && p->owner == DRD_(thread_get_running_tid)() in DRD_()
284 && p->recursion_count >= 1 in DRD_()
288 p->a1, p->recursion_count, p->owner }; in DRD_()
306 struct mutex_info* p; in DRD_() local
308 p = DRD_(mutex_get)(mutex); in DRD_()
314 p ? DRD_(mutex_get_typename)(p) : "(?)", in DRD_()
315 mutex, p ? p->recursion_count : 0, in DRD_()
316 p ? p->owner : VG_INVALID_THREADID, in DRD_()
319 if (! p || ! took_lock) in DRD_()
322 if (p->recursion_count == 0) { in DRD_()
323 if (!p->ignore_ordering) { in DRD_()
324 if (p->owner != drd_tid && p->owner != DRD_INVALID_THREADID) { in DRD_()
325 tl_assert(p->last_locked_segment); in DRD_()
328 p->last_locked_segment); in DRD_()
336 p->owner = drd_tid; in DRD_()
337 p->acquiry_time_ms = VG_(read_millisecond_timer)(); in DRD_()
338 p->acquired_at = VG_(record_ExeContext)(VG_(get_running_tid)(), 0); in DRD_()
340 } else if (p->owner != drd_tid) { in DRD_()
343 p->a1, p->recursion_count, p->owner }; in DRD_()
350 p->owner = drd_tid; in DRD_()
352 p->recursion_count++; in DRD_()
370 struct mutex_info* p; in DRD_() local
372 p = DRD_(mutex_get)(mutex); in DRD_()
373 if (p && mutex_type == mutex_type_unknown) in DRD_()
374 mutex_type = p->mutex_type; in DRD_()
378 drd_tid, p ? DRD_(mutex_get_typename)(p) : "(?)", in DRD_()
379 mutex, p ? p->recursion_count : 0); in DRD_()
382 if (p == 0 || mutex_type == mutex_type_invalid_mutex) in DRD_()
388 if (p->owner == DRD_INVALID_THREADID) in DRD_()
391 p->a1, p->recursion_count, p->owner }; in DRD_()
400 tl_assert(p); in DRD_()
401 if (p->mutex_type != mutex_type) { in DRD_()
403 p->a1, p->recursion_count, p->owner }; in DRD_()
407 tl_assert(p->mutex_type == mutex_type); in DRD_()
408 tl_assert(p->owner != DRD_INVALID_THREADID); in DRD_()
410 if (p->owner != drd_tid || p->recursion_count <= 0) in DRD_()
413 p->a1, p->recursion_count, p->owner }; in DRD_()
421 tl_assert(p->recursion_count > 0); in DRD_()
422 p->recursion_count--; in DRD_()
423 tl_assert(p->recursion_count >= 0); in DRD_()
425 if (p->recursion_count == 0) in DRD_()
429 Long held = VG_(read_millisecond_timer)() - p->acquiry_time_ms; in DRD_()
434 mutex, p->acquired_at, held, s_mutex_lock_threshold_ms }; in DRD_()
447 DRD_(thread_get_latest_segment)(&p->last_locked_segment, drd_tid); in DRD_()
448 if (!p->ignore_ordering) in DRD_()
450 p->acquired_at = 0; in DRD_()
468 const HChar* DRD_(mutex_get_typename)(struct mutex_info* const p) in DRD_()
470 tl_assert(p); in DRD_()
472 return DRD_(mutex_type_name)(p->mutex_type); in DRD_()
499 static Bool mutex_is_locked(struct mutex_info* const p) in mutex_is_locked() argument
501 tl_assert(p); in mutex_is_locked()
502 return (p->recursion_count > 0); in mutex_is_locked()
507 struct mutex_info* const p = DRD_(mutex_get)(mutex); in DRD_() local
508 if (p) in DRD_()
510 return (p->recursion_count > 0 && p->owner == tid); in DRD_()
517 struct mutex_info* const p = DRD_(mutex_get)(mutex); in DRD_() local
518 tl_assert(p); in DRD_()
519 return p->recursion_count; in DRD_()
526 static void mutex_delete_thread(struct mutex_info* p, const DrdThreadId tid) in mutex_delete_thread() argument
528 tl_assert(p); in mutex_delete_thread()
530 if (p->owner == tid && p->recursion_count > 0) in mutex_delete_thread()
533 p->a1, p->recursion_count, p->owner }; in mutex_delete_thread()
539 p->owner = VG_INVALID_THREADID; in mutex_delete_thread()