File tree 1 file changed +7
-3
lines changed
1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -28,14 +28,18 @@ impl Mutex {
28
28
//
29
29
// A pthread mutex initialized with PTHREAD_MUTEX_INITIALIZER will have
30
30
// a type of PTHREAD_MUTEX_DEFAULT, which has undefined behavior if you
31
- // try to re-lock it from the same thread when you already hold a lock.
31
+ // try to re-lock it from the same thread when you already hold a lock
32
+ // (https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_init.html).
32
33
//
33
34
// In practice, glibc takes advantage of this undefined behavior to
34
35
// implement hardware lock elision, which uses hardware transactional
35
- // memory to avoid acquiring the lock. While a transaction is in
36
+ // memory to avoid acquiring the lock.
37
+ // This is the case even if PTHREAD_MUTEX_DEFAULT == PTHREAD_MUTEX_NORMAL
38
+ // (https://github.com/rust-lang/rust/issues/33770#issuecomment-220847521).
39
+ // As a consequence, while a transaction is in
36
40
// progress, the lock appears to be unlocked. This isn't a problem for
37
41
// other threads since the transactional memory will abort if a conflict
38
- // is detected, however no abort is generated if re-locking from the
42
+ // is detected, however no abort is generated when re-locking from the
39
43
// same thread.
40
44
//
41
45
// Since locking the same mutex twice will result in two aliasing &mut
You can’t perform that action at this time.
0 commit comments