Fix occasional hang in ApiTest.DepartedRace
Fix occasional hang in ApiTest.DepartedRace

pthread_join() strikes again!

In this particular case t2.join() returned "early" before the
thread had fully exited (in fact it had gotten offcpu via a
_cond_resched()). This raced with the AgentProcess destructor
calling TerminateAgentTasks(). When the satellite agents had
exited there was no cpu on which the 't2' could schedule even
though it was runnable.

Typically a txn commit failure due to GHOST_TXN_NO_AGENT is
considered unexpected and fatal _except_ when we are explicitly
terminating agents via TerminateAgentTasks().

Fix this by exiting the spinning agent immediately after
Finished() is asserted. If there are tasks remaining in
the enclave they will be moved into the fair sched_class
by the kernel when the enclave is destroyed.

Tested: 1000 iterations of ApiTest.DepartedRace

google/ghost-userspace,google/ghost-userspace,google/ghost-userspace,google/ghost-userspace