Robust mutexes implementation

Martin Simmons martin at lispworks.com
Thu May 5 17:31:40 UTC 2016


There is a potential bug in enqueue_mutex when it tests m1 == NULL and m1 !=
NULL.  These tests only work because m_lock is the first slot in struct
pthread_mutex and hence 0 in curthread->robust_list is converted to NULL
(rather than a negative value).

Also, is it safe to assume memory ordering between the assignments of
m->m_lock.m_rb_lnk and curthread->robust_list?  Maybe it is OK because the
kernel will never read curthread->robust_list until after the CPU executing
enqueue_mutex has passed a memory barrier?

__Martin


More information about the freebsd-threads mailing list