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

@@ -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;