protect signal handling with locks for threaded version.
fix close/1 entry in manual (obs from Nicos). fix -f option in chr Makefile. git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@2201 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
708e69a670
commit
78d7105c16
10
C/absmi.c
10
C/absmi.c
@ -10,8 +10,11 @@
|
||||
* *
|
||||
* File: absmi.c *
|
||||
* comments: Portable abstract machine interpreter *
|
||||
* Last rev: $Date: 2008-04-03 10:50:23 $,$Author: vsc $ *
|
||||
* Last rev: $Date: 2008-04-03 13:26:37 $,$Author: vsc $ *
|
||||
* $Log: not supported by cvs2svn $
|
||||
* Revision 1.238 2008/04/03 10:50:23 vsc
|
||||
* term_variables could store local variable in global.
|
||||
*
|
||||
* Revision 1.237 2008/03/26 14:37:07 vsc
|
||||
* more icc fixes
|
||||
*
|
||||
@ -8069,10 +8072,15 @@ Yap_absmi(int inp)
|
||||
H += 2;
|
||||
{
|
||||
PredEntry *pt0;
|
||||
LOCK(ThreadHandlesLock);
|
||||
pt0 = SpyCode;
|
||||
P_before_spy = PREG;
|
||||
PREG = pt0->CodeOfPred;
|
||||
/* for profiler */
|
||||
#ifdef THREADS
|
||||
pthread_mutex_lock(&(ThreadHandle[worker_id].tlock));
|
||||
#endif
|
||||
UNLOCK(ThreadHandlesLock);
|
||||
save_pc();
|
||||
CACHE_A1();
|
||||
#ifdef LOW_LEVEL_TRACER
|
||||
|
@ -10,8 +10,11 @@
|
||||
* File: c_interface.c *
|
||||
* comments: c_interface primitives definition *
|
||||
* *
|
||||
* Last rev: $Date: 2008-04-02 21:44:07 $,$Author: vsc $ *
|
||||
* Last rev: $Date: 2008-04-03 13:26:38 $,$Author: vsc $ *
|
||||
* $Log: not supported by cvs2svn $
|
||||
* Revision 1.111 2008/04/02 21:44:07 vsc
|
||||
* threaded version should ignore saved states (for now).
|
||||
*
|
||||
* Revision 1.110 2008/04/02 17:37:06 vsc
|
||||
* handle out of memory error at thread creation (obs from Paulo Moura).
|
||||
*
|
||||
@ -1663,7 +1666,7 @@ YAP_Init(YAP_init_args *yap_init)
|
||||
Yap_argc = yap_init->Argc;
|
||||
#ifdef THREADS
|
||||
if (yap_init->SavedState) {
|
||||
fprintf(stderr,"[ WARNING: thread Yap will ignore saved state %s ]\n",yap_init->SavedState);
|
||||
fprintf(stderr,"[ WARNING: threaded Yap will ignore saved state %s ]\n",yap_init->SavedState);
|
||||
yap_init->SavedState = NULL;
|
||||
}
|
||||
#endif
|
||||
|
@ -269,7 +269,7 @@ dump_stack(void)
|
||||
|
||||
#if DEBUG
|
||||
fprintf(stderr,"%% YAP regs: P=%p, CP=%p, ASP=%p, H=%p, TR=%p, HeapTop=%p\n",P,CP,ASP,H,TR,HeapTop);
|
||||
fprintf(stderr,"%% YAP mode: %x\n",Yap_PrologMode);
|
||||
fprintf(stderr,"%% YAP mode: %ux\n",(unsigned long int)Yap_PrologMode);
|
||||
if (Yap_ErrorMessage)
|
||||
fprintf(stderr,"%% YAP_ErrorMessage: %s\n",Yap_ErrorMessage);
|
||||
#endif
|
||||
|
@ -2513,6 +2513,9 @@ static Int
|
||||
p_first_signal(void)
|
||||
{
|
||||
LOCK(SignalLock);
|
||||
#ifdef THREADS
|
||||
pthread_mutex_lock(&(ThreadHandle[worker_id].tlock));
|
||||
#endif
|
||||
/* always do wakeups first, because you don't want to keep the
|
||||
non-backtrackable variable bad */
|
||||
if (ActiveSignals & YAP_WAKEUP_SIGNAL) {
|
||||
@ -2586,6 +2589,9 @@ p_first_signal(void)
|
||||
return Yap_unify(ARG1, MkAtomTerm(Yap_LookupAtom("sig_statistics")));
|
||||
}
|
||||
UNLOCK(SignalLock);
|
||||
#ifdef THREADS
|
||||
pthread_mutex_unlock(&(ThreadHandle[worker_id].tlock));
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -2632,6 +2638,9 @@ p_continue_signals(void)
|
||||
if (ActiveSignals & YAP_STATISTICS_SIGNAL) {
|
||||
Yap_signal(YAP_STATISTICS_SIGNAL);
|
||||
}
|
||||
#ifdef THREADS
|
||||
pthread_mutex_unlock(&(ThreadHandle[worker_id].tlock));
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
14
C/threads.c
14
C/threads.c
@ -669,6 +669,13 @@ p_thread_runtime(void)
|
||||
return Yap_unify(ARG1,MkIntegerTerm(ThreadsTotalTime));
|
||||
}
|
||||
|
||||
static Int
|
||||
p_thread_self_lock(void)
|
||||
{ /* '$thread_self_lock' */
|
||||
pthread_mutex_lock(&(ThreadHandle[worker_id].tlock));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void Yap_InitThreadPreds(void)
|
||||
{
|
||||
Yap_InitCPred("$no_threads", 0, p_no_threads, HiddenPredFlag);
|
||||
@ -741,6 +748,12 @@ p_thread_self(void)
|
||||
return Yap_unify(ARG1,MkIntTerm(0));
|
||||
}
|
||||
|
||||
static Int
|
||||
p_thread_self_lock(void)
|
||||
{ /* '$thread_runtime'(+P) */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void Yap_InitThreadPreds(void)
|
||||
{
|
||||
Yap_InitCPred("$thread_self", 1, p_thread_self, SafePredFlag|HiddenPredFlag);
|
||||
@ -749,6 +762,7 @@ void Yap_InitThreadPreds(void)
|
||||
Yap_InitCPred("$nof_threads", 1, p_nof_threads, SafePredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred("$nof_threads_created", 1, p_nof_threads_created, SafePredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred("$thread_runtime", 1, p_thread_runtime, SafePredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred("$self_thread_lock", p_thread_self_lock, SafePredFlag);
|
||||
}
|
||||
|
||||
|
||||
|
@ -51,34 +51,34 @@ EXAMPLES= $(srcdir)/Benchmarks/chrfreeze.chr $(srcdir)/Benchmarks/fib.chr $(srcd
|
||||
all: chr_translate.pl
|
||||
|
||||
chr_translate_bootstrap1.pl: $(srcdir)/chr_translate_bootstrap1.chr
|
||||
$(PL) -l chr_swi_bootstrap.yap \
|
||||
$(PL) -f -l chr_swi_bootstrap.yap \
|
||||
-g "chr_compile_step1('$<','$@'),halt." \
|
||||
-z 'halt(1).'
|
||||
$(PL) -l chr_swi_bootstrap.yap \
|
||||
$(PL) -f -l chr_swi_bootstrap.yap \
|
||||
-g "chr_compile_step2('$<','$@'),halt." \
|
||||
-z 'halt(1).'
|
||||
|
||||
chr_translate_bootstrap2.pl: $(srcdir)/chr_translate_bootstrap2.chr chr_translate_bootstrap1.pl
|
||||
$(PL) -l chr_swi_bootstrap.yap \
|
||||
$(PL) -f -l chr_swi_bootstrap.yap \
|
||||
-g "chr_compile_step2('$<','$@'),halt." \
|
||||
-z 'halt(1).'
|
||||
$(PL) -l chr_swi_bootstrap.yap \
|
||||
$(PL) -f -l chr_swi_bootstrap.yap \
|
||||
-g "chr_compile_step3('$<','$@'),halt." \
|
||||
-z 'halt(1).'
|
||||
|
||||
guard_entailment.pl: $(srcdir)/guard_entailment.chr chr_translate_bootstrap2.pl
|
||||
$(PL) -l chr_swi_bootstrap.yap \
|
||||
$(PL) -f -l chr_swi_bootstrap.yap \
|
||||
-g "chr_compile_step3('$<','$@'),halt." \
|
||||
-z 'halt(1).'
|
||||
|
||||
chr_translate.pl: $(srcdir)/chr_translate.chr chr_translate_bootstrap2.pl guard_entailment.pl
|
||||
$(PL) -l chr_swi_bootstrap.yap \
|
||||
$(PL) -f -l chr_swi_bootstrap.yap \
|
||||
-g "chr_compile_step3('$<','$@'),halt." \
|
||||
-z 'halt(1).'
|
||||
$(PL) -p chr=. -l chr_swi_bootstrap.yap \
|
||||
$(PL) -f -p chr=. -l chr_swi_bootstrap.yap \
|
||||
-g "chr_compile_step4('guard_entailment.chr','guard_entailment.pl'),halt." \
|
||||
-z 'halt(1).'
|
||||
$(PL) -p chr=. -l chr_swi_bootstrap.yap \
|
||||
$(PL) -f -p chr=. -l chr_swi_bootstrap.yap \
|
||||
-g "chr_compile_step4('$<','$@'),halt." \
|
||||
-z 'halt(1).'
|
||||
|
||||
@ -90,7 +90,7 @@ install: chr_translate.pl guard_entailment.pl
|
||||
$(INSTALL) -m 644 $(LIBPL) $(DESTDIR)$(CHRDIR)
|
||||
$(INSTALL) -m 644 $(CHRPL) $(DESTDIR)$(SHAREDIR)/chr.pl
|
||||
$(INSTALL) -m 644 $(srcdir)/README $(DESTDIR)$(CHRDIR)
|
||||
# $(PL) -g make -z halt
|
||||
# $(PL) -f -g make -z halt
|
||||
|
||||
rpm-install: install
|
||||
|
||||
|
@ -4073,9 +4073,9 @@ Closes the stream @var{S}. If @var{S} does not stand for a stream
|
||||
currently opened an error is reported. The streams @code{user_input},
|
||||
@code{user_output}, and @code{user_error} can never be closed.
|
||||
|
||||
By default, give a file name, @code{close/1} will also try to close a
|
||||
corresponding open stream. This feature is not available in ISO or
|
||||
SICStus languages mode and is deprecated.
|
||||
@c By default, give a file name, @code{close/1} will also try to close a
|
||||
@c corresponding open stream. This feature is not available in ISO or
|
||||
@c SICStus languages mode and is deprecated.
|
||||
|
||||
@item close(+@var{S},+@var{O}) [ISO]
|
||||
@findex close/2
|
||||
|
Reference in New Issue
Block a user