mirror of
https://github.com/sockspls/badfish
synced 2025-07-11 19:49:14 +00:00
Revert "Recursive lock"
Joona says that sp_update_pv() does not pass the split point boundaries, so there is no risk to corrupt data from another split point. Also the race on thread_should_stop() is harmless because of this. So revert the patch and come back to single lock. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
2de2b76896
commit
13c096f839
1 changed files with 4 additions and 28 deletions
|
@ -1854,16 +1854,7 @@ namespace {
|
||||||
// New best move?
|
// New best move?
|
||||||
if (value > sp->bestValue) // Less then 2% of cases
|
if (value > sp->bestValue) // Less then 2% of cases
|
||||||
{
|
{
|
||||||
// Recursive locking, lock current split point and its ancestors to
|
lock_grab(&(sp->lock));
|
||||||
// guarantee thread_should_stop() and sp_update_pv() are race free.
|
|
||||||
SplitPoint* spChain[MAX_THREADS * ACTIVE_SPLIT_POINTS_MAX];
|
|
||||||
int cnt = 0;
|
|
||||||
for (spChain[cnt] = sp; spChain[cnt]; )
|
|
||||||
{
|
|
||||||
lock_grab(&(spChain[cnt++]->lock));
|
|
||||||
spChain[cnt] = spChain[cnt - 1]->parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value > sp->bestValue && !TM.thread_should_stop(threadID))
|
if (value > sp->bestValue && !TM.thread_should_stop(threadID))
|
||||||
{
|
{
|
||||||
sp->bestValue = value;
|
sp->bestValue = value;
|
||||||
|
@ -1873,10 +1864,7 @@ namespace {
|
||||||
sp_update_pv(sp->parentSstack, ss, sp->ply);
|
sp_update_pv(sp->parentSstack, ss, sp->ply);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
lock_release(&(sp->lock));
|
||||||
// Release locks in reverse order
|
|
||||||
while (cnt > 0)
|
|
||||||
lock_release(&(spChain[--cnt]->lock));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1975,16 +1963,7 @@ namespace {
|
||||||
// New best move?
|
// New best move?
|
||||||
if (value > sp->bestValue) // Less then 2% of cases
|
if (value > sp->bestValue) // Less then 2% of cases
|
||||||
{
|
{
|
||||||
// Recursive locking, lock current split point and its ancestors to
|
lock_grab(&(sp->lock));
|
||||||
// guarantee thread_should_stop() and sp_update_pv() are race free.
|
|
||||||
SplitPoint* spChain[MAX_THREADS * ACTIVE_SPLIT_POINTS_MAX];
|
|
||||||
int cnt = 0;
|
|
||||||
for (spChain[cnt] = sp; spChain[cnt]; )
|
|
||||||
{
|
|
||||||
lock_grab(&(spChain[cnt++]->lock));
|
|
||||||
spChain[cnt] = spChain[cnt - 1]->parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value > sp->bestValue && !TM.thread_should_stop(threadID))
|
if (value > sp->bestValue && !TM.thread_should_stop(threadID))
|
||||||
{
|
{
|
||||||
sp->bestValue = value;
|
sp->bestValue = value;
|
||||||
|
@ -2001,10 +1980,7 @@ namespace {
|
||||||
ss[sp->ply].mateKiller = move;
|
ss[sp->ply].mateKiller = move;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
lock_release(&(sp->lock));
|
||||||
// Release locks in reverse order
|
|
||||||
while (cnt > 0)
|
|
||||||
lock_release(&(spChain[--cnt]->lock));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue