From b96d977234f4c4740d419b8396eb9d20c7db7341 Mon Sep 17 00:00:00 2001 From: "hyunghwan.chung" Date: Sat, 31 Aug 2019 10:21:37 +0000 Subject: [PATCH] some experimental code in terminate_process() to handle IO semaphores properly --- moo/lib/exec.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/moo/lib/exec.c b/moo/lib/exec.c index fc70954..10a070c 100644 --- a/moo/lib/exec.c +++ b/moo/lib/exec.c @@ -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 */