equal
deleted
inserted
replaced
848 // |
848 // |
849 // 1-0 exit |
849 // 1-0 exit |
850 // ~~~~~~~~ |
850 // ~~~~~~~~ |
851 // ::exit() uses a canonical 1-1 idiom with a MEMBAR although some of |
851 // ::exit() uses a canonical 1-1 idiom with a MEMBAR although some of |
852 // the fast-path operators have been optimized so the common ::exit() |
852 // the fast-path operators have been optimized so the common ::exit() |
853 // operation is 1-0. See i486.ad fast_unlock(), for instance. |
853 // operation is 1-0, e.g., see macroAssembler_x86.cpp: fast_unlock(). |
854 // The code emitted by fast_unlock() elides the usual MEMBAR. This |
854 // The code emitted by fast_unlock() elides the usual MEMBAR. This |
855 // greatly improves latency -- MEMBAR and CAS having considerable local |
855 // greatly improves latency -- MEMBAR and CAS having considerable local |
856 // latency on modern processors -- but at the cost of "stranding". Absent the |
856 // latency on modern processors -- but at the cost of "stranding". Absent the |
857 // MEMBAR, a thread in fast_unlock() can race a thread in the slow |
857 // MEMBAR, a thread in fast_unlock() can race a thread in the slow |
858 // ::enter() path, resulting in the entering thread being stranding |
858 // ::enter() path, resulting in the entering thread being stranding |
861 // and recover from stranding. Potentially stranded threads periodically |
861 // and recover from stranding. Potentially stranded threads periodically |
862 // wake up and poll the lock. See the usage of the _Responsible variable. |
862 // wake up and poll the lock. See the usage of the _Responsible variable. |
863 // |
863 // |
864 // The CAS() in enter provides for safety and exclusion, while the CAS or |
864 // The CAS() in enter provides for safety and exclusion, while the CAS or |
865 // MEMBAR in exit provides for progress and avoids stranding. 1-0 locking |
865 // MEMBAR in exit provides for progress and avoids stranding. 1-0 locking |
866 // eliminates the CAS/MEMBAR from the exist path, but it admits stranding. |
866 // eliminates the CAS/MEMBAR from the exit path, but it admits stranding. |
867 // We detect and recover from stranding with timers. |
867 // We detect and recover from stranding with timers. |
868 // |
868 // |
869 // If a thread transiently strands it'll park until (a) another |
869 // If a thread transiently strands it'll park until (a) another |
870 // thread acquires the lock and then drops the lock, at which time the |
870 // thread acquires the lock and then drops the lock, at which time the |
871 // exiting thread will notice and unpark the stranded thread, or, (b) |
871 // exiting thread will notice and unpark the stranded thread, or, (b) |
933 } |
933 } |
934 #endif |
934 #endif |
935 |
935 |
936 for (;;) { |
936 for (;;) { |
937 assert(THREAD == _owner, "invariant"); |
937 assert(THREAD == _owner, "invariant"); |
938 |
|
939 |
938 |
940 if (Knob_ExitPolicy == 0) { |
939 if (Knob_ExitPolicy == 0) { |
941 // release semantics: prior loads and stores from within the critical section |
940 // release semantics: prior loads and stores from within the critical section |
942 // must not float (reorder) past the following store that drops the lock. |
941 // must not float (reorder) past the following store that drops the lock. |
943 // On SPARC that requires MEMBAR #loadstore|#storestore. |
942 // On SPARC that requires MEMBAR #loadstore|#storestore. |