6822370: ReentrantReadWriteLock: threads hung when there are no threads holding onto the lock (Netra x4450)

This day one bug is caused by missing memory barriers in various Parker::park() paths that can result in lost wakeups and hangs.

Reviewed-by: dice, acorn
This commit is contained in:
David Holmes 2009-12-01 22:29:02 -05:00
parent b409d16477
commit 10232cb341
2 changed files with 6 additions and 0 deletions

View File

@ -4683,6 +4683,7 @@ void Parker::park(bool isAbsolute, jlong time) {
// Return immediately if a permit is available. // Return immediately if a permit is available.
if (_counter > 0) { if (_counter > 0) {
_counter = 0 ; _counter = 0 ;
OrderAccess::fence();
return ; return ;
} }
@ -4725,6 +4726,7 @@ void Parker::park(bool isAbsolute, jlong time) {
_counter = 0; _counter = 0;
status = pthread_mutex_unlock(_mutex); status = pthread_mutex_unlock(_mutex);
assert (status == 0, "invariant") ; assert (status == 0, "invariant") ;
OrderAccess::fence();
return; return;
} }
@ -4765,6 +4767,7 @@ void Parker::park(bool isAbsolute, jlong time) {
jt->java_suspend_self(); jt->java_suspend_self();
} }
OrderAccess::fence();
} }
void Parker::unpark() { void Parker::unpark() {

View File

@ -5803,6 +5803,7 @@ void Parker::park(bool isAbsolute, jlong time) {
// Return immediately if a permit is available. // Return immediately if a permit is available.
if (_counter > 0) { if (_counter > 0) {
_counter = 0 ; _counter = 0 ;
OrderAccess::fence();
return ; return ;
} }
@ -5846,6 +5847,7 @@ void Parker::park(bool isAbsolute, jlong time) {
_counter = 0; _counter = 0;
status = os::Solaris::mutex_unlock(_mutex); status = os::Solaris::mutex_unlock(_mutex);
assert (status == 0, "invariant") ; assert (status == 0, "invariant") ;
OrderAccess::fence();
return; return;
} }
@ -5892,6 +5894,7 @@ void Parker::park(bool isAbsolute, jlong time) {
jt->java_suspend_self(); jt->java_suspend_self();
} }
OrderAccess::fence();
} }
void Parker::unpark() { void Parker::unpark() {