I've since moved the Unix signal delivery from the semaphore queuing scheme to have it handed without delay to a running task. Example: the random game generator now checks the SIGINT (Control-C) flag set by a signal handler once each time through the game loop; the generation now concludes early but correctly if the signal occurs. The checking requires no system call; only a memory read of a single
volatile bool flag.
----
Measurements of
Symbolic show that its semaphore queuing and all inter-thread fiddling eats less than one percent of the CPU. There are virtually no calls to unproductive sleeps/waits/polls other than a a very few during program initialization or termination.
The only waiting noticeable by the user is for allocation or clearing of transposition table storage. Allocation runs between one and two GiB per second and the multithreaded clearing runs between ten to twenty GiB per second:
Code: Select all
[2015-05-12 10:59:14.903] Transposition table set allocation begun
[2015-05-12 10:59:14.903] Allocating full position transposition table
[2015-05-12 10:59:15.398] ItemSize: 24 B ItemCount: 33,554,432 (2^25) TableSize: 768 MiB
[2015-05-12 10:59:15.398] Allocating material balance transposition table
[2015-05-12 10:59:15.433] ItemSize: 24 B ItemCount: 1,048,576 (2^20) TableSize: 24 MiB
[2015-05-12 10:59:15.433] Allocating pawn structure transposition table
[2015-05-12 10:59:16.258] ItemSize: 80 B ItemCount: 16,777,216 (2^24) TableSize: 1,280 MiB
[2015-05-12 10:59:16.258] Transposition table set allocation ended
----
My own
Thread class is as good and as portable as the C++11 near-equivalent, so I'm not losing anything here by not having the C++11 tool chain on all of the target platforms.
----
If available, the system call
poll() is slightly simpler than
select() and can handle some of what
select() does.
http://www.ipnom.com/FreeBSD-Man-Pages/poll.2.html
For lower level control, the routines to use are
kqueue() and
kevent().
http://www.ipnom.com/FreeBSD-Man-Pages/kevent.2.html
----
I have no clue as to how Windows does any of this, but sooner or later any functionality which shows up in BSD or Linux will also appear in Windows in some contorted way. You only have to wait.