relocated process information dumping into a separate function, dump_process_info() in exec.c

This commit is contained in:
hyunghwan.chung 2019-08-31 03:08:59 +00:00
parent 10cf217b7b
commit 44425c5e60
2 changed files with 90 additions and 45 deletions

View File

@ -120,6 +120,7 @@ class System(Apex)
self.gcfin_sem wait. self.gcfin_sem wait.
} }
] ensure: [ ] ensure: [
self.gcfin_sem signal. // in case the process is stuck in wait.
self.gcfin_sem unsignal. self.gcfin_sem unsignal.
System logNl: 'End of GC finalization process ' & (thisProcess id) asString. System logNl: 'End of GC finalization process ' & (thisProcess id) asString.
]. ].
@ -151,6 +152,7 @@ class System(Apex)
] ]
ensure: [ ensure: [
| pid proc | | pid proc |
os_intr_sem signal.
os_intr_sem unsignal. os_intr_sem unsignal.
System logNl: '>>>>Requesting to terminate the caller process ' & (caller id) asString. System logNl: '>>>>Requesting to terminate the caller process ' & (caller id) asString.

View File

@ -581,6 +581,89 @@ static MOO_INLINE void unchain_from_semaphore (moo_t* moo, moo_oop_process_t pro
proc->sem = moo->_nil; proc->sem = moo->_nil;
} }
static void dump_process_info (moo_t* moo, moo_bitmask_t log_mask)
{
if (MOO_OOP_TO_SMOOI(moo->processor->runnable.count) > 0)
{
moo_oop_process_t p;
MOO_LOG0 (moo, log_mask, "> Runnable:");
p = moo->processor->runnable.first;
while (p)
{
MOO_LOG1 (moo, log_mask, " %O", p->id);
if (p == moo->processor->runnable.last) break;
p = p->ps.next;
}
MOO_LOG0 (moo, log_mask, "\n");
}
if (MOO_OOP_TO_SMOOI(moo->processor->suspended.count) > 0)
{
moo_oop_process_t p;
MOO_LOG0 (moo, log_mask, "> Suspended:");
p = moo->processor->suspended.first;
while (p)
{
MOO_LOG1 (moo, log_mask, " %O", p->id);
if (p == moo->processor->suspended.last) break;
p = p->ps.next;
}
MOO_LOG0 (moo, log_mask, "\n");
}
if (moo->sem_io_wait_count > 0)
{
moo_ooi_t io_handle;
MOO_LOG0 (moo, log_mask, "> IO Semaphores:");
for (io_handle = 0; io_handle < moo->sem_io_map_capa; io_handle++)
{
moo_ooi_t index;
index = moo->sem_io_map[io_handle];
if (index >= 0)
{
moo_oop_semaphore_t sem;
MOO_LOG1 (moo, log_mask, " h=%zd", io_handle);
/* dump process IDs waiting for input signaling */
MOO_LOG0 (moo, log_mask, "(wpi");
sem = moo->sem_io_tuple[index].sem[MOO_SEMAPHORE_IO_TYPE_INPUT];
if (sem)
{
moo_oop_process_t wp; /* waiting process */
for (wp = sem->waiting.first; (moo_oop_t)wp != moo->_nil; wp = wp->sem_wait.next)
{
MOO_LOG1 (moo, log_mask, ":%zd", MOO_OOP_TO_SMOOI(wp->id));
}
}
else
{
MOO_LOG0 (moo, log_mask, ":none");
}
/* dump process IDs waiting for output signaling */
MOO_LOG0 (moo, log_mask, ",wpo");
sem = moo->sem_io_tuple[index].sem[MOO_SEMAPHORE_IO_TYPE_OUTPUT];
if (sem)
{
moo_oop_process_t wp; /* waiting process */
for (wp = sem->waiting.first; (moo_oop_t)wp != moo->_nil; wp = wp->sem_wait.next)
{
MOO_LOG1 (moo, log_mask, ":%zd", MOO_OOP_TO_SMOOI(wp->id));
}
}
else
{
MOO_LOG0 (moo, log_mask, ":none");
}
MOO_LOG0 (moo, log_mask, ")");
}
}
MOO_LOG0 (moo, log_mask, "\n");
}
}
static void terminate_process (moo_t* moo, moo_oop_process_t proc) static void terminate_process (moo_t* moo, moo_oop_process_t proc)
{ {
if (proc->state == MOO_SMOOI_TO_OOP(PROC_STATE_RUNNING) || if (proc->state == MOO_SMOOI_TO_OOP(PROC_STATE_RUNNING) ||
@ -620,51 +703,7 @@ static void terminate_process (moo_t* moo, moo_oop_process_t proc)
moo->sem_io_wait_count moo->sem_io_wait_count
); );
if (MOO_OOP_TO_SMOOI(moo->processor->runnable.count) > 0) dump_process_info (moo, MOO_LOG_IC | MOO_LOG_DEBUG);
{
moo_oop_process_t p;
MOO_LOG0 (moo, MOO_LOG_IC | MOO_LOG_DEBUG, "> Runnable:");
p = moo->processor->runnable.first;
while (p)
{
MOO_LOG1 (moo, MOO_LOG_IC | MOO_LOG_DEBUG, " %O", p->id);
if (p == moo->processor->runnable.last) break;
p = p->ps.next;
}
MOO_LOG0 (moo, MOO_LOG_IC | MOO_LOG_DEBUG, "\n");
}
if (MOO_OOP_TO_SMOOI(moo->processor->suspended.count) > 0)
{
moo_oop_process_t p;
MOO_LOG0 (moo, MOO_LOG_IC | MOO_LOG_DEBUG, "> Suspended:");
p = moo->processor->suspended.first;
while (p)
{
MOO_LOG1 (moo, MOO_LOG_IC | MOO_LOG_DEBUG, " %O", p->id);
if (p == moo->processor->suspended.last) break;
p = p->ps.next;
}
MOO_LOG0 (moo, MOO_LOG_IC | MOO_LOG_DEBUG, "\n");
}
if (moo->sem_io_wait_count > 0)
{
moo_ooi_t io_handle;
MOO_LOG0 (moo, MOO_LOG_IC | MOO_LOG_DEBUG, "> IO Semaphores:");
for (io_handle = 0; io_handle < moo->sem_io_map_capa; io_handle++)
{
moo_ooi_t index;
index = moo->sem_io_map[io_handle];
if (index >= 0)
{
/*moo->sem_io_tuple[index].sem[MOO_SEMAPHORE_IO_TYPE_INPUT];
moo->sem_io_tuple[index].sem[MOO_SEMAPHORE_IO_TYPE_OUTPUT];*/
MOO_LOG1 (moo, MOO_LOG_IC | MOO_LOG_DEBUG, " %zd", io_handle);
}
}
MOO_LOG0 (moo, MOO_LOG_IC | MOO_LOG_DEBUG, "\n");
}
} }
} }
else else
@ -1405,9 +1444,12 @@ static int delete_sem_from_sem_io_tuple (moo_t* moo, moo_oop_semaphore_t sem, in
moo->sem_io_count--; moo->sem_io_count--;
/* ****************************************** */ /* ****************************************** */
#if 0
if ((moo_oop_t)sem->waiting.first != moo->_nil) if ((moo_oop_t)sem->waiting.first != moo->_nil)
{ {
/* TODO: debug further.... */ /* TODO: debug further.... */
/* TODO: this should not be done here. instead, something similar should be done in a process termination routine.
view this as resource cleanup for a proceses?? if the waiting process dies, it must decrement this counter... */
moo_oop_process_t wp = sem->waiting.first; moo_oop_process_t wp = sem->waiting.first;
do do
{ {
@ -1417,6 +1459,7 @@ MOO_DEBUG1 (moo, "decrementing 44 seio_io_wait_count. IO %zd\n", io_handle);
} }
while ((moo_oop_t)wp != moo->_nil); while ((moo_oop_t)wp != moo->_nil);
} }
#endif
/* ****************************************** */ /* ****************************************** */
if ((moo_oop_t)sem->group != moo->_nil) if ((moo_oop_t)sem->group != moo->_nil)