Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which OS / platforms implement wait morphing optimization?

Which major OS / platforms implement wait morphing?

This question came up when I noticed that there's no clearcut best practice about whether one should signal a condition variable with mutex locked or not. A typical recommendation is to signal while holding the lock unless profiling shows a substantial performance improvement overhead from unlocking (by removing an extra context switch).

IIUC, the only disadvantage of holding the lock while signalling is the extra two context switches; the advantages are the lower risk of a bug, and easier to achieve real-time predictability.

So, it seems that if wait morphing is implemented, the practice of holding the lock while signalling is strictly better.

like image 494
max Avatar asked Jul 18 '17 10:07

max


Video Answer


1 Answers

It's not supported on Linux. Mark Mossberg investigated it here, and it still holds true as of glibc master today (June 9, 2022).

like image 178
Kevin Yin Avatar answered Nov 27 '22 14:11

Kevin Yin