Lines Matching refs:p
42 static void mutex_cleanup(struct mutex_info* p);
43 static Bool mutex_is_locked(struct mutex_info* const p);
44 static void mutex_delete_thread(struct mutex_info* p, const DrdThreadId tid);
69 void DRD_(mutex_initialize)(struct mutex_info* const p, in DRD_()
73 tl_assert(p->a1 == mutex); in DRD_()
75 p->cleanup = (void(*)(DrdClientobj*))mutex_cleanup; in DRD_()
76 p->delete_thread in DRD_()
78 p->mutex_type = mutex_type; in DRD_()
79 p->recursion_count = 0; 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_()
87 static void mutex_cleanup(struct mutex_info* p) in mutex_cleanup() argument
89 tl_assert(p); in mutex_cleanup()
94 DRD_(mutex_get_typename)(p), p->a1, in mutex_cleanup()
95 p ? p->recursion_count : -1, in mutex_cleanup()
96 p ? p->owner : DRD_INVALID_THREADID); in mutex_cleanup()
98 if (mutex_is_locked(p)) in mutex_cleanup()
101 p->a1, p->recursion_count, p->owner }; in mutex_cleanup()
109 DRD_(sg_put)(p->last_locked_segment); in mutex_cleanup()
110 p->last_locked_segment = 0; in mutex_cleanup()
144 struct mutex_info* p; in DRD_() local
147 p = &(DRD_(clientobj_get)(mutex, ClientMutex)->mutex); in DRD_()
148 if (p) in DRD_()
150 if (mutex_type == mutex_type_unknown || p->mutex_type == mutex_type) in DRD_()
151 return p; in DRD_()
165 p = &(DRD_(clientobj_add)(mutex, ClientMutex)->mutex); in DRD_()
166 DRD_(mutex_initialize)(p, mutex, mutex_type); in DRD_()
167 return p; in DRD_()
180 struct mutex_info* p; in DRD_() local
194 p = DRD_(mutex_get)(mutex); in DRD_()
195 if (p) in DRD_()
199 p->a1, p->recursion_count, p->owner }; in DRD_()
205 p->mutex_type = mutex_type; in DRD_()
206 return p; in DRD_()
208 p = DRD_(mutex_get_or_allocate)(mutex, mutex_type); in DRD_()
210 return p; in DRD_()
216 struct mutex_info* p; in DRD_() local
218 p = DRD_(mutex_get)(mutex); in DRD_()
219 if (p == 0) in DRD_()
237 struct mutex_info* p; in DRD_() local
239 p = DRD_(mutex_get_or_allocate)(mutex, mutex_type); in DRD_()
240 if (p && mutex_type == mutex_type_unknown) in DRD_()
241 mutex_type = p->mutex_type; in DRD_()
247 p ? DRD_(mutex_get_typename)(p) : "(?)", in DRD_()
248 mutex, p ? p->recursion_count : -1, in DRD_()
249 p ? p->owner : DRD_INVALID_THREADID); in DRD_()
251 if (p == 0) in DRD_()
257 tl_assert(p); in DRD_()
266 && p->owner == DRD_(thread_get_running_tid)() in DRD_()
267 && p->recursion_count >= 1 in DRD_()
271 p->a1, p->recursion_count, p->owner }; in DRD_()
289 struct mutex_info* p; in DRD_() local
291 p = DRD_(mutex_get)(mutex); in DRD_()
297 p ? DRD_(mutex_get_typename)(p) : "(?)", in DRD_()
298 mutex, p ? p->recursion_count : 0, in DRD_()
299 p ? p->owner : VG_INVALID_THREADID, in DRD_()
302 if (! p || ! took_lock) in DRD_()
305 if (p->recursion_count == 0) { in DRD_()
306 if (p->owner != drd_tid && p->owner != DRD_INVALID_THREADID) in DRD_()
308 tl_assert(p->last_locked_segment); in DRD_()
311 p->last_locked_segment); in DRD_()
318 p->owner = drd_tid; in DRD_()
319 p->acquiry_time_ms = VG_(read_millisecond_timer)(); in DRD_()
320 p->acquired_at = VG_(record_ExeContext)(VG_(get_running_tid)(), 0); in DRD_()
322 } else if (p->owner != drd_tid) { in DRD_()
325 p->a1, p->recursion_count, p->owner }; in DRD_()
332 p->owner = drd_tid; in DRD_()
334 p->recursion_count++; in DRD_()
352 struct mutex_info* p; in DRD_() local
354 p = DRD_(mutex_get)(mutex); in DRD_()
355 if (p && mutex_type == mutex_type_unknown) in DRD_()
356 mutex_type = p->mutex_type; in DRD_()
360 drd_tid, p ? DRD_(mutex_get_typename)(p) : "(?)", in DRD_()
361 mutex, p ? p->recursion_count : 0); in DRD_()
364 if (p == 0 || mutex_type == mutex_type_invalid_mutex) in DRD_()
370 if (p->owner == DRD_INVALID_THREADID) in DRD_()
373 p->a1, p->recursion_count, p->owner }; in DRD_()
382 tl_assert(p); in DRD_()
383 if (p->mutex_type != mutex_type) { in DRD_()
385 p->a1, p->recursion_count, p->owner }; in DRD_()
389 tl_assert(p->mutex_type == mutex_type); in DRD_()
390 tl_assert(p->owner != DRD_INVALID_THREADID); in DRD_()
392 if (p->owner != drd_tid || p->recursion_count <= 0) in DRD_()
395 p->a1, p->recursion_count, p->owner }; in DRD_()
403 tl_assert(p->recursion_count > 0); in DRD_()
404 p->recursion_count--; in DRD_()
405 tl_assert(p->recursion_count >= 0); in DRD_()
407 if (p->recursion_count == 0) in DRD_()
411 Long held = VG_(read_millisecond_timer)() - p->acquiry_time_ms; in DRD_()
416 mutex, p->acquired_at, held, s_mutex_lock_threshold_ms }; in DRD_()
429 DRD_(thread_get_latest_segment)(&p->last_locked_segment, drd_tid); in DRD_()
431 p->acquired_at = 0; in DRD_()
449 const char* DRD_(mutex_get_typename)(struct mutex_info* const p) in DRD_()
451 tl_assert(p); in DRD_()
453 return DRD_(mutex_type_name)(p->mutex_type); in DRD_()
478 static Bool mutex_is_locked(struct mutex_info* const p) in mutex_is_locked() argument
480 tl_assert(p); in mutex_is_locked()
481 return (p->recursion_count > 0); in mutex_is_locked()
486 struct mutex_info* const p = DRD_(mutex_get)(mutex); in DRD_() local
487 if (p) in DRD_()
489 return (p->recursion_count > 0 && p->owner == tid); in DRD_()
496 struct mutex_info* const p = DRD_(mutex_get)(mutex); in DRD_() local
497 tl_assert(p); in DRD_()
498 return p->recursion_count; in DRD_()
505 static void mutex_delete_thread(struct mutex_info* p, const DrdThreadId tid) in mutex_delete_thread() argument
507 tl_assert(p); in mutex_delete_thread()
509 if (p->owner == tid && p->recursion_count > 0) in mutex_delete_thread()
512 p->a1, p->recursion_count, p->owner }; in mutex_delete_thread()
518 p->owner = VG_INVALID_THREADID; in mutex_delete_thread()