The observation to be made is that you always should first propagate to a fixpoint and then perform the ask. While not incorrect (asks are monotonic) it would be inefficient anyway. So one why would be to do it as follows:
- Give a space a lock - In order to do propagation, the lock must be acquired and hence remains locked - In order to do an ask, also the lock must be acquired, so there are no issues with synchronization Then, of course, remains the question whether one wants to use OS threads. They are made for big computations and not tiny asks, so that might incur a tremendous overhead. Then, one other thing: you might want to avoid pthreads as they are not fully portable. Please check the boost threads package for a portable and efficient alternative. Cheers Christian -- Christian Schulte, www.ict.kth.se/~cschulte/ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mauricio Toro Sent: Tuesday, March 11, 2008 8:11 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: [gecode-users] Naive CCP ask in Gecode Hello Mr. Schulte, I had many threads doing something like this: //pthread start while ( not root[j+n].assigned() ){ gecode::status()}; gecode::status(); if (root[j+n].val() == 1) rel(this, root[i+n], IRT_EQ, 1); //pthread end But, since Gecode is not thread safe, I should only have one thread asking if the variables are assigned and calling the propagators, right? Thank you very much, Sorry for asking so much. Mauricio 2008/3/11, Christian Schulte <[EMAIL PROTECTED]>: What you can always do, is compute a fixpoint for a space (via status()) and the find out. Christian -- Christian Schulte, www.ict.kth.se/~cschulte/ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mauricio Toro Sent: Monday, March 10, 2008 11:31 PM To: [EMAIL PROTECTED] Subject: Re: [gecode-users] Naive CCP ask in Gecode Hello all, I am trying to use Gecode for make some ccp processes. something like: when a = 1 do tell b = 1 || when b = 1 do tell c = 1 || tell a = 1 || when b = 1 and c = 1 do tell answer = true with a,b,c all in the same intvararray (in the same space), how can i make that? thanks 2008/3/10, Mikael Zayenz Lagerkvist <[EMAIL PROTECTED]>: Hi, If you are using a Gecode Space in a concurrent setting, there are a couple of things that you must observe. First of all, a Space is not reentrant. Thus you must serialize all accesses to the Space object. Secondly, if you want to manipulate two different Spaces concurrently, you must make sure that they do not share any data structures. This is done by passing false as the share argument when cloning a Space. Cheers, Mikael On Mon, Mar 10, 2008 at 12:54 PM, Mauricio Toro <[EMAIL PROTECTED]> wrote: > Hello, > > I am trying to do a naive CCP ask in Gecode and > I am getting "Bus error". > > The idea is doing this process inside a thread > ask (a = 1) do tell( b = 1) > > I am doing it like this: > > while ( not root[i].assigned() ){ }; > if (root[i].val() == 1) > rel(this, root[j], IRT_EQ, 1); > > Any clues why I am getting "Bus error", > > Thanks > > -- > Mauricio Toro Bermudez > Estudiante de Ingeniería de Sistemas > Pontificia Universidad Javeriana, Colombia > > Stagiare à l'Ircam > 1, place Igor-Stravinsky 75004 Paris, > France de 2008 à 2009 > _______________________________________________ > Gecode users mailing list > [EMAIL PROTECTED] > https://www.gecode.org/mailman/listinfo/gecode-users > > -- Mikael Zayenz Lagerkvist, http://www.ict.kth.se/~zayenz/ -- Mauricio Toro Bermudez Estudiante de Ingeniería de Sistemas Pontificia Universidad Javeriana, Colombia Stagiare à l'Ircam 1, place Igor-Stravinsky 75004 Paris, France de 2008 à 2009 -- Mauricio Toro Bermudez Estudiante de Ingeniería de Sistemas Pontificia Universidad Javeriana, Colombia Stagiare à l'Ircam 1, place Igor-Stravinsky 75004 Paris, France de 2008 à 2009
_______________________________________________ Gecode users mailing list [EMAIL PROTECTED] https://www.gecode.org/mailman/listinfo/gecode-users