check read locking on PRWLock

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1002 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2004-02-22 00:35:07 +00:00
parent 6027963867
commit f609e8b93b
5 changed files with 34 additions and 31 deletions

View File

@ -1443,11 +1443,11 @@ Yap_absmi(int inp)
CUT_wait_leftmost();
#endif /* YAPOR */
/* need to make the DB stable until I get the new clause */
READ_LOCK(((PredEntry *)(PREG->u.ld.p))->PRWLock);
READ_LOCK(PREG->u.ld.p->PRWLock);
CACHE_Y(B);
PREG = PREG->u.ld.d;
LOCK(DynamicLock(PREG));
READ_UNLOCK(((PredEntry *)(PREG->u.ld.p))->PRWLock);
READ_UNLOCK(PREG->u.ld.p->PRWLock);
restore_yaam_regs(PREG);
restore_args(PREG->u.ld.s);
#ifdef FROZEN_STACKS

View File

@ -2035,11 +2035,13 @@ p_pred_exists(void)
if (EndOfPAEntr(pe))
return FALSE;
READ_LOCK(pe->PRWLock);
if (pe->PredFlags & HiddenPredFlag)
return(FALSE);
if (pe->PredFlags & HiddenPredFlag){
READ_UNLOCK(pe->PRWLock);
return FALSE;
}
out = (pe->OpcodeOfPred != UNDEF_OPCODE);
READ_UNLOCK(pe->PRWLock);
return(out);
return out;
}
static Int
@ -2376,8 +2378,8 @@ search_for_static_predicate_in_use(PredEntry *p, int check_everything)
}
}
}
READ_UNLOCK(pe->PRWLock);
}
READ_UNLOCK(pe->PRWLock);
env_ptr = b_ptr->cp_env;
b_ptr = b_ptr->cp_b;
}
@ -3142,6 +3144,12 @@ fetch_next_lu_clause(PredEntry *pe, yamop *i_code, Term th, Term tb, Term tr, ya
TRAIL_CLREF(cl); /* So that fail will erase it */
}
#endif
#if defined(YAPOR) || defined(THREADS)
if (PP == pe) {
PP = NULL;
READ_UNLOCK(pe->PRWLock);
}
#endif
#if defined(YAPOR) || defined(THREADS)
WPP = NULL;
#endif
@ -3210,18 +3218,10 @@ p_log_update_clause(void)
WRITE_UNLOCK(pe->PRWLock);
}
#if defined(YAPOR) || defined(THREADS)
if (PP != pe) {
READ_LOCK(pe->PRWLock);
PP = pe;
}
READ_LOCK(pe->PRWLock);
PP = pe;
#endif
ret = fetch_next_lu_clause(pe, pe->cs.p_code.TrueCodeOfPred, t1, ARG3, ARG4, P, TRUE);
#if defined(YAPOR) || defined(THREADS)
if (PP == pe) {
PP = NULL;
READ_UNLOCK(pe->PRWLock);
}
#endif
return ret;
}
@ -3240,6 +3240,12 @@ fetch_next_lu_clause0(PredEntry *pe, yamop *i_code, Term th, Term tb, yamop *cp_
LogUpdClause *cl;
cl = Yap_FollowIndexingCode(pe, i_code, th, tb, TermNil, NEXTOP(PredLogUpdClause0->CodeOfPred,ld), cp_ptr);
#if defined(YAPOR) || defined(THREADS)
if (PP == pe) {
PP = NULL;
READ_UNLOCK(pe->PRWLock);
}
#endif
if (cl == NULL) {
return FALSE;
}
@ -3304,18 +3310,10 @@ p_log_update_clause0(void)
IPred(pe);
}
#if defined(YAPOR) || defined(THREADS)
if (PP != pe) {
READ_LOCK(pe->PRWLock);
PP = pe;
}
READ_LOCK(pe->PRWLock);
PP = pe;
#endif
ret = fetch_next_lu_clause0(pe, pe->cs.p_code.TrueCodeOfPred, t1, ARG3, P, TRUE);
#if defined(YAPOR) || defined(THREADS)
if (PP == pe) {
PP = NULL;
READ_UNLOCK(pe->PRWLock);
}
#endif
return ret;
}
@ -3479,6 +3477,7 @@ add_code_in_pred(PredEntry *pp) {
cl = ClauseCodeToStaticClause(clcode);
code_end = (char *)cl + Yap_SizeOfBlock((CODEADDR)cl);
Yap_inform_profiler_of_clause(clcode, (yamop *)code_end, pp);
READ_UNLOCK(pp->PRWLock);
return;
}
clcode = pp->cs.p_code.TrueCodeOfPred;

View File

@ -571,6 +571,7 @@ c_arg(Int argno, Term t, unsigned int arity, unsigned int level, compiler_struct
READ_UNLOCK(cglobs->cint.CurrentPred->PRWLock);
FAIL("can not compile data base reference",TYPE_ERROR_CALLABLE,t);
} else {
READ_UNLOCK(cglobs->cint.CurrentPred->PRWLock);
Yap_emit((cglobs->onhead ? get_atom_op : put_atom_op), (CELL) t, argno, &cglobs->cint);
}
} else {

View File

@ -109,6 +109,7 @@ DumpActiveGoals (void)
Functor f;
Term mod = TermProlog;
READ_UNLOCK(pe->PRWLock);
f = pe->FunctorOfPred;
if (pe->KindOfPE && hidden (NameOfFunctor (f)))
goto next;
@ -125,9 +126,10 @@ DumpActiveGoals (void)
Yap_plwrite (MkIntTerm (ArityOfFunctor (f)), Yap_DebugPutc, 0);
}
Yap_DebugPutc (Yap_c_error_stream,'\n');
} else {
READ_UNLOCK(pe->PRWLock);
}
next:
READ_UNLOCK(pe->PRWLock);
ep = (CELL *) ep[E_E];
}
first = 1;

View File

@ -51,8 +51,10 @@ CallPredicate(PredEntry *pen, choiceptr cut_pt) {
#ifdef DEPTH_LIMIT
if (DEPTH <= MkIntTerm(1)) {/* I assume Module==0 is prolog */
if (pen->ModuleOfPred) {
if (DEPTH == MkIntTerm(0))
if (DEPTH == MkIntTerm(0)) {
READ_UNLOCK(pen->PRWLock);
return FALSE;
}
else DEPTH = RESET_DEPTH();
}
} else if (pen->ModuleOfPred)
@ -1349,15 +1351,14 @@ Yap_RunTopGoal(Term t)
ppe = RepPredProp(pe);
if (pe != NIL) {
READ_LOCK(ppe->PRWLock);
}
if (pe == NIL) {
} else if (pe == NIL) {
/* we must always start the emulator with Prolog code */
return(FALSE);
}
CodeAdr = ppe->CodeOfPred;
if (pe != NIL) {
READ_UNLOCK(ppe->PRWLock);
}
CodeAdr = ppe->CodeOfPred;
if (Yap_TrailTop - HeapTop < 2048) {
Yap_PrologMode = BootMode;
Yap_Error(SYSTEM_ERROR,TermNil,