13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "runtime/atomic.inline.hpp"
27 #include "runtime/interfaceSupport.hpp"
28 #include "runtime/mutex.hpp"
29 #include "runtime/orderAccess.inline.hpp"
30 #include "runtime/osThread.hpp"
31 #include "runtime/thread.inline.hpp"
32 #include "utilities/events.hpp"
33 #ifdef TARGET_OS_FAMILY_linux
34 # include "mutex_linux.inline.hpp"
35 #endif
36 #ifdef TARGET_OS_FAMILY_solaris
37 # include "mutex_solaris.inline.hpp"
38 #endif
39 #ifdef TARGET_OS_FAMILY_windows
40 # include "mutex_windows.inline.hpp"
41 #endif
42 #ifdef TARGET_OS_FAMILY_bsd
43 # include "mutex_bsd.inline.hpp"
44 #endif
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.
|
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "runtime/atomic.inline.hpp"
27 #include "runtime/interfaceSupport.hpp"
28 #include "runtime/mutex.hpp"
29 #include "runtime/orderAccess.inline.hpp"
30 #include "runtime/osThread.hpp"
31 #include "runtime/thread.inline.hpp"
32 #include "utilities/events.hpp"
33 #include "utilities/macros.hpp"
34
35 // 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
36 //
37 // Native Monitor-Mutex locking - theory of operations
38 //
39 // * Native Monitors are completely unrelated to Java-level monitors,
40 // although the "back-end" slow-path implementations share a common lineage.
41 // See objectMonitor:: in synchronizer.cpp.
42 // Native Monitors do *not* support nesting or recursion but otherwise
43 // they're basically Hoare-flavor monitors.
44 //
45 // * A thread acquires ownership of a Monitor/Mutex by CASing the LockByte
46 // in the _LockWord from zero to non-zero. Note that the _Owner field
47 // is advisory and is used only to verify that the thread calling unlock()
48 // is indeed the last thread to have acquired the lock.
49 //
50 // * Contending threads "push" themselves onto the front of the contention
51 // queue -- called the cxq -- with CAS and then spin/park.
52 // The _LockWord contains the LockByte as well as the pointer to the head
53 // of the cxq. Colocating the LockByte with the cxq precludes certain races.
|