From 418fb0680a0f59b87a7572f6bd9bb11481c0c307 Mon Sep 17 00:00:00 2001 From: vsc Date: Tue, 30 Oct 2001 22:13:18 +0000 Subject: [PATCH] fix locking for YapOr git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@173 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- C/adtdefs.c | 9 ++++----- C/arrays.c | 1 - C/c_interface.c | 2 +- C/cdmgr.c | 2 +- C/dbase.c | 2 +- C/heapgc.c | 4 ++-- C/init.c | 4 ++-- C/stdpreds.c | 2 +- pl/boot.yap | 1 - pl/consult.yap | 2 +- 10 files changed, 13 insertions(+), 16 deletions(-) diff --git a/C/adtdefs.c b/C/adtdefs.c index ae3e06a92..25a3fd9b9 100644 --- a/C/adtdefs.c +++ b/C/adtdefs.c @@ -274,7 +274,6 @@ UnlockedFunctorGetPredProp(Functor f, Term cur_mod) while (p0 && (/* p->KindOfPE != PEProp || only preds in here */ (p->ModuleOfPred != cur_mod && p->ModuleOfPred))) p = RepPredProp(p0 = p->NextOfPE); - READ_UNLOCK(fe->FRWLock); return (p0); } @@ -322,8 +321,8 @@ GetPredProp(Atom ap, unsigned int arity) return(GetPredPropByAtom(ap, *CurrentModulePtr)); WRITE_LOCK(ae->ARWLock); f = InlinedUnlockedMkFunctor(ae, arity); - WRITE_UNLOCK(ae->FRWLock); - READ_LOCK(f->ARWLock); + WRITE_UNLOCK(ae->ARWLock); + READ_LOCK(f->FRWLock); p0 = UnlockedFunctorGetPredProp(f, *CurrentModulePtr); READ_UNLOCK(f->FRWLock); return (p0); @@ -335,7 +334,7 @@ GetPredPropByFunc(Functor f, Term t) { Prop p0; - READ_LOCK(f->ARWLock); + READ_LOCK(f->FRWLock); p0 = UnlockedFunctorGetPredProp(f, t); READ_UNLOCK(f->FRWLock); return (p0); @@ -353,7 +352,7 @@ GetPredPropHavingLock(Atom ap, unsigned int arity) GetPredPropByAtomHavingLock(ae, *CurrentModulePtr); } f = InlinedUnlockedMkFunctor(ae, arity); - READ_LOCK(f->ARWLock); + READ_LOCK(f->FRWLock); p0 = UnlockedFunctorGetPredProp(f, *CurrentModulePtr); READ_UNLOCK(f->FRWLock); return (p0); diff --git a/C/arrays.c b/C/arrays.c index 4daf7740d..eb0aca9f2 100644 --- a/C/arrays.c +++ b/C/arrays.c @@ -754,7 +754,6 @@ p_create_static_array(void) WRITE_LOCK(ae->ARWLock); pp = RepStaticArrayProp(ae->PropsOfAE); - WRITE_LOCK(pp->ArRWLock); while (!EndOfPAEntr(pp) && pp->KindOfPE != ArrayProperty) pp = RepStaticArrayProp(pp->NextOfPE); if (EndOfPAEntr(pp) || pp->ValueOfVE.ints == NULL) { diff --git a/C/c_interface.c b/C/c_interface.c index b754eb357..9d6477dfe 100644 --- a/C/c_interface.c +++ b/C/c_interface.c @@ -677,7 +677,7 @@ YapInit(yap_init_args *yap_init) InitYaamRegs(); #endif /* slaves, waiting for work */ - CurrentModule = 1; + *CurrentModulePtr = MkIntTerm(1); P = GETWORK_FIRST_TIME; exec_absmi(FALSE); abort_optyap("abstract machine unexpected exit"); diff --git a/C/cdmgr.c b/C/cdmgr.c index f2d8c6c31..ab283d59d 100644 --- a/C/cdmgr.c +++ b/C/cdmgr.c @@ -1367,7 +1367,7 @@ p_find_dynamic(void) { Clause *cl = ClauseCodeToClause(q); LOCK(cl->ClLock); - TRAIL_CLREF(cl->ClFlags); + TRAIL_CLREF(cl); INC_CLREF_COUNT(cl); UNLOCK(cl->ClLock); } diff --git a/C/dbase.c b/C/dbase.c index a9a355a17..095dc379f 100644 --- a/C/dbase.c +++ b/C/dbase.c @@ -3034,7 +3034,7 @@ find_next_clause(DBRef ref0) Clause *cl = ClauseCodeToClause(newp); LOCK(cl->ClLock); - TRAIL_CLREF(cl)); + TRAIL_CLREF(cl); INC_DBREF_COUNT(cl); UNLOCK(cl->ClLock); } diff --git a/C/heapgc.c b/C/heapgc.c index a0dfd7db5..4e184093d 100644 --- a/C/heapgc.c +++ b/C/heapgc.c @@ -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_recovered = 0; /* number of heap objects in all garbage collections */ + /* in a single gc */ 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 update_relocation_chain, (CELL *, CELL *)); -static Int tot_gc_recovered = 0; /* number of heap objects in all garbage collections */ - #include "heapgc.h" static int discard_trail_entries = 0; diff --git a/C/init.c b/C/init.c index 3eb6b8d7e..0efe2c4d7 100644 --- a/C/init.c +++ b/C/init.c @@ -722,7 +722,7 @@ InitFlags(void) yap_flags[SOURCE_MODE_FLAG] = FALSE; yap_flags[CHARACTER_ESCAPE_FLAG] = ISO_CHARACTER_ESCAPES; 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; #else yap_flags[ALLOW_ASSERTING_STATIC_FLAG] = TRUE; @@ -809,7 +809,7 @@ InitCodes(void) heap_regs->clausecode.clause = NIL; heap_regs->clausecode.func = NIL; - heap_regs->invisiblechain.Entry = 0; + heap_regs->invisiblechain.Entry = NIL; INIT_RWLOCK(heap_regs->invisiblechain.AERWLock); heap_regs->consultlow = (consult_obj *)AllocCodeSpace(sizeof(consult_obj)*InitialConsultCapacity); diff --git a/C/stdpreds.c b/C/stdpreds.c index 7d666dea1..17ccd9895 100644 --- a/C/stdpreds.c +++ b/C/stdpreds.c @@ -1659,9 +1659,9 @@ p_hidden(void) return (FALSE); READ_LOCK(INVISIBLECHAIN.AERWLock); chain = RepAtom(INVISIBLECHAIN.Entry); - READ_LOCK(INVISIBLECHAIN.AERWLock); while (!EndOfPAEntr(chain) && AbsAtom(chain) != at) chain = RepAtom(chain->NextOfAE); + READ_UNLOCK(INVISIBLECHAIN.AERWLock); if (EndOfPAEntr(chain)) return (FALSE); return (TRUE); diff --git a/pl/boot.yap b/pl/boot.yap index 5928fa402..4f2a097b8 100644 --- a/pl/boot.yap +++ b/pl/boot.yap @@ -15,7 +15,6 @@ * * *************************************************************************/ -% % This one should come first so that disjunctions and long distance % cuts are compiled right with co-routining. % diff --git a/pl/consult.yap b/pl/consult.yap index 45f97ecd3..e890d8189 100644 --- a/pl/consult.yap +++ b/pl/consult.yap @@ -86,7 +86,7 @@ consult(Fs) :- '$consult'(Fs). reconsult(Fs) :- - '$has_yap_or', + '$has_yap_or', fail, throw(error(context_error(reconsult(Fs),clause),query)). reconsult(Fs) :- '$reconsult'(Fs).