24 */ 25 26 #include "precompiled.hpp" 27 #include "runtime/mutex.hpp" 28 #include "runtime/osThread.hpp" 29 #include "runtime/thread.inline.hpp" 30 #include "utilities/events.hpp" 31 #ifdef TARGET_OS_FAMILY_linux 32 # include "mutex_linux.inline.hpp" 33 #endif 34 #ifdef TARGET_OS_FAMILY_solaris 35 # include "mutex_solaris.inline.hpp" 36 #endif 37 #ifdef TARGET_OS_FAMILY_windows 38 # include "mutex_windows.inline.hpp" 39 #endif 40 #ifdef TARGET_OS_FAMILY_bsd 41 # include "mutex_bsd.inline.hpp" 42 #endif 43 44 // o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o 45 // 46 // Native Monitor-Mutex locking - theory of operations 47 // 48 // * Native Monitors are completely unrelated to Java-level monitors, 49 // although the "back-end" slow-path implementations share a common lineage. 50 // See objectMonitor:: in synchronizer.cpp. 51 // Native Monitors do *not* support nesting or recursion but otherwise 52 // they're basically Hoare-flavor monitors. 53 // 54 // * A thread acquires ownership of a Monitor/Mutex by CASing the LockByte 55 // in the _LockWord from zero to non-zero. Note that the _Owner field 56 // is advisory and is used only to verify that the thread calling unlock() 57 // is indeed the last thread to have acquired the lock. 58 // 59 // * Contending threads "push" themselves onto the front of the contention 60 // queue -- called the cxq -- with CAS and then spin/park. 61 // The _LockWord contains the LockByte as well as the pointer to the head 62 // of the cxq. Colocating the LockByte with the cxq precludes certain races. 63 // | 24 */ 25 26 #include "precompiled.hpp" 27 #include "runtime/mutex.hpp" 28 #include "runtime/osThread.hpp" 29 #include "runtime/thread.inline.hpp" 30 #include "utilities/events.hpp" 31 #ifdef TARGET_OS_FAMILY_linux 32 # include "mutex_linux.inline.hpp" 33 #endif 34 #ifdef TARGET_OS_FAMILY_solaris 35 # include "mutex_solaris.inline.hpp" 36 #endif 37 #ifdef TARGET_OS_FAMILY_windows 38 # include "mutex_windows.inline.hpp" 39 #endif 40 #ifdef TARGET_OS_FAMILY_bsd 41 # include "mutex_bsd.inline.hpp" 42 #endif 43 44 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC 45 46 // o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o 47 // 48 // Native Monitor-Mutex locking - theory of operations 49 // 50 // * Native Monitors are completely unrelated to Java-level monitors, 51 // although the "back-end" slow-path implementations share a common lineage. 52 // See objectMonitor:: in synchronizer.cpp. 53 // Native Monitors do *not* support nesting or recursion but otherwise 54 // they're basically Hoare-flavor monitors. 55 // 56 // * A thread acquires ownership of a Monitor/Mutex by CASing the LockByte 57 // in the _LockWord from zero to non-zero. Note that the _Owner field 58 // is advisory and is used only to verify that the thread calling unlock() 59 // is indeed the last thread to have acquired the lock. 60 // 61 // * Contending threads "push" themselves onto the front of the contention 62 // queue -- called the cxq -- with CAS and then spin/park. 63 // The _LockWord contains the LockByte as well as the pointer to the head 64 // of the cxq. Colocating the LockByte with the cxq precludes certain races. 65 // |