OSDN Git Service

Fix the ordering of lock acquisition in the heap worker.
authorCarl Shapiro <cshapiro@google.com>
Fri, 6 Aug 2010 22:17:46 +0000 (15:17 -0700)
committerCarl Shapiro <cshapiro@google.com>
Mon, 9 Aug 2010 23:13:20 +0000 (16:13 -0700)
commitd012d06b0673c3da9d23b1816ff5a325576eb9b3
treef4ff7e4396fff38a87710488d3a910c506de83cc
parent34bfe020eccbe4034322c5952012612b0540acb3
Fix the ordering of lock acquisition in the heap worker.

A feature of the concurrent GC is that gcHeapLock is released while
roots are traced through.  This complicates the heap worker thread as
it assumes that when the gcHeapLock can be acquired no threads are
contending for the heapWorkerLock.  However, the concurrent GC holds
heapWorkerLock for the duration of a GC.  If the heap worker thread
becomes active while the GC temporarily release gcHeapLock it may
deadlock the GC by acquring the gcHeapLock, needed by the GC during
its final pause, and wait for the heapWorkerLock held by the GC.

This change attempts to resolve this issue by checking to see if after
a transition into running whether the GC has become active.  If so, it
releases gcHeapLock and reacquires it after the GC has signaled
completion.  This must be done in a loop as there is no guarantee that
the GC has not become active when heap worker is rescheduled.
vm/alloc/HeapWorker.c