Skip to content

Commit

Permalink
For starvation check openjdk#3
Browse files Browse the repository at this point in the history
  • Loading branch information
DougLea committed Oct 24, 2024
1 parent b35cc63 commit 409cf50
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2013,9 +2013,8 @@ else if (U.compareAndSetReference(a, k, t, null)) {
w.source = j; // volatile
rescan = true;
if ((!propagated ||
((j & 1) == 0 &&
t.getClass().getSuperclass() ==
interruptibleTaskClass)) &&
t.getClass().getSuperclass() ==
interruptibleTaskClass) &&
next != null) {
propagated = true;
signalWork();
Expand Down Expand Up @@ -2055,18 +2054,18 @@ private int deactivate(WorkQueue w, int phase) {
((e & SHUTDOWN) != 0L && ac == 0 && quiescent() > 0) ||
(qs = queues) == null || (n = qs.length) <= 0)
return IDLE; // terminating
int checks = (ac == 0) ? 1 : (ac == 1) ? 2 : 3;
int checks = (ac <= 1) ? ac + 1 : 3; // reactivation threshold
for (int k = Math.max(n + (n << 1), SPIN_WAITS);;) {
WorkQueue q; int cap; ForkJoinTask<?>[] a;
if (w.phase == activePhase)
return activePhase;
if (--k < 0)
return awaitWork(w, p); // block, drop, or exit
if ((q = qs[k & (n - 1)]) == null)
Thread.onSpinWait(); // interleave spins and rechecks
else if ((a = q.array) != null && (cap = a.length) > 0 &&
a[q.base & (cap - 1)] != null && --checks <= 0 &&
ctl == qc && compareAndSetCtl(qc, pc))
Thread.onSpinWait(); // interleave spins and rechecks
if ((k & 1) == 0 && (q = qs[k & (n - 1)]) != null &&
(a = q.array) != null && (cap = a.length) > 0 &&
a[q.base & (cap - 1)] != null && --checks <= 0 &&
ctl == qc && compareAndSetCtl(qc, pc))
return w.phase = activePhase; // reactivate
}
}
Expand Down

0 comments on commit 409cf50

Please sign in to comment.