instrument PE locking

fix missing unlock in index_pred (if predicate had been indexed while we were
waiting).
This commit is contained in:
Vítor Santos Costa 2010-07-25 11:22:16 +01:00
parent 5b6014175e
commit e031026a62
12 changed files with 81 additions and 64 deletions

View File

@ -1094,7 +1094,7 @@ Yap_absmi(int inp)
/* HEY, leave indexing block alone!! */
/* check if we are the ones using this code */
#if defined(YAPOR) || defined(THREADS)
LOCK(ap->PELock);
PELOCK(1, ap);
PP = ap;
DEC_CLREF_COUNT(cl);
/* clear the entry from the trail */
@ -1395,7 +1395,7 @@ Yap_absmi(int inp)
/* HEY, leave indexing block alone!! */
/* check if we are the ones using this code */
#if defined(YAPOR) || defined(THREADS)
LOCK(ap->PELock);
PELOCK(2, ap);
PP = ap;
DEC_CLREF_COUNT(cl);
/* clear the entry from the trail */
@ -1492,7 +1492,7 @@ Yap_absmi(int inp)
GONext();
}
PP = PREG->u.p.p;
LOCK(PP->PELock);
PELOCK(3, PP);
#endif
PREG = NEXTOP(PREG, p);
GONext();
@ -1676,7 +1676,7 @@ Yap_absmi(int inp)
/* spy_or_trymark */
BOp(spy_or_trymark, Otapl);
LOCK(((PredEntry *)(PREG->u.Otapl.p))->PELock);
PELOCK(5, ((PredEntry *)(PREG->u.Otapl.p)));
PREG = (yamop *)(&(((PredEntry *)(PREG->u.Otapl.p))->OpcodeOfPred));
UNLOCK(((PredEntry *)(PREG->u.Otapl.p))->PELock);
goto dospy;
@ -1691,7 +1691,7 @@ Yap_absmi(int inp)
CUT_wait_leftmost();
#endif /* YAPOR */
if (PREG->u.Otapl.p->PredFlags & LogUpdatePredFlag) {
LOCK(PREG->u.Otapl.p->PELock);
PELOCK(6,PREG->u.Otapl.p);
PP = PREG->u.Otapl.p;
}
if (PREG->u.Otapl.p->CodeOfPred != PREG) {
@ -1774,7 +1774,7 @@ Yap_absmi(int inp)
CUT_wait_leftmost();
#endif /* YAPOR */
/* need to make the DB stable until I get the new clause */
LOCK(PREG->u.Otapl.p->PELock);
PELOCK(7,PREG->u.Otapl.p);
CACHE_Y(B);
PREG = PREG->u.Otapl.d;
LOCK(DynamicLock(PREG));
@ -2069,7 +2069,7 @@ Yap_absmi(int inp)
int erase;
PredEntry *ap = cl->ClPred;
LOCK(ap->PELock);
PELOCK(8,ap);
DEC_CLREF_COUNT(cl);
erase = (cl->ClFlags & ErasedMask) && !(cl->ClRefCount);
if (erase) {
@ -2093,7 +2093,7 @@ Yap_absmi(int inp)
int erase;
PredEntry *ap = cl->ClPred;
LOCK(ap->PELock);
PELOCK(9,ap);
DEC_CLREF_COUNT(cl);
erase = (cl->ClFlags & ErasedMask) && !(cl->ClRefCount);
if (erase) {
@ -7813,7 +7813,7 @@ Yap_absmi(int inp)
#if defined(YAPOR) || defined(THREADS)
{
PredEntry *ap = PredFromDefCode(PREG);
LOCK(ap->PELock);
PELOCK(10,ap);
PP = ap;
if (!ap->cs.p_code.NOfClauses) {
FAIL();
@ -7852,10 +7852,13 @@ Yap_absmi(int inp)
we must take extra care here
*/
if (!PP) {
LOCK(ap->PELock);
PELOCK(11,ap);
}
if (ap->OpcodeOfPred != INDEX_OPCODE) {
/* someone was here before we were */
if (!PP) {
UNLOCKPE(11,ap);
}
PREG = ap->CodeOfPred;
/* for profiler */
save_pc();
@ -7909,12 +7912,13 @@ Yap_absmi(int inp)
}
#if defined(YAPOR) || defined(THREADS)
if (!PP) {
LOCK(pe->PELock);
PELOCK(12,pe);
}
if (!same_lu_block(PREG_ADDR, PREG)) {
PREG = *PREG_ADDR;
if (!PP)
if (!PP) {
UNLOCK(pe->PELock);
}
JMPNext();
}
#endif
@ -7930,9 +7934,10 @@ Yap_absmi(int inp)
#endif /* SHADOW_S */
PREG = pt0;
#if defined(YAPOR) || defined(THREADS)
if (!PP)
if (!PP) {
UNLOCKPE(12,pe);
}
#endif
UNLOCK(pe->PELock);
JMPNext();
}
ENDBOp();
@ -7949,7 +7954,7 @@ Yap_absmi(int inp)
}
#if defined(YAPOR) || defined(THREADS)
if (PP == NULL) {
LOCK(pe->PELock);
PELOCK(13,pe);
}
if (!same_lu_block(PREG_ADDR, PREG)) {
PREG = *PREG_ADDR;
@ -8048,7 +8053,7 @@ Yap_absmi(int inp)
{
PredEntry *pe = PredFromDefCode(PREG);
BEGD(d0);
LOCK(pe->PELock);
PELOCK(14,pe);
if (!(pe->PredFlags & IndexedPredFlag) &&
pe->cs.p_code.NOfClauses > 1) {
/* update ASP before calling IPred */
@ -8446,7 +8451,7 @@ Yap_absmi(int inp)
#if defined(YAPOR) || defined(THREADS)
if (!PP) {
PP = PREG->u.OtaLl.d->ClPred;
LOCK(PP->PELock);
PELOCK(15,PP);
}
#endif
timestamp = IntegerOfTerm(((CELL *)(B_YREG+1))[PREG->u.OtaLl.s]);
@ -8485,7 +8490,7 @@ Yap_absmi(int inp)
/* fprintf(stderr,"- %p/%p %d %d %p\n",PREG,ap,timestamp,ap->TimeStampOfPred,PREG->u.OtILl.d->ClCode);*/
#if defined(YAPOR) || defined(THREADS)
if (!PP) {
LOCK(ap->PELock);
PELOCK(16,ap);
PP = ap;
}
#endif

View File

@ -2112,7 +2112,7 @@ addclause(Term t, yamop *cp, int mode, Term mod, Term *t4ref)
p = RepPredProp(PredPropByFunc(f, mod));
}
Yap_PutValue(AtomAbol, TermNil);
LOCK(p->PELock);
PELOCK(20,p);
pflags = p->PredFlags;
/* we are redefining a prolog module predicate */
if ((pflags & (UserCPredFlag|CArgsPredFlag|NumberDBPredFlag|AtomDBPredFlag|TestPredFlag|AsmPredFlag|CPredFlag|BinaryPredFlag)) ||
@ -2731,7 +2731,7 @@ p_purge_clauses(void)
pred = RepPredProp(PredPropByFunc(fun, mod));
} else
return (FALSE);
LOCK(pred->PELock);
PELOCK(21,pred);
if (pred->PredFlags & StandardPredFlag) {
UNLOCK(pred->PELock);
Yap_Error(PERMISSION_ERROR_MODIFY_STATIC_PROCEDURE, t, "assert/1");
@ -2774,7 +2774,7 @@ p_setspy(void)
} else {
return (FALSE);
}
LOCK(pred->PELock);
PELOCK(22,pred);
restart_spy:
if (pred->PredFlags & (CPredFlag | SafePredFlag)) {
UNLOCK(pred->PELock);
@ -2829,7 +2829,7 @@ p_rmspy(void)
pred = RepPredProp(Yap_PredPropByFunctorNonThreadLocal(fun, mod));
} else
return FALSE;
LOCK(pred->PELock);
PELOCK(23,pred);
if (!(pred->PredFlags & SpiedPredFlag)) {
UNLOCK(pred->PELock);
return FALSE;
@ -2897,7 +2897,7 @@ p_number_of_clauses(void)
}
if (EndOfPAEntr(pe))
return FALSE;
LOCK(RepPredProp(pe)->PELock);
PELOCK(24,RepPredProp(pe));
ncl = RepPredProp(pe)->cs.p_code.NOfClauses;
UNLOCK(RepPredProp(pe)->PELock);
return (Yap_unify_constant(ARG3, MkIntegerTerm(ncl)));
@ -2912,7 +2912,7 @@ p_in_use(void)
pe = get_pred(Deref(ARG1), Deref(ARG2), "$in_use");
if (EndOfPAEntr(pe))
return FALSE;
LOCK(pe->PELock);
PELOCK(25,pe);
out = static_in_use(pe,TRUE);
UNLOCK(pe->PELock);
return(out);
@ -2944,7 +2944,7 @@ p_new_multifile(void)
pe = RepPredProp(PredPropByAtom(at, mod));
else
pe = RepPredProp(PredPropByFunc(Yap_MkFunctor(at, arity),mod));
LOCK(pe->PELock);
PELOCK(26,pe);
pe->PredFlags |= MultiFileFlag;
if (pe->ModuleOfPred == PROLOG_MODULE)
pe->ModuleOfPred = TermProlog;
@ -2966,7 +2966,7 @@ p_is_multifile(void)
pe = get_pred(Deref(ARG1), Deref(ARG2), "$is_multifile");
if (EndOfPAEntr(pe))
return FALSE;
LOCK(pe->PELock);
PELOCK(27,pe);
out = (pe->PredFlags & MultiFileFlag);
UNLOCK(pe->PELock);
return(out);

View File

@ -758,7 +758,7 @@ c_arg(Int argno, Term t, unsigned int arity, unsigned int level, compiler_struct
pop_code(level, cglobs);
}
} else if (IsRefTerm(t)) {
LOCK(cglobs->cint.CurrentPred->PELock);
PELOCK(40,cglobs->cint.CurrentPred);
if (!(cglobs->cint.CurrentPred->PredFlags & (DynamicPredFlag|LogUpdatePredFlag))) {
UNLOCK(cglobs->cint.CurrentPred->PELock);
FAIL("can not compile data base reference",TYPE_ERROR_CALLABLE,t);
@ -1466,7 +1466,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
if (cglobs->onlast) {
Yap_emit(deallocate_op, Zero, Zero, &cglobs->cint);
#ifdef TABLING
LOCK(cglobs->cint.CurrentPred->PELock);
PELOCK(41,cglobs->cint.CurrentPred);
if (is_tabled(cglobs->cint.CurrentPred))
Yap_emit(table_new_answer_op, Zero, cglobs->cint.CurrentPred->ArityOfPE, &cglobs->cint);
else
@ -1487,7 +1487,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
/* never a problem here with a -> b, !, c ; d */
Yap_emit(deallocate_op, Zero, Zero, &cglobs->cint);
#ifdef TABLING
LOCK(cglobs->cint.CurrentPred->PELock);
PELOCK(42,cglobs->cint.CurrentPred);
if (is_tabled(cglobs->cint.CurrentPred)) {
Yap_emit_3ops(cut_op, Zero, Zero, Zero, &cglobs->cint);
Yap_emit(table_new_answer_op, Zero, cglobs->cint.CurrentPred->ArityOfPE, &cglobs->cint);
@ -1535,7 +1535,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
Yap_emit(label_op, l2, Zero, &cglobs->cint);
if (cglobs->onlast) {
#ifdef TABLING
LOCK(cglobs->cint.CurrentPred->PELock);
PELOCK(43,cglobs->cint.CurrentPred);
if (is_tabled(cglobs->cint.CurrentPred))
Yap_emit(table_new_answer_op, Zero, cglobs->cint.CurrentPred->ArityOfPE, &cglobs->cint);
else
@ -1781,7 +1781,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
if (cglobs->onlast) {
Yap_emit(deallocate_op, Zero, Zero, &cglobs->cint);
#ifdef TABLING
LOCK(cglobs->cint.CurrentPred->PELock);
PELOCK(44,cglobs->cint.CurrentPred);
if (is_tabled(cglobs->cint.CurrentPred))
Yap_emit(table_new_answer_op, Zero, cglobs->cint.CurrentPred->ArityOfPE, &cglobs->cint);
else
@ -1811,7 +1811,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
if (cglobs->onlast) {
Yap_emit(deallocate_op, Zero, Zero, &cglobs->cint);
#ifdef TABLING
LOCK(cglobs->cint.CurrentPred->PELock);
PELOCK(45,cglobs->cint.CurrentPred);
if (is_tabled(cglobs->cint.CurrentPred))
Yap_emit(table_new_answer_op, Zero, cglobs->cint.CurrentPred->ArityOfPE, &cglobs->cint);
else
@ -1843,7 +1843,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
if (cglobs->onlast) {
Yap_emit(deallocate_op, Zero, Zero, &cglobs->cint);
#ifdef TABLING
LOCK(cglobs->cint.CurrentPred->PELock);
PELOCK(46,cglobs->cint.CurrentPred);
if (is_tabled(cglobs->cint.CurrentPred))
Yap_emit(table_new_answer_op, Zero, cglobs->cint.CurrentPred->ArityOfPE, &cglobs->cint);
else
@ -1926,7 +1926,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
if (cglobs->onlast) {
Yap_emit(deallocate_op, Zero, Zero, &cglobs->cint);
#ifdef TABLING
LOCK(cglobs->cint.CurrentPred->PELock);
PELOCK(47,cglobs->cint.CurrentPred);
if (is_tabled(cglobs->cint.CurrentPred))
Yap_emit(table_new_answer_op, Zero, cglobs->cint.CurrentPred->ArityOfPE, &cglobs->cint);
else
@ -1961,7 +1961,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
if (cglobs->onlast) {
Yap_emit(deallocate_op, Zero, Zero, &cglobs->cint);
#ifdef TABLING
LOCK(cglobs->cint.CurrentPred->PELock);
PELOCK(48,cglobs->cint.CurrentPred);
if (is_tabled(cglobs->cint.CurrentPred))
Yap_emit(table_new_answer_op, Zero, cglobs->cint.CurrentPred->ArityOfPE, &cglobs->cint);
else
@ -1993,7 +1993,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
Yap_emit(deallocate_op, Zero, Zero, &cglobs->cint);
cglobs->or_found = TRUE;
#ifdef TABLING
LOCK(cglobs->cint.CurrentPred->PELock);
PELOCK(49,cglobs->cint.CurrentPred);
if (is_tabled(cglobs->cint.CurrentPred))
Yap_emit(table_new_answer_op, Zero, cglobs->cint.CurrentPred->ArityOfPE, &cglobs->cint);
else
@ -2008,7 +2008,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
if (cglobs->onlast) {
Yap_emit(deallocate_op, Zero, Zero, &cglobs->cint);
#ifdef TABLING
LOCK(cglobs->cint.CurrentPred->PELock);
PELOCK(50,cglobs->cint.CurrentPred);
if (is_tabled(cglobs->cint.CurrentPred)) {
cglobs->needs_env = TRUE;
Yap_emit_3ops(call_op, (CELL) p0, Zero, Zero, &cglobs->cint);
@ -2810,7 +2810,7 @@ c_layout(compiler_struct *cglobs)
cglobs->cint.cpc->op = nop_op;
} else {
#ifdef TABLING
LOCK(cglobs->cint.CurrentPred->PELock);
PELOCK(51,cglobs->cint.CurrentPred);
if (is_tabled(cglobs->cint.CurrentPred))
cglobs->cint.cpc->op = nop_op;
else
@ -3460,7 +3460,7 @@ Yap_cclause(volatile Term inp_clause, Int NOfArgs, Term mod, volatile Term src)
cglobs.cint.CurrentPred = RepPredProp(PredPropByFunc(FunctorOfTerm(head),mod));
}
/* insert extra instructions to count calls */
LOCK(cglobs.cint.CurrentPred->PELock);
PELOCK(52,cglobs.cint.CurrentPred);
if ((cglobs.cint.CurrentPred->PredFlags & ProfiledPredFlag) ||
(PROFILING && (cglobs.cint.CurrentPred->cs.p_code.FirstClause == NIL))) {
profiling = TRUE;
@ -3482,7 +3482,7 @@ Yap_cclause(volatile Term inp_clause, Int NOfArgs, Term mod, volatile Term src)
if (cglobs.is_a_fact && !cglobs.vtable) {
#ifdef TABLING
LOCK(cglobs.cint.CurrentPred->PELock);
PELOCK(53,cglobs.cint.CurrentPred);
if (is_tabled(cglobs.cint.CurrentPred))
Yap_emit(table_new_answer_op, Zero, cglobs.cint.CurrentPred->ArityOfPE, &cglobs.cint);
else

View File

@ -1895,7 +1895,7 @@ record_lu_at(int position, LogUpdClause *ocl, Term t)
PredEntry *pe;
pe = ocl->ClPred;
LOCK(pe->PELock);
PELOCK(62,pe);
if ((cl = new_lu_db_entry(t,pe)) == NULL) {
UNLOCK(pe->PELock);
return NULL;
@ -1951,7 +1951,7 @@ p_rcda(void)
if (pe) {
LogUpdClause *cl;
LOCK(pe->PELock);
PELOCK(61,pe);
cl = record_lu(pe, Deref(ARG2), MkFirst);
if (cl != NULL) {
TRAIL_CLREF(cl);
@ -2061,7 +2061,7 @@ p_rcdz(void)
if (pe) {
LogUpdClause *cl;
LOCK(pe->PELock);
PELOCK(62,pe);
cl = record_lu(pe, t2, MkLast);
if (cl != NULL) {
TRAIL_CLREF(cl);
@ -2367,7 +2367,7 @@ copy_attachments(CELL *ts)
static Term
GetDBLUKey(PredEntry *ap)
{
LOCK(ap->PELock);
PELOCK(63,ap);
if (ap->PredFlags & NumberDBPredFlag) {
Int id = ap->src.IndxId;
UNLOCK(ap->PELock);
@ -2867,7 +2867,7 @@ FetchDBPropFromKey(Term twork, int flag, int new, char *error_mssg)
pp = RepPredProp(Yap_GetPredPropHavingLock(At, arity, dbmod));
if (!EndOfPAEntr(pp)) {
LOCK(pp->PELock);
PELOCK(64,pp);
if(pp->PredFlags & LogUpdatePredFlag)
UPDATE_MODE = UPDATE_MODE_LOGICAL;
UNLOCK(pp->PELock);
@ -2909,7 +2909,7 @@ lu_nth_recorded(PredEntry *pe, Int Count)
if (cl == NULL)
return FALSE;
#if defined(YAPOR) || defined(THREADS)
LOCK(pe->PELock);
PELOCK(65,pe);
TRAIL_CLREF(cl); /* So that fail will erase it */
INC_CLREF_COUNT(cl);
UNLOCK(pe->PELock);
@ -2991,7 +2991,7 @@ p_nth_instance(void)
Term pred_module;
pe = cl->ClPred;
LOCK(pe->PELock);
PELOCK(66,pe);
if (cl->ClFlags & ErasedMask) {
UNLOCK(pe->PELock);
return FALSE;
@ -3436,7 +3436,7 @@ lu_recorded(PredEntry *pe) {
op_numbers opc = Yap_op_from_opcode(P->opc);
#if defined(YAPOR) || defined(THREADS)
LOCK(pe->PELock);
PELOCK(66,pe);
PP = pe;
#endif
if (opc == _procceed) {
@ -4349,7 +4349,7 @@ EraseEntry(DBRef entryref)
if (entryref->Flags & LogUpdMask &&
!(entryref->Flags & DBClMask)) {
LogUpdClause *luclause = (LogUpdClause *)entryref;
LOCK(luclause->ClPred->PELock);
PELOCK(67,luclause->ClPred);
EraseLogUpdCl(luclause);
UNLOCK(luclause->ClPred->PELock);
return;
@ -4611,7 +4611,7 @@ p_instance(void)
LogUpdClause *cl = (LogUpdClause *)dbr;
PredEntry *ap = cl->ClPred;
LOCK(ap->PELock);
PELOCK(68,ap);
if (cl->ClFlags & ErasedMask) {
UNLOCK(ap->PELock);
return FALSE;
@ -5413,7 +5413,7 @@ p_install_thread_local(void)
} else {
return FALSE;
}
LOCK(pe->PELock);
PELOCK(69,pe);
if (pe->PredFlags & (UserCPredFlag|HiddenPredFlag|CArgsPredFlag|SyncPredFlag|TestPredFlag|AsmPredFlag|StandardPredFlag|CPredFlag|SafePredFlag|IndexedPredFlag|BinaryPredFlag) ||
pe->cs.p_code.NOfClauses) {
return FALSE;

View File

@ -67,7 +67,7 @@ legal_env (CELL *ep)
return (FALSE);
ps = *((CELL *) (Addr (cp) - CellSize));
pe = (PredEntry *) (ps - sizeof (OPREG) - sizeof (Prop));
LOCK(pe->PELock);
PELOCK(70,pe);
if (!ONHEAP (pe) || Unsigned (pe) & 3 || pe->KindOfPE & 0xff00) {
UNLOCK(pe->PELock);
return (FALSE);
@ -100,7 +100,7 @@ DumpActiveGoals (void)
pe = EnvPreg((yamop *)cp);
if (!ONHEAP (pe) || Unsigned (pe) & (sizeof(CELL)-1))
break;
LOCK(pe->PELock);
PELOCK(71,pe);
if (pe->KindOfPE & 0xff00) {
UNLOCK(pe->PELock);
break;
@ -142,7 +142,7 @@ DumpActiveGoals (void)
if (!ONLOCAL (b_ptr) || b_ptr->cp_b == NULL)
break;
pe = Yap_PredForChoicePt(b_ptr);
LOCK(pe->PELock);
PELOCK(72,pe);
{
Functor f;
Term mod = PROLOG_MODULE;

View File

@ -795,7 +795,7 @@ p_execute_nonstop(void)
#if defined(YAPOR) || defined(THREADS)
if (RepPredProp(pe)->PredFlags & LogUpdatePredFlag) {
PP = RepPredProp(pe);
LOCK(PP->PELock);
PELOCK(80,PP);
}
#endif
return CallPredicate(RepPredProp(pe), B, RepPredProp(pe)->cs.p_code.TrueCodeOfPred);
@ -1119,7 +1119,7 @@ Yap_execute_goal(Term t, int nargs, Term mod)
if (pe == NIL) {
return(CallMetaCall(mod));
}
LOCK(ppe->PELock);
PELOCK(81,ppe);
if (IsAtomTerm(t)) {
CodeAdr = RepPredProp (pe)->CodeOfPred;
UNLOCK(ppe->PELock);
@ -1271,7 +1271,7 @@ Yap_RunTopGoal(Term t)
/* we must always start the emulator with Prolog code */
return FALSE;
}
LOCK(ppe->PELock);
PELOCK(82,ppe);
CodeAdr = ppe->CodeOfPred;
UNLOCK(ppe->PELock);
#if !USE_SYSTEM_MALLOC

View File

@ -2546,7 +2546,7 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR)
*/
PredEntry *ap = indx->ClPred;
if (ap != PP)
LOCK(ap->PELock);
PELOCK(85,ap);
#endif
DEC_CLREF_COUNT(indx);
indx->ClFlags &= ~InUseMask;
@ -2570,7 +2570,7 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR)
#if defined(YAPOR) || defined(THREADS)
if (ap != PP)
LOCK(ap->PELock);
PELOCK(86,ap);
#endif
DEC_CLREF_COUNT(cl);
cl->ClFlags &= ~InUseMask;

View File

@ -1159,7 +1159,6 @@ InitFirstWorkerThreadHandle(void)
ThreadHandle.default_yaam_regs =
&Yap_standard_regs;
ThreadHandle.pthread_handle = pthread_self();
ThreadHandle.pthread_handle = pthread_self();
pthread_mutex_init(&FOREIGN_ThreadHandle(0).tlock, NULL);
pthread_mutex_init(&FOREIGN_ThreadHandle(0).tlock_status, NULL);
ThreadHandle.tdetach = MkAtomTerm(AtomFalse);

View File

@ -607,7 +607,7 @@ FindAtom(codeToFind, arity)
pp = RepPredProp(pp->NextOfPE);
if (pp != NIL) {
CODEADDR *out;
LOCK(pp->PELock);
PELOCK(90,pp);
out = &(pp->CodeOfPred)
*arityp = pp->ArityOfPE;
UNLOCK(pp->PELock);
@ -632,7 +632,7 @@ FindAtom(codeToFind, arity)
pp = RepPredProp(pp->NextOfPE);
if (pp != NIL) {
CODEADDR *out;
LOCK(pp->PELock);
PELOCK(91,pp);
out = &(pp->CodeOfPred)
*arityp = pp->ArityOfPE;
UNLOCK(pp->PELock);
@ -3124,7 +3124,7 @@ p_flags(void)
return (FALSE);
if (EndOfPAEntr(pe))
return (FALSE);
LOCK(pe->PELock);
PELOCK(92,pe);
if (!Yap_unify_constant(ARG3, MkIntegerTerm(pe->PredFlags))) {
UNLOCK(pe->PELock);
return(FALSE);

View File

@ -154,7 +154,7 @@ copy_complex_term(CELL *pt0, CELL *pt0_end, int share, int newattvs, CELL *ptf,
DBRef entryref = DBRefOfTerm(d0);
if (entryref->Flags & LogUpdMask) {
LogUpdClause *luclause = (LogUpdClause *)entryref;
LOCK(luclause->ClPred->PELock);
PELOCK(100,luclause->ClPred);
UNLOCK(luclause->ClPred->PELock);
} else {
LOCK(entryref->lock);

View File

@ -128,6 +128,9 @@ typedef struct thandle {
long long int thread_inst_count;
int been_here1;
int been_here2;
#endif
#ifdef DEBUG
int been_here;
#endif
pthread_mutex_t tlock;
pthread_mutex_t tlock_status;

View File

@ -1520,4 +1520,14 @@ PredPropByAtom (Atom at, Term cur_mod)
return Yap_NewPredPropByAtom (ae, cur_mod);
}
#if DEBUG_PELOCKING
#define PELOCK(I,Z) \
{ LOCK((Z)->PELock); (Z)->StatisticsForPred.NOfEntries=(I),(Z)->StatisticsForPred.NOfHeadSuccesses=pthread_self(); }
#define UNLOCKPE(I,Z) \
( (Z)->StatisticsForPred.NOfRetries=(I), UNLOCK((Z)->PELock) )
#else
#define PELOCK(I,Z) LOCK((Z)->PELock)
#define UNLOCKPE(I,Z) UNLOCK((Z)->PELock)
#endif
#endif