some experimental code in terminate_process() to handle IO semaphores properly

This commit is contained in:
hyunghwan.chung 2019-08-31 10:21:37 +00:00
parent f6d7098744
commit b96d977234

View File

@ -734,6 +734,26 @@ static void terminate_process (moo_t* moo, moo_oop_process_t proc)
if ((moo_oop_t)proc->sem != moo->_nil)
{
unchain_from_semaphore (moo, proc);
/* [EXPERIMENTAL] =============================== */
if (MOO_CLASSOF(moo, proc->sem) == moo->_semaphore_group)
{
/* TODO: */
if (MOO_OOP_TO_SMOOI((moo_oop_semaphore_group_t)proc->sem) > 0)
{
MOO_ASSERT (moo, moo->sem_io_wait_count > 0);
moo->sem_io_wait_count--;
}
}
else
{
if (((moo_oop_semaphore_t)proc->sem)->subtype == MOO_SMOOI_TO_OOP(MOO_SEMAPHORE_SUBTYPE_IO))
{
MOO_ASSERT (moo, moo->sem_io_wait_count > 0);
moo->sem_io_wait_count--;
}
}
/* =============================== */
}
/* when terminated, clear it from the pid table and set the process id to a negative number */