added two new vm primitives - vm_getsigfd and vm_getsig - to support os signal handling more promptly

This commit is contained in:
hyunghwan.chung
2019-08-15 15:55:06 +00:00
parent 3253b8fe0a
commit f23a5bd22c
8 changed files with 128 additions and 113 deletions

View File

@ -2669,20 +2669,6 @@ static moo_pfrc_t pf_semaphore_signal_on_gcfin (moo_t* moo, moo_mod_t* mod, moo_
return MOO_PF_SUCCESS;
}
static moo_pfrc_t pf_semaphore_signal_on_intr (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{
moo_oop_semaphore_t sem;
sem = (moo_oop_semaphore_t)MOO_STACK_GETRCV(moo, nargs);
MOO_PF_CHECK_RCV (moo, moo_iskindof(moo, (moo_oop_t)sem, moo->_semaphore));
/* TODO: should i prevent overwriting? */
moo->sem_intr = sem;
MOO_STACK_SETRETTORCV (moo, nargs); /* ^self */
return MOO_PF_SUCCESS;
}
static moo_pfrc_t pf_semaphore_signal_timed (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{
moo_oop_semaphore_t sem;
@ -2839,10 +2825,6 @@ static moo_pfrc_t pf_semaphore_unsignal (moo_t* moo, moo_mod_t* mod, moo_ooi_t n
{
moo->sem_gcfin = (moo_oop_semaphore_t)moo->_nil;
}
else if (sem == moo->sem_intr)
{
moo->sem_intr = (moo_oop_semaphore_t)moo->_nil;
}
if (sem->subtype == MOO_SMOOI_TO_OOP(MOO_SEMAPHORE_SUBTYPE_TIMED))
{
@ -4144,7 +4126,6 @@ static pf_t pftab[] =
{ "Semaphore_signalAfterSecs:nanosecs:", { pf_semaphore_signal_timed, 2, 2 } },
{ "Semaphore_signalOnGCFin", { pf_semaphore_signal_on_gcfin, 0, 0 } },
{ "Semaphore_signalOnInput:", { pf_semaphore_signal_on_input, 1, 1 } },
{ "Semaphore_signalOnIntr", { pf_semaphore_signal_on_intr, 0, 0 } },
{ "Semaphore_signalOnOutput:", { pf_semaphore_signal_on_output, 1, 1 } },
{ "Semaphore_unsignal", { pf_semaphore_unsignal, 0, 0 } },
{ "Semaphore_wait", { pf_semaphore_wait, 0, 0 } },
@ -4180,7 +4161,6 @@ static pf_t pftab[] =
{ "System_calloc", { moo_pf_system_calloc, 1, 1 } },
{ "System_calloc:", { moo_pf_system_calloc, 1, 1 } },
{ "System_collectGarbage", { moo_pf_system_collect_garbage, 0, 0 } },
{ "System_dequeueIntr", { moo_pf_system_dequeue_intr, 0, 0 } },
{ "System_free", { moo_pf_system_free, 1, 1 } },
{ "System_free:", { moo_pf_system_free, 1, 1 } },
{ "System_gc", { moo_pf_system_collect_garbage, 0, 0 } },
@ -4189,6 +4169,8 @@ static pf_t pftab[] =
{ "System_getInt32", { moo_pf_system_get_int32, 2, 2 } },
{ "System_getInt64", { moo_pf_system_get_int64, 2, 2 } },
{ "System_getInt8", { moo_pf_system_get_int8, 2, 2 } },
{ "System_getSig", { moo_pf_system_get_sig, 0, 0 } },
{ "System_getSigfd", { moo_pf_system_get_sigfd, 0, 0 } },
{ "System_getUint16", { moo_pf_system_get_uint16, 2, 2 } },
{ "System_getUint32", { moo_pf_system_get_uint32, 2, 2 } },
{ "System_getUint64", { moo_pf_system_get_uint64, 2, 2 } },
@ -4632,7 +4614,7 @@ static int send_message (moo_t* moo, moo_oop_char_t selector, moo_ooi_t nargs, i
method = moo_findmethod(moo, receiver, selector, to_super);
if (!method)
{
{
method = moo_findmethod(moo, receiver, moo->does_not_understand_sym, 0);
if (!method)
{
@ -4665,20 +4647,6 @@ static int send_message (moo_t* moo, moo_oop_char_t selector, moo_ooi_t nargs, i
static MOO_INLINE int switch_process_if_needed (moo_t* moo)
{
if (moo->intr_qstart != moo->intr_qend && (moo_oop_t)moo->sem_intr != moo->_nil)
{
moo_oop_process_t proc;
proc = signal_semaphore(moo, moo->sem_intr);
if (moo->processor->active == moo->nil_process && (moo_oop_t)proc != moo->_nil)
{
MOO_ASSERT (moo, proc->state == MOO_SMOOI_TO_OOP(PROC_STATE_RUNNABLE));
MOO_ASSERT (moo, proc == moo->processor->runnable.first);
switch_to_process_from_nil (moo, proc);
}
goto switch_to_next;
}
if (moo->sem_heap_count > 0)
{
/* handle timed semaphores */
@ -6166,13 +6134,6 @@ void moo_abort (moo_t* moo)
moo->abort_req = 1;
}
void moo_reportintr (moo_t* moo, int intrno)
{
moo->intr_queue[moo->intr_qend] = intrno;
moo->intr_qend = (moo->intr_qend + 1) % MOO_COUNTOF(moo->intr_queue);
if (moo->intr_qend == moo->intr_qstart) moo->intr_qstart = (moo->intr_qstart + 1) % MOO_COUNTOF(moo->intr_queue);
}
int moo_invoke (moo_t* moo, const moo_oocs_t* objname, const moo_oocs_t* mthname)
{
int n;