Gauche VM thread 実装メモ

#define theVM   ((ScmVM*)pthread_getspecific(vm_key))
*   NOTE: the thread should still be created by Boehm-GC's pthread_create,
*   for it is the only way for GC to see the thread's stack.

VM の thread entry。

static void *thread_entry(void *data)
    ScmVM *vm = SCM_VM(data);
enum {
    SCM_VM_NEW,                 /* This VM is just created and not attached
                                   to the running thread.  vm->thread is not
                                   initialized. */
    SCM_VM_RUNNABLE,            /* This VM is attached to a thread which is
                                   runnable or blocked. */
    SCM_VM_BLOCKED,             /* The thread attached to this VM is stopped
                                   because of thread-yield! or thread-sleep!.
                                   Note that if the thread is blocked by
                                   system call, VM's state is still RUNNABLE.*/
    SCM_VM_TERMINATED           /* The thread attached to this VM is
                                   terminated. */