Tabling concurrency: yielding to another thread

I noticed you used sleep(0.000001) (in restart_tabling/3), to yield to the other threads. I would suggest to add a thread_yield/0 foreign predicate which calls posix’s sched_yield() (don’t know what the equivalent is in windows).

See sched_yield(2): yield processor - Linux man page

That is probably cleaner. For now, this was easier and results in almost the same effect. I’m also not entirely sure. The comment says “If the calling thread is the only thread in the highest priority list at that time, it will continue to run after a call to sched_yield ().”. We really want to give up the CPU such that the other thread that is waiting on a condition variable that we just signalled gets the table before us.