Stockfish: uiThread required to avoid data race?

Created on 3 Feb 2019  路  5Comments  路  Source: official-stockfish/Stockfish

For context: I am currently porting Stockfish to WebAssembly, where creating pthreads, even idle ones, is very expensive. This brought my attention to uiThread, which (as far as I can tell) is just a dummy and only ever sleeps.


It was introduced in bdeda52efd55c97d0f5da908267c01f973371e5d and appears to be used only once:

https://github.com/official-stockfish/Stockfish/blob/651450023619ddea590f301f040286151004df66/src/uci.cpp#L194-L196

In particular it is not used here (intentionally?):
https://github.com/official-stockfish/Stockfish/blob/651450023619ddea590f301f040286151004df66/src/uci.cpp#L70

If we just need any dummy thread, can't we just use Threads.main() also the first time and get rid of uiThread?

If not, how about not actually instanciating an unsed OS thread? No worries if this is too annoying - I can easily patch this in my WASM port.

Most helpful comment

Oooops :-)

All 5 comments

My feeling is that you could. Maybe you could try editing the c++ code, see if it still work, and open a PR, you don't need a test on fishtest for that.

Rejected PR for reference: #1995

@mcostalba Can you please explain to what conclusion you came?

Should uiThread be removed (#1995), or is there a data race by using Thread.main() in position(), or is there a third option that I am missing?

Oooops :-)

@snicolet What's the conclusion?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BKSpurgeon picture BKSpurgeon  路  6Comments

NKONSTANTAKIS picture NKONSTANTAKIS  路  6Comments

bftjoe picture bftjoe  路  5Comments

Technologov picture Technologov  路  3Comments

d3vv picture d3vv  路  4Comments