semaphores in the runtime
Trivial refactorings:
* Rename STATE_SUSPENDED STATE_STOPPED for elegance. (Spells with the same
number of letters as STATE_RUNNING, things line up nicer.)
* Re-express make_fixnum in terms of MAKE_FIXNUM so that we can use the
latter to define STATE_* names in a manner acceptable to use in
switch-statements.
* Move Mach exception handling initialization to darwin_init from
create_initial_thread so that current_mach_task gets initialized before
the first thread struct is initialized.
The Beef:
Replace condition variables in the runtime with semaphores.
On most platforms use sem_t, but on Darwin use semaphore_t. Hide the
difference behind, os_sem_t, os_sem_init, os_sem_destroy, os_sem_post, and
os_sem_wait.
POSIX realtime semaphores are supposedly safe to use in signal handlers,
unlike condition variables -- and experimentally at least Mach semaphores
on Darwin are a lot less prone to problems.
(Our pthread mutex usage isn't quite kosher either, but it's the
pthread_cond_wait and pthread_cond_broadcast pair that seemed to be
causing most of the trouble.)