Don't reparent if a cutoff is pending

And update master->splitPointsCnt under lock
protection. Not stricly necessary because
single_bit() condition takes care of false
positives anyhow, but it is a bit tricky and
moving under lock is the most natural thing
to do to avoid races with "reparenting".

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba
2012-04-10 19:48:57 +01:00
parent 44432f67d7
commit c645aca199
2 changed files with 17 additions and 19 deletions

View File

@@ -313,7 +313,7 @@ Value ThreadsManager::split(Position& pos, Stack* ss, Value alpha, Value beta,
return bestValue;
// Pick the next available split point from the split point stack
SplitPoint* sp = &master->splitPoints[master->splitPointsCnt++];
SplitPoint* sp = &master->splitPoints[master->splitPointsCnt];
sp->parent = master->curSplitPoint;
sp->master = master;
@@ -362,6 +362,8 @@ Value ThreadsManager::split(Position& pos, Stack* ss, Value alpha, Value beta,
}
}
master->splitPointsCnt++;
lock_release(splitLock);
lock_release(sp->lock);