Hi people,
here again with more problems.
Look at this small program:
**************************************
:- concurrent proceed/2.
:- use_module(library(concurrency)). :- use_module(library(system)). :- use_module(library(random)).
not(X) :- X,!,fail. not(X).
repeat. repeat :- repeat.
producer(N,0) :- display(end(N)),nl. producer(N,M) :- repeat, random(1,100,I), not(proceed(N,I)), <==== ???? display(proceed(N,I)), nl, asserta_fact(proceed(N,I)), M2 is M - 1, producer(N,M2).
start(0). start(N) :- eng_call(producer(N,5),create,create), M is N - 1, start(M).
*****************************************
This program starts N threads. Each thread calculates a random number. Then, if there is already a fact with this number fails and tries to recalculate another one. If not, asserts a fact with the number and the thread identifier. Each thread repeats this operation 5 times.
If I run this program as it is, it doesn't work. The strange thing is that when I remove the marked line (<==== ????) then it works!!!
Do you experiment the same behaviour? Anybody knows what's wrong?
I'm using Ciao1.5p166 and Linux.
Thanks in advance.
______________________________________________________________________________
_/ _/ _/_| Jordi Sabater Mir / _/ _/ _| IIIA - Institut d'Investigacio en Intel.ligencia Artificial _/ _/___| CSIC - Spanish Scientific Research Council _/ _/____| Campus Universitat Autonoma de Barcelona / _/ _| 08193 Bellaterra, Catalonia, Spain Ph.: +34 3 5809570 Fax.: +34 3 5809661 jsabater(a)iiia.csic.es http://www.iiia.csic.es ______________________________________________________________________________