From: Rui M. <ru...@us...> - 2005-07-26 13:11:13
|
Update of /cvsroot/xsb/XSB/emu In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21501 Modified Files: bineg_xsb_i.h builtin.c Log Message: extended shared completed tables to handle negation Index: bineg_xsb_i.h =================================================================== RCS file: /cvsroot/xsb/XSB/emu/bineg_xsb_i.h,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- bineg_xsb_i.h 14 Jan 2005 18:30:50 -0000 1.19 +++ bineg_xsb_i.h 26 Jul 2005 13:10:57 -0000 1.20 @@ -98,6 +98,11 @@ const int regSubgoalFrame = 1; /* in: rep of a tabled subgoal */ const int regRootSubgoal = 2; /* in: PTCPreg */ +#ifdef MULTI_THREAD + int table_tid ; + th_context *waiting_for_thread ; +#endif + VariantSF producerSF = ptoc_addr(regSubgoalFrame); CPtr t_ptcp = ptoc_addr(regRootSubgoal); #ifdef DEBUG_ASSERTIONS @@ -110,6 +115,34 @@ dbg_print_subgoal(LOG_DELAY, stddbg, producerSF); xsb_dbgmsg((LOG_DELAY, ", (%x)\n", (int)&subg_ans_root_ptr(producerSF))); +#ifdef MULTI_THREAD +/* This allows sharing of completed tables. */ + pthread_mutex_lock(&completing_mut); + while( !is_completed(producerSF) ) + { + table_tid = subg_tid(producerSF) ; + /* if the thread owns the table, proceed */ + if (table_tid == th->tid) + break ; + waiting_for_thread = find_context(table_tid) ; + if( would_deadlock( waiting_for_thread, th ) ) + xsb_exit( "deadlock in concurrent tabling detected" ); + th->waiting_for_subgoal = producerSF ; + th->waiting_for_thread = waiting_for_thread ; + pthread_mutex_unlock(&completing_mut); + pthread_cond_wait(&completing_cond,&completing_mut) ; + if( th->reset_thread ) + { th->reset_thread = FALSE ; + pthread_mutex_unlock(&completing_mut) ; + /* restart the tabletry instruction */ + return TRUE ; + } + } + th->waiting_for_thread = NULL ; + th->waiting_for_subgoal = NULL ; + pthread_mutex_unlock(&completing_mut); +#endif + if (is_completed(producerSF)) { neg_delay = FALSE; ptcpreg = t_ptcp; /* restore ptcpreg as the compl. suspens. would */ Index: builtin.c =================================================================== RCS file: /cvsroot/xsb/XSB/emu/builtin.c,v retrieving revision 1.206 retrieving revision 1.207 diff -u -r1.206 -r1.207 --- builtin.c 19 Jul 2005 13:57:42 -0000 1.206 +++ builtin.c 26 Jul 2005 13:10:57 -0000 1.207 @@ -90,6 +90,7 @@ #include "trie_internals.h" #include "table_status_defs.h" #include "rw_lock.h" +#include "deadlock.h" #ifdef ORACLE #include "oracle_xsb.h" |