more semaphore debugging

This commit is contained in:
hyunghwan.chung 2019-08-30 15:48:39 +00:00
parent d9ad1a7804
commit 10cf217b7b
2 changed files with 60 additions and 45 deletions

View File

@ -609,6 +609,8 @@ static void terminate_process (moo_t* moo, moo_oop_process_t proc)
{
/* no runnable process after termination */
MOO_ASSERT (moo, moo->processor->active == moo->nil_process);
if (MOO_LOG_ENABLED(moo, MOO_LOG_IC | MOO_LOG_DEBUG))
{
MOO_LOG5 (moo, MOO_LOG_IC | MOO_LOG_DEBUG,
"No runnable process after termination of process %zd - total %zd runnable/running %zd suspended %zd - sem_io_wait_count %zu\n",
MOO_OOP_TO_SMOOI(proc->id),
@ -617,10 +619,11 @@ static void terminate_process (moo_t* moo, moo_oop_process_t proc)
MOO_OOP_TO_SMOOI(moo->processor->suspended.count),
moo->sem_io_wait_count
);
if (MOO_OOP_TO_SMOOI(moo->processor->runnable.count) > 0)
{
moo_oop_process_t p;
MOO_LOG0 (moo, MOO_LOG_IC | MOO_LOG_DEBUG, "Runnable:");
MOO_LOG0 (moo, MOO_LOG_IC | MOO_LOG_DEBUG, "> Runnable:");
p = moo->processor->runnable.first;
while (p)
{
@ -633,7 +636,7 @@ static void terminate_process (moo_t* moo, moo_oop_process_t proc)
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:");
MOO_LOG0 (moo, MOO_LOG_IC | MOO_LOG_DEBUG, "> Suspended:");
p = moo->processor->suspended.first;
while (p)
{
@ -647,17 +650,23 @@ static void terminate_process (moo_t* moo, moo_oop_process_t proc)
{
moo_ooi_t io_handle;
MOO_LOG0 (moo, MOO_LOG_IC | MOO_LOG_DEBUG, "IO Semaphores:");
MOO_LOG0 (moo, MOO_LOG_IC | MOO_LOG_DEBUG, "> IO Semaphores:");
for (io_handle = 0; io_handle < moo->sem_io_map_capa; io_handle++)
{
if (moo->sem_io_map[io_handle] >= 0)
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
{
switch_to_process (moo, nrp, PROC_STATE_TERMINATED);
@ -845,7 +854,7 @@ static moo_oop_process_t signal_semaphore (moo_t* moo, moo_oop_semaphore_t sem)
moo_ooi_t sp;
/* there is a process waiting on the process group */
proc = sg->waiting.first;
proc = sg->waiting.first; /* will wake the first process in the waiting list */
unchain_from_semaphore (moo, proc);
resume_process (moo, proc);
@ -1396,11 +1405,17 @@ static int delete_sem_from_sem_io_tuple (moo_t* moo, moo_oop_semaphore_t sem, in
moo->sem_io_count--;
/* ****************************************** */
if (sem->waiting.first != moo->_nil)
if ((moo_oop_t)sem->waiting.first != moo->_nil)
{
/* TODO: debug further.... */
moo_oop_process_t wp = sem->waiting.first;
do
{
MOO_DEBUG1 (moo, "decrementing 44 seio_io_wait_count. IO %zd\n", io_handle);
moo->sem_io_wait_count--;
wp = wp->sem_wait.next;
}
while ((moo_oop_t)wp != moo->_nil);
}
/* ****************************************** */

View File

@ -1603,7 +1603,7 @@ struct moo_t
moo_oow_t sem_io_tuple_capa;
moo_oow_t sem_io_count;
moo_oow_t sem_io_wait_count;
moo_oow_t sem_io_wait_count; /* number of processes waiting on an IO semaphore */
moo_ooi_t* sem_io_map;
moo_oow_t sem_io_map_capa;