fix locking for YapOr

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@173 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2001-10-30 22:13:18 +00:00
parent a543874856
commit 418fb0680a
10 changed files with 13 additions and 16 deletions

View File

@ -274,7 +274,6 @@ UnlockedFunctorGetPredProp(Functor f, Term cur_mod)
while (p0 && (/* p->KindOfPE != PEProp || only preds in here */ while (p0 && (/* p->KindOfPE != PEProp || only preds in here */
(p->ModuleOfPred != cur_mod && p->ModuleOfPred))) (p->ModuleOfPred != cur_mod && p->ModuleOfPred)))
p = RepPredProp(p0 = p->NextOfPE); p = RepPredProp(p0 = p->NextOfPE);
READ_UNLOCK(fe->FRWLock);
return (p0); return (p0);
} }
@ -322,8 +321,8 @@ GetPredProp(Atom ap, unsigned int arity)
return(GetPredPropByAtom(ap, *CurrentModulePtr)); return(GetPredPropByAtom(ap, *CurrentModulePtr));
WRITE_LOCK(ae->ARWLock); WRITE_LOCK(ae->ARWLock);
f = InlinedUnlockedMkFunctor(ae, arity); f = InlinedUnlockedMkFunctor(ae, arity);
WRITE_UNLOCK(ae->FRWLock); WRITE_UNLOCK(ae->ARWLock);
READ_LOCK(f->ARWLock); READ_LOCK(f->FRWLock);
p0 = UnlockedFunctorGetPredProp(f, *CurrentModulePtr); p0 = UnlockedFunctorGetPredProp(f, *CurrentModulePtr);
READ_UNLOCK(f->FRWLock); READ_UNLOCK(f->FRWLock);
return (p0); return (p0);
@ -335,7 +334,7 @@ GetPredPropByFunc(Functor f, Term t)
{ {
Prop p0; Prop p0;
READ_LOCK(f->ARWLock); READ_LOCK(f->FRWLock);
p0 = UnlockedFunctorGetPredProp(f, t); p0 = UnlockedFunctorGetPredProp(f, t);
READ_UNLOCK(f->FRWLock); READ_UNLOCK(f->FRWLock);
return (p0); return (p0);
@ -353,7 +352,7 @@ GetPredPropHavingLock(Atom ap, unsigned int arity)
GetPredPropByAtomHavingLock(ae, *CurrentModulePtr); GetPredPropByAtomHavingLock(ae, *CurrentModulePtr);
} }
f = InlinedUnlockedMkFunctor(ae, arity); f = InlinedUnlockedMkFunctor(ae, arity);
READ_LOCK(f->ARWLock); READ_LOCK(f->FRWLock);
p0 = UnlockedFunctorGetPredProp(f, *CurrentModulePtr); p0 = UnlockedFunctorGetPredProp(f, *CurrentModulePtr);
READ_UNLOCK(f->FRWLock); READ_UNLOCK(f->FRWLock);
return (p0); return (p0);

View File

@ -754,7 +754,6 @@ p_create_static_array(void)
WRITE_LOCK(ae->ARWLock); WRITE_LOCK(ae->ARWLock);
pp = RepStaticArrayProp(ae->PropsOfAE); pp = RepStaticArrayProp(ae->PropsOfAE);
WRITE_LOCK(pp->ArRWLock);
while (!EndOfPAEntr(pp) && pp->KindOfPE != ArrayProperty) while (!EndOfPAEntr(pp) && pp->KindOfPE != ArrayProperty)
pp = RepStaticArrayProp(pp->NextOfPE); pp = RepStaticArrayProp(pp->NextOfPE);
if (EndOfPAEntr(pp) || pp->ValueOfVE.ints == NULL) { if (EndOfPAEntr(pp) || pp->ValueOfVE.ints == NULL) {

View File

@ -677,7 +677,7 @@ YapInit(yap_init_args *yap_init)
InitYaamRegs(); InitYaamRegs();
#endif #endif
/* slaves, waiting for work */ /* slaves, waiting for work */
CurrentModule = 1; *CurrentModulePtr = MkIntTerm(1);
P = GETWORK_FIRST_TIME; P = GETWORK_FIRST_TIME;
exec_absmi(FALSE); exec_absmi(FALSE);
abort_optyap("abstract machine unexpected exit"); abort_optyap("abstract machine unexpected exit");

View File

@ -1367,7 +1367,7 @@ p_find_dynamic(void)
{ {
Clause *cl = ClauseCodeToClause(q); Clause *cl = ClauseCodeToClause(q);
LOCK(cl->ClLock); LOCK(cl->ClLock);
TRAIL_CLREF(cl->ClFlags); TRAIL_CLREF(cl);
INC_CLREF_COUNT(cl); INC_CLREF_COUNT(cl);
UNLOCK(cl->ClLock); UNLOCK(cl->ClLock);
} }

View File

@ -3034,7 +3034,7 @@ find_next_clause(DBRef ref0)
Clause *cl = ClauseCodeToClause(newp); Clause *cl = ClauseCodeToClause(newp);
LOCK(cl->ClLock); LOCK(cl->ClLock);
TRAIL_CLREF(cl)); TRAIL_CLREF(cl);
INC_DBREF_COUNT(cl); INC_DBREF_COUNT(cl);
UNLOCK(cl->ClLock); UNLOCK(cl->ClLock);
} }

View File

@ -37,6 +37,8 @@ unsigned int gc_calls = 0; /* number of times GC has been called */
static Int tot_gc_time = 0; /* total time spent in GC */ static Int tot_gc_time = 0; /* total time spent in GC */
static Int tot_gc_recovered = 0; /* number of heap objects in all garbage collections */
/* in a single gc */ /* in a single gc */
UInt total_marked; /* number of heap objects marked */ UInt total_marked; /* number of heap objects marked */
@ -77,8 +79,6 @@ STATIC_PROTO(choiceptr update_B_H, (choiceptr, CELL *, CELL *, CELL *));
STATIC_PROTO(void compact_heap, (void)); STATIC_PROTO(void compact_heap, (void));
STATIC_PROTO(void update_relocation_chain, (CELL *, CELL *)); STATIC_PROTO(void update_relocation_chain, (CELL *, CELL *));
static Int tot_gc_recovered = 0; /* number of heap objects in all garbage collections */
#include "heapgc.h" #include "heapgc.h"
static int discard_trail_entries = 0; static int discard_trail_entries = 0;

View File

@ -722,7 +722,7 @@ InitFlags(void)
yap_flags[SOURCE_MODE_FLAG] = FALSE; yap_flags[SOURCE_MODE_FLAG] = FALSE;
yap_flags[CHARACTER_ESCAPE_FLAG] = ISO_CHARACTER_ESCAPES; yap_flags[CHARACTER_ESCAPE_FLAG] = ISO_CHARACTER_ESCAPES;
yap_flags[WRITE_QUOTED_STRING_FLAG] = FALSE; yap_flags[WRITE_QUOTED_STRING_FLAG] = FALSE;
#if defined(YAPOR) || defined(THREADS) #if (defined(YAPOR) || defined(THREADS)) && VSC_FOR_YAPOR
yap_flags[ALLOW_ASSERTING_STATIC_FLAG] = FALSE; yap_flags[ALLOW_ASSERTING_STATIC_FLAG] = FALSE;
#else #else
yap_flags[ALLOW_ASSERTING_STATIC_FLAG] = TRUE; yap_flags[ALLOW_ASSERTING_STATIC_FLAG] = TRUE;
@ -809,7 +809,7 @@ InitCodes(void)
heap_regs->clausecode.clause = NIL; heap_regs->clausecode.clause = NIL;
heap_regs->clausecode.func = NIL; heap_regs->clausecode.func = NIL;
heap_regs->invisiblechain.Entry = 0; heap_regs->invisiblechain.Entry = NIL;
INIT_RWLOCK(heap_regs->invisiblechain.AERWLock); INIT_RWLOCK(heap_regs->invisiblechain.AERWLock);
heap_regs->consultlow = (consult_obj *)AllocCodeSpace(sizeof(consult_obj)*InitialConsultCapacity); heap_regs->consultlow = (consult_obj *)AllocCodeSpace(sizeof(consult_obj)*InitialConsultCapacity);

View File

@ -1659,9 +1659,9 @@ p_hidden(void)
return (FALSE); return (FALSE);
READ_LOCK(INVISIBLECHAIN.AERWLock); READ_LOCK(INVISIBLECHAIN.AERWLock);
chain = RepAtom(INVISIBLECHAIN.Entry); chain = RepAtom(INVISIBLECHAIN.Entry);
READ_LOCK(INVISIBLECHAIN.AERWLock);
while (!EndOfPAEntr(chain) && AbsAtom(chain) != at) while (!EndOfPAEntr(chain) && AbsAtom(chain) != at)
chain = RepAtom(chain->NextOfAE); chain = RepAtom(chain->NextOfAE);
READ_UNLOCK(INVISIBLECHAIN.AERWLock);
if (EndOfPAEntr(chain)) if (EndOfPAEntr(chain))
return (FALSE); return (FALSE);
return (TRUE); return (TRUE);

View File

@ -15,7 +15,6 @@
* * * *
*************************************************************************/ *************************************************************************/
%
% This one should come first so that disjunctions and long distance % This one should come first so that disjunctions and long distance
% cuts are compiled right with co-routining. % cuts are compiled right with co-routining.
% %

View File

@ -86,7 +86,7 @@ consult(Fs) :-
'$consult'(Fs). '$consult'(Fs).
reconsult(Fs) :- reconsult(Fs) :-
'$has_yap_or', '$has_yap_or', fail,
throw(error(context_error(reconsult(Fs),clause),query)). throw(error(context_error(reconsult(Fs),clause),query)).
reconsult(Fs) :- reconsult(Fs) :-
'$reconsult'(Fs). '$reconsult'(Fs).