Update of /cvsroot/xsb/XSB/emu
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv2335
Modified Files:
biassert.c conc_compl.c conc_compl.h context.h deadlock.c
emuloop.c loader_xsb.c macro_xsb.h memory_xsb.c psc_xsb.c
schedrev_xsb_i.h slginsts_xsb_i.h thread_xsb.c thread_xsb.h
tr_utils.c
Log Message:
added incarnation number to thread id to avoid problems with
detached threads, when joining could mistake a thread with one reusing and old id
Index: biassert.c
===================================================================
RCS file: /cvsroot/xsb/XSB/emu/biassert.c,v
retrieving revision 1.127
retrieving revision 1.128
diff -u -r1.127 -r1.128
--- biassert.c 16 Nov 2006 00:10:45 -0000 1.127
+++ biassert.c 20 Nov 2006 16:53:41 -0000 1.128
@@ -106,9 +106,9 @@
table wrapper */
CPtr dynpredep_to_prortb(CTXTdeclc void *pred_ep) {
- if (th->tid > (((struct DispBlk_t **)pred_ep)[1])->MaxThread)
+ if (xsb_thread_entry > (((struct DispBlk_t **)pred_ep)[1])->MaxThread)
xsb_abort("Dynamic Dispatch block too small");
- return (CPtr) ((&((struct DispBlk_t **)pred_ep)[1]->Thread0)[th->tid]);
+ return (CPtr) ((&((struct DispBlk_t **)pred_ep)[1]->Thread0)[xsb_thread_entry]);
}
#endif
@@ -122,9 +122,9 @@
PrRef dynpredep_to_prref(CTXTdeclc void *pred_ep) {
#ifdef MULTI_THREAD
if (cell_opcode((CPtr)(pred_ep)) == switchonthread) {
- if (th->tid > (((struct DispBlk_t **)pred_ep)[1])->MaxThread)
+ if (xsb_thread_entry > (((struct DispBlk_t **)pred_ep)[1])->MaxThread)
xsb_abort("Dynamic Dispatch block too small");
- pred_ep = (pb) (&((struct DispBlk_t **)pred_ep)[1]->Thread0)[th->tid];
+ pred_ep = (pb) (&((struct DispBlk_t **)pred_ep)[1]->Thread0)[xsb_thread_entry];
}
if (!pred_ep) return NULL;
#endif
@@ -2731,16 +2731,16 @@
// printf("Enter thread_free_dyn_blks\n");
SYS_MUTEX_LOCK( MUTEX_DYNAMIC );
for (dispblk=DispBlkHdr.firstDB ; dispblk != NULL ; dispblk=dispblk->NextDB) {
- if (th->tid <= dispblk->MaxThread) {
- prref0 = (PrRef)(&(dispblk->Thread0))[th->tid];
+ if (xsb_thread_entry <= dispblk->MaxThread) {
+ prref0 = (PrRef)(&(dispblk->Thread0))[xsb_thread_entry];
if (prref0) {
if (cell_opcode((CPtr *)prref0) == tabletrysingle)
prref = (PrRef)((CPtr *)prref0)[6];
else prref = prref0;
retractall_prref(CTXTc prref);
free_private_prref(CTXTc (CPtr *)prref0);
- // printf("set prref free for thread %d\n",th->tid);
- (&(dispblk->Thread0))[th->tid] = (CPtr) NULL;
+ // printf("set prref free for thread %d\n",xsb_thread_id);
+ (&(dispblk->Thread0))[xsb_thread_entry] = (CPtr) NULL;
}
}
}
@@ -3262,8 +3262,8 @@
/* add to dispblock if room, extending if nec */
dispblk = (struct DispBlk_t *)*((CPtr)get_ep(psc)+1);
}
- if (dispblk->MaxThread >= th->tid) {
- (&(dispblk->Thread0))[th->tid] = (CPtr)new_ep;
+ if (dispblk->MaxThread >= xsb_thread_entry) {
+ (&(dispblk->Thread0))[xsb_thread_entry] = (CPtr)new_ep;
} else xsb_exit("must expand dispatch-block");
} else set_ep(psc,new_ep);
#else
@@ -3291,8 +3291,8 @@
pb new_ep;
struct DispBlk_t *dispblk = ((struct DispBlk_t **)get_ep(psc))[1];
allocate_prref_tab(CTXTc psc,&prref,&new_ep);
- if (dispblk->MaxThread >= th->tid) {
- (&(dispblk->Thread0))[th->tid] = (CPtr) new_ep;
+ if (dispblk->MaxThread >= xsb_thread_entry) {
+ (&(dispblk->Thread0))[xsb_thread_entry] = (CPtr) new_ep;
} else {
// SYS_MUTEX_UNLOCK( MUTEX_DYNAMIC );
xsb_exit("must expand dispatch-block");
Index: conc_compl.c
===================================================================
RCS file: /cvsroot/xsb/XSB/emu/conc_compl.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- conc_compl.c 6 Nov 2006 17:31:53 -0000 1.11
+++ conc_compl.c 20 Nov 2006 16:53:41 -0000 1.12
@@ -55,7 +55,7 @@
else
i++ ;
}
- if( TDL->NumDeps == MAX_TDEP_LIST - 1 )
+ if( TDL->NumDeps == MAX_THREAD_DEPS - 1 )
xsb_abort( "Too many inter-thread dependencies" );
GetDepSubgoal(&TDL->Deps[TDL->NumDeps++]) = subg ;
@@ -115,7 +115,7 @@
dep = GetInitDep(&dep_th->TDL);
while( dep != NULL )
{ sgf = GetDepSubgoal(dep) ;
- if( subg_tid(sgf) == th->tid )
+ if( subg_tid(sgf) == xsb_thread_id )
{
if( subg_compl_stack_ptr(sgf) > *leader )
*leader = subg_compl_stack_ptr(sgf) ;
Index: conc_compl.h
===================================================================
RCS file: /cvsroot/xsb/XSB/emu/conc_compl.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- conc_compl.h 4 Oct 2005 11:21:00 -0000 1.4
+++ conc_compl.h 20 Nov 2006 16:53:41 -0000 1.5
@@ -5,7 +5,8 @@
#define _CONC_COMPL_H_
#ifdef CONC_COMPL
-#define MAX_TDEP_LIST 100
+
+#define MAX_THREAD_DEPS 256
struct subgoal_frame ;
@@ -19,7 +20,7 @@
typedef
struct {
int NumDeps ;
-ThreadDep Deps[MAX_TDEP_LIST];
+ThreadDep Deps[MAX_THREAD_DEPS];
} ThreadDepList ;
int EmptyThreadDepList( ThreadDepList *TDL ) ;
Index: context.h
===================================================================
RCS file: /cvsroot/xsb/XSB/emu/context.h,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- context.h 15 Nov 2006 16:38:09 -0000 1.47
+++ context.h 20 Nov 2006 16:53:41 -0000 1.48
@@ -402,6 +402,7 @@
#define xsb_thread_id (th -> tid)
+#define xsb_thread_entry (THREAD_ENTRY(th -> tid))
#define call_intercept (th->_call_intercept)
Index: deadlock.c
===================================================================
RCS file: /cvsroot/xsb/XSB/emu/deadlock.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- deadlock.c 7 Nov 2006 02:01:07 -0000 1.11
+++ deadlock.c 20 Nov 2006 16:53:41 -0000 1.12
@@ -68,13 +68,13 @@
/* if the subgoal has not yet been computed, the
thread should not be reset */
if( subg_grabbed(sgf) )
- { subg_tid(sgf) = th->tid ;
+ { subg_tid(sgf) = xsb_thread_id ;
return ;
}
ctxt->reset_thread = TRUE ;
sgf = bottom_leader(ctxt, sgf) ;
*resetsgf = sgf ;
- ReclaimDSandMarkReset(ctxt, sgf, th->tid);
+ ReclaimDSandMarkReset(ctxt, sgf, xsb_thread_id);
/* trick to use other thread's context */
th = ctxt ;
/* reset the stacks by restoring the generator cp of this sg */
Index: emuloop.c
===================================================================
RCS file: /cvsroot/xsb/XSB/emu/emuloop.c,v
retrieving revision 1.145
retrieving revision 1.146
diff -u -r1.145 -r1.146
--- emuloop.c 4 Nov 2006 12:41:26 -0000 1.145
+++ emuloop.c 20 Nov 2006 16:53:41 -0000 1.146
@@ -96,19 +96,19 @@
Creates a log-file for each thread, and
Logs calls and executes to it.
*/
-FILE *th_log_file[100] = {NULL};
-int th_log_cnt[100] = {0};
+FILE *th_log_file[MAX_THREADS] = {NULL};
+int th_log_cnt[MAX_THREADS] = {0};
void open_th_log_file(int tid) {
char fname[100];
sprintf(fname,"temp_th_log_file_%d",tid);
- th_log_file[tid] = fopen(fname,"w");
+ th_log_file[THREAD_ENTRY(tid)] = fopen(fname,"w");
return;
}
void log_rec(CTXTdeclc Psc psc, char *ctype) {
- if (!th_log_file[th->tid]) open_th_log_file(th->tid);
- fprintf(th_log_file[th->tid],"inst(%d,%s,'%s',%d).\n",++th_log_cnt[th->tid],ctype,get_name(psc),get_arity(psc));
+ if (!th_log_file[xsb_thread_id]) open_th_log_file(xsb_thread_id);
+ fprintf(th_log_file[xsb_thread_entry],"inst(%d,%s,'%s',%d).\n",++th_log_cnt[xsb_thread_entry],ctype,get_name(psc),get_arity(psc));
return;
}
#endif
@@ -1245,9 +1245,9 @@
#ifdef MULTI_THREAD
Def1op
Op1(get_xxxl);
- if (th->tid > *((long *)op1+2)) Fail1;
+ if (xsb_thread_entry > *((long *)op1+2)) Fail1;
// fprintf(stderr,"switchonthread to %p\n",(pb)(*((long *)op1+3+(th->tid))));
- if (!(lpcreg = (pb)(*((long *)op1+3+(th->tid))))) Fail1;
+ if (!(lpcreg = (pb)(*((long *)op1+3+(xsb_thread_entry))))) Fail1;
#else
xsb_exit("Not configured for Multithreading");
#endif
Index: loader_xsb.c
===================================================================
RCS file: /cvsroot/xsb/XSB/emu/loader_xsb.c,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -r1.62 -r1.63
--- loader_xsb.c 23 Jun 2006 14:53:10 -0000 1.62
+++ loader_xsb.c 20 Nov 2006 16:53:42 -0000 1.63
@@ -975,11 +975,11 @@
|
| SYS_MUTEX_LOCK( MUTEX_TABLE );
| for (tdispblk=tdispblkhdr.firstDB ; tdispblk != NULL ; tdispblk=tdispblk->NextDB) {
-| if (th->tid <= tdispblk->MaxThread) {
-| tip = (&(tdispblk->Thread0))[th->tid];
+| if (xsb_thread_entry <= tdispblk->MaxThread) {
+| tip = (&(tdispblk->Thread0))[xsb_thread_entry];
| if (tip) {
| delete_predicate_table(CTXTc tip);
-| (&(tdispblk->Thread0))[th->tid] = (TIFptr) NULL;
+| (&(tdispblk->Thread0))[xsb_thread_entry] = (TIFptr) NULL;
| }
| }
| }
Index: macro_xsb.h
===================================================================
RCS file: /cvsroot/xsb/XSB/emu/macro_xsb.h,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- macro_xsb.h 8 Nov 2006 01:42:57 -0000 1.54
+++ macro_xsb.h 20 Nov 2006 16:53:42 -0000 1.55
@@ -491,10 +491,10 @@
};
typedef struct TDispBlk_t *TDBptr;
-#define TIF_DispatchBlock(pTIF) ((TDBptr) (pTIF)->psc_ptr )
-#define TDB_MaxThread(pTDB) ( (pTDB)->MaxThread )
-#define TDB_TIFArray(pTDB) ( (&(pTDB)->Thread0) )
-#define TDB_PrivateTIF(pTDB,tid) ( TDB_TIFArray(pTDB)[(tid)] )
+#define TIF_DispatchBlock(pTIF) ((TDBptr) (pTIF)->psc_ptr )
+#define TDB_MaxThread(pTDB) ( (pTDB)->MaxThread )
+#define TDB_TIFArray(pTDB) ( (&(pTDB)->Thread0) )
+#define TDB_PrivateTIF(pTDB,tid_pos) ( TDB_TIFArray(pTDB)[(tid_pos)] )
struct TDispBlkHdr_t {
struct TDispBlk_t *firstDB;
@@ -507,13 +507,13 @@
if ( isPrivateTIF(tip) ) { \
TDBptr tdispblk; \
tdispblk = (TDBptr) tip; \
- if (th->tid > TDB_MaxThread(tdispblk)) \
+ if (xsb_thread_entry > TDB_MaxThread(tdispblk)) \
xsb_abort("Table Dispatch block too small"); \
- tip = TDB_PrivateTIF(tdispblk,th->tid); \
+ tip = TDB_PrivateTIF(tdispblk,xsb_thread_entry); \
if (!tip) { \
/* this may not be possible, as it may always be initted in get_tip? */\
tip = New_TIF(CTXTc tdispblk->psc_ptr); \
- TDB_PrivateTIF(tdispblk,th->tid) = tip; \
+ TDB_PrivateTIF(tdispblk,xsb_thread_entry) = tip; \
} \
}
Index: memory_xsb.c
===================================================================
RCS file: /cvsroot/xsb/XSB/emu/memory_xsb.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- memory_xsb.c 8 Nov 2006 17:06:33 -0000 1.38
+++ memory_xsb.c 20 Nov 2006 16:53:42 -0000 1.39
@@ -511,7 +511,7 @@
/* In CONC_COMPL there might be completion stack frames pointing to
subgoal frames owned by other threads which in turn point
to the other thread's completion stack */
- if( subg_tid(subg_ptr) == th->tid )
+ if( subg_tid(subg_ptr) == xsb_thread_id )
#endif
subg_compl_stack_ptr(subg_ptr) =
(CPtr)((byte *)subg_compl_stack_ptr(subg_ptr) + bottom_offset);
Index: psc_xsb.c
===================================================================
RCS file: /cvsroot/xsb/XSB/emu/psc_xsb.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- psc_xsb.c 6 Sep 2006 15:11:27 -0000 1.33
+++ psc_xsb.c 20 Nov 2006 16:53:42 -0000 1.34
@@ -224,10 +224,10 @@
if (TIF_EvalMethod(*tip) != DISPATCH_BLOCK) return *tip;
/* *tip points to 3rd word in TDispBlk, so get addr of TDispBlk */
{ struct TDispBlk_t *tdispblk = (struct TDispBlk_t *) (*tip);
- TIFptr rtip = (TIFptr)((&(tdispblk->Thread0))[th->tid]);
+ TIFptr rtip = (TIFptr)((&(tdispblk->Thread0))[xsb_thread_entry]);
if (!rtip) {
rtip = New_TIF(CTXTc psc);
- (&(tdispblk->Thread0))[th->tid] = rtip;
+ (&(tdispblk->Thread0))[xsb_thread_entry] = rtip;
}
return rtip;
}
Index: schedrev_xsb_i.h
===================================================================
RCS file: /cvsroot/xsb/XSB/emu/schedrev_xsb_i.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- schedrev_xsb_i.h 5 Nov 2006 23:53:15 -0000 1.19
+++ schedrev_xsb_i.h 20 Nov 2006 16:53:42 -0000 1.20
@@ -86,7 +86,7 @@
else
while ( IsNonNULL(consumer_cpf) ) {
#ifdef CONC_COMPL
- if( int_val(nlcp_tid(consumer_cpf)) != th->tid )
+ if( int_val(nlcp_tid(consumer_cpf)) != xsb_thread_id )
;
else
#endif
Index: slginsts_xsb_i.h
===================================================================
RCS file: /cvsroot/xsb/XSB/emu/slginsts_xsb_i.h,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -r1.66 -r1.67
--- slginsts_xsb_i.h 6 Nov 2006 07:56:04 -0000 1.66
+++ slginsts_xsb_i.h 20 Nov 2006 16:53:42 -0000 1.67
@@ -242,14 +242,14 @@
{
/* if is leader and subgoal is marked to be computed by leader */
if( th->deadlock_brk_leader && subg_grabbed(producer_sf) )
- { subg_tid(producer_sf) = th->tid ;
+ { subg_tid(producer_sf) = xsb_thread_id ;
subg_grabbed(producer_sf) = FALSE ;
grabbed = TRUE ;
break ;
}
table_tid = subg_tid(producer_sf) ;
/* if the thread owns the table, proceed */
- if (table_tid == th->tid)
+ if (table_tid == xsb_thread_id)
break ;
waiting_for_thread = find_context(table_tid) ;
if( would_deadlock( waiting_for_thread, th ) )
@@ -283,7 +283,7 @@
{
producer_sf = NewProducerSF(CTXTc CallLUR_Leaf(lookupResults),
CallInfo_TableInfo(callInfo));
- subg_tid(producer_sf) = th->tid;
+ subg_tid(producer_sf) = xsb_thread_id;
subg_grabbed(producer_sf) = 0;
UNLOCK_CALL_TRIE() ;
}
@@ -300,7 +300,7 @@
CallInfo_TableInfo(callInfo));
#endif /* !SHARED_COMPL_TABLES */
#ifdef CONC_COMPL
- subg_tid(producer_sf) = th->tid;
+ subg_tid(producer_sf) = xsb_thread_id;
subg_tag(producer_sf) = INCOMP_ANSWERS;
#endif
UNLOCK_CALL_TRIE() ;
@@ -463,7 +463,7 @@
/* with variant tabling and thus in CONC_COMPL shared tables,
producer_sf == consumer_sf */
- if( subg_tid(producer_sf) == th->tid )
+ if( subg_tid(producer_sf) == xsb_thread_id )
{
#endif
adjust_level(subg_compl_stack_ptr(producer_sf));
@@ -505,9 +505,9 @@
breg,nlcp_prevbreg(breg)));
#ifdef CONC_COMPL
- nlcp_tid(consumer_cpf) = makeint(th->tid);
+ nlcp_tid(consumer_cpf) = makeint(xsb_thread_id);
- if( subg_tid(producer_sf) != th->tid )
+ if( subg_tid(producer_sf) != xsb_thread_id )
{
push_completion_frame(producer_sf);
compl_ext_cons(openreg) = consumer_cpf;
Index: thread_xsb.c
===================================================================
RCS file: /cvsroot/xsb/XSB/emu/thread_xsb.c,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -r1.55 -r1.56
--- thread_xsb.c 15 Nov 2006 16:38:10 -0000 1.55
+++ thread_xsb.c 20 Nov 2006 16:53:42 -0000 1.56
@@ -85,6 +85,7 @@
pthread_t * tid_addr;
#endif
int valid;
+ unsigned int incarn;
int detached ;
th_context * ctxt ;
} xsb_thread_t ;
@@ -131,12 +132,23 @@
th_context *find_context( int id )
{
- if (th_vec[id].valid)
- return th_vec[id].ctxt;
+ if (th_vec[THREAD_ENTRY(id)].valid && th_vec[THREAD_ENTRY(id)].incarn == THREAD_INCARN(id))
+ return th_vec[THREAD_ENTRY(id)].ctxt;
else
return NULL;
}
+static void init_thread_table(void)
+{
+ int i ;
+ for( i = 0; i < MAX_THREADS; i++ )
+ {
+ th_vec[i].valid = 0;
+ th_vec[i].incarn = INC_MASK_RIGHT;
+// th_vec[i].incarn = 0;
+ }
+}
+
/*-------------------------------------------------------------------------*/
/* Thread Creation, Destruction, etc. */
@@ -171,6 +183,7 @@
pos->ctxt = ctxt ;
pos->valid = 1;
+ pos->incarn = (pos->incarn+1) & (INC_MASK_RIGHT);
#ifdef WIN_NT
pos->tid = *t;
pos->tid_addr = t;
@@ -206,12 +219,15 @@
{
pthread_t tid;
th_context *ctxt = (th_context *)arg ;
+ int pos ;
pthread_mutex_lock( &th_mutex );
tid = pthread_self();
/* if the xsb thread id was just created we need to re-initialize it on the
thread context */
- ctxt->tid = th_new( P_PTHREAD_T_P, ctxt ) ;
+ ctxt->tid = pos = th_new( P_PTHREAD_T_P, ctxt ) ;
+ SET_THREAD_INCARN(ctxt->tid, th_vec[pos].incarn ) ;
+
pthread_mutex_unlock( &th_mutex );
emuloop( ctxt, get_ep((Psc)flags[THREAD_RUN]) ) ;
@@ -235,7 +251,7 @@
Cell goal ;
th_context *new_th_ctxt ;
pthread_t_p thr ;
- Integer id ;
+ Integer id, pos ;
goal = ptoc_tag(th, 2) ;
new_th_ctxt = mem_alloc(sizeof(th_context),THREAD_SPACE) ;
@@ -280,9 +296,10 @@
/* This repetition of the call to th_new is need for concurrency reasons */
pthread_mutex_lock( &th_mutex );
- id = th_new( thr, new_th_ctxt ) ;
+ id = pos = th_new( thr, new_th_ctxt ) ;
+ SET_THREAD_INCARN(id, th_vec[pos].incarn ) ;
- if (is_detached) th_vec[id].detached = 1;
+ if (is_detached) th_vec[pos].detached = 1;
pthread_mutex_unlock( &th_mutex );
@@ -296,6 +313,8 @@
void init_system_threads( th_context *ctxt )
{
pthread_t tid = pthread_self();
+
+ init_thread_table();
th_new(P_PTHREAD_T_P, ctxt) ;
}
@@ -460,11 +479,12 @@
int xsb_thread_self()
{
#ifdef MULTI_THREAD
- int id;
+ int pos, id;
pthread_t tid = pthread_self();
pthread_mutex_lock( &th_mutex );
- id = th_find( P_PTHREAD_T_P ) ;
+ id = pos = th_find( P_PTHREAD_T_P ) ;
+ SET_THREAD_INCARN( id, th_vec[pos].incarn ) ;
pthread_mutex_unlock( &th_mutex );
return id;
#else
@@ -531,7 +551,7 @@
case XSB_THREAD_JOIN: {
id = ptoc_int( CTXTc 2 ) ;
pthread_mutex_lock( &th_mutex );
- tid = th_get( id ) ;
+ tid = th_get( THREAD_ENTRY(id) ) ;
pthread_mutex_unlock( &th_mutex );
if( tid == (pthread_t_p)0 )
xsb_existence_error(CTXTc "thread",reg[2],"xsb_thread_join",1,1);
@@ -549,7 +569,7 @@
}
pthread_mutex_lock( &th_mutex );
- th_delete(id);
+ th_delete(THREAD_ENTRY(id));
pthread_mutex_unlock( &th_mutex );
ctop_int( CTXTc 3, rval ) ;
break ;
@@ -558,7 +578,7 @@
case XSB_THREAD_DETACH:
id = ptoc_int( CTXTc 2 ) ;
pthread_mutex_lock( &th_mutex );
- tid = th_get( id ) ;
+ tid = th_get( THREAD_ENTRY(id) ) ;
if( tid == (pthread_t_p)0 )
xsb_abort( "[THREAD] Thread detach - invalid thread id" );
pthread_mutex_unlock( &th_mutex );
@@ -572,7 +592,7 @@
"xsb_thread_detach",1,1);
}
}
- th_vec[id].detached = 1;
+ th_vec[THREAD_ENTRY(id)].detached = 1;
break ;
case XSB_THREAD_SELF:
@@ -724,7 +744,7 @@
/* TLS: may generalize -- right now, just detached/joinable */
case XSB_THREAD_PROPERTY:
- ctop_int(CTXTc 3, th_vec[ ptoc_int(CTXTc 2) ].detached);
+ ctop_int(CTXTc 3, th_vec[ THREAD_ENTRY(ptoc_int(CTXTc 2)) ].detached);
break;
/* for now, one interrupt, but possibly we should allow
@@ -733,13 +753,13 @@
th_context * ctxt_ptr ;
i = ptoc_int(CTXTc 2);
- if (th_vec[i].valid) {
- ctxt_ptr = th_vec[i].ctxt;
+ if (th_vec[THREAD_ENTRY(i)].valid) {
+ ctxt_ptr = th_vec[THREAD_ENTRY(i)].ctxt;
ctxt_ptr->_asynint_val |= THREADINT_MARK;
#ifdef WIN_NT
- PTHREAD_KILL( th_vec[i].tid_addr, SIGINT );
+ PTHREAD_KILL( th_vec[THREAD_ENTRY(i)].tid_addr, SIGINT );
#else
- PTHREAD_KILL( th_vec[i].tid, SIGINT );
+ PTHREAD_KILL( th_vec[THREAD_ENTRY(i)].tid, SIGINT );
#endif
} else {
bld_int(reg+2,i);
Index: thread_xsb.h
===================================================================
RCS file: /cvsroot/xsb/XSB/emu/thread_xsb.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- thread_xsb.h 4 Nov 2006 00:53:00 -0000 1.21
+++ thread_xsb.h 20 Nov 2006 16:53:42 -0000 1.22
@@ -50,6 +50,14 @@
#define PTHREAD_KILL(a,s) pthread_kill(a,s);
#endif
+#define INC_MASK_RIGHT 0x3ff
+#define INC_MASK 0x3ff00000
+#define ENTRY_MASK 0x000fffff
+
+#define THREAD_ENTRY(TID) ((TID)&ENTRY_MASK)
+#define THREAD_INCARN(TID) (((TID)&INC_MASK)>>20)
+#define SET_THREAD_INCARN(TID,INC) ((TID) = ((TID & ~INC_MASK) | (((INC)<<20) & INC_MASK)))
+
typedef struct Mutex_Frame {
pthread_mutex_t th_mutex;
int num_locks;
@@ -78,7 +86,7 @@
extern pthread_cond_t completing_cond;
extern pthread_attr_t detached_attr_gl;
-extern pthread_attr_t normal_attr_gl;
+extern pthread_attr_t normal_attr_gl;
#define PROFILE_MUTEXES 1
#ifdef PROFILE_MUTEXES
@@ -153,18 +161,3 @@
#endif
#endif
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Index: tr_utils.c
===================================================================
RCS file: /cvsroot/xsb/XSB/emu/tr_utils.c,v
retrieving revision 1.126
retrieving revision 1.127
diff -u -r1.126 -r1.127
--- tr_utils.c 15 Nov 2006 16:38:10 -0000 1.126
+++ tr_utils.c 20 Nov 2006 16:53:42 -0000 1.127
@@ -2467,10 +2467,10 @@
SYS_MUTEX_LOCK( MUTEX_TABLE );
for (tdispblk=tdispblkhdr.firstDB
; tdispblk != NULL ; tdispblk=tdispblk->NextDB) {
- if (th->tid <= tdispblk->MaxThread) {
- tip = (&(tdispblk->Thread0))[th->tid];
+ if (xsb_thread_entry <= tdispblk->MaxThread) {
+ tip = (&(tdispblk->Thread0))[xsb_thread_entry];
if (tip) {
- (&(tdispblk->Thread0))[th->tid] = (TIFptr) NULL;
+ (&(tdispblk->Thread0))[xsb_thread_entry] = (TIFptr) NULL;
Free_Private_TIF(tip);
}
}
|