+} }
+
+
+// wake_up() wakes up the thread, normally at the beginning of the search or,
+// if "sleeping threads" is used, when there is some work to do.
+
+void Thread::wake_up() {
+
+ lock_grab(&sleepLock);
+ cond_signal(&sleepCond);
+ lock_release(&sleepLock);
+}
+
+
+// cutoff_occurred() checks whether a beta cutoff has occurred in
+// the thread's currently active split point, or in some ancestor of
+// the current split point.
+
+bool Thread::cutoff_occurred() const {
+
+ for (SplitPoint* sp = splitPoint; sp; sp = sp->parent)
+ if (sp->is_betaCutoff)
+ return true;
+ return false;
+}
+
+
+// is_available_to() checks whether the thread is available to help the thread with
+// threadID "master" at a split point. An obvious requirement is that thread must be
+// idle. With more than two threads, this is not by itself sufficient: If the thread
+// is the master of some active split point, it is only available as a slave to the
+// threads which are busy searching the split point at the top of "slave"'s split
+// point stack (the "helpful master concept" in YBWC terminology).
+
+bool Thread::is_available_to(int master) const {
+
+ if (state != AVAILABLE)
+ return false;
+
+ // Make a local copy to be sure doesn't become zero under our feet while
+ // testing next condition and so leading to an out of bound access.
+ int localActiveSplitPoints = activeSplitPoints;
+
+ // No active split points means that the thread is available as a slave for any
+ // other thread otherwise apply the "helpful master" concept if possible.
+ if ( !localActiveSplitPoints
+ || splitPoints[localActiveSplitPoints - 1].is_slave[master])
+ return true;
+
+ return false;