[Openmcl-devel] binding with threads

Vijay Mathew vijay.the.lisper at gmail.com
Thu Mar 21 16:38:15 UTC 2013


Hi David,

Thanks for your reply.
I wrote the futures library just as an exercise for learning Common Lisp.
You can download it here: http://ubuntuone.com/4XEnbbdvhccGOqC6WqGJ3S. BTW,
I am still debugging it!

I am on CCL 1.10 dev trunk.

Thanks,

--Vijay


On Thu, Mar 21, 2013 at 7:57 PM, David L. Rager <ragerdl at gmail.com> wrote:

> Hi Vijay,
>
> Welcome to the world of CCL threads!
>
> I don't yet know the answer to your first question.  However, maybe
> you can figure it out with this debugging hint:  I have my own
> multi-threading package, so this will look like pseudo-code.  The most
> common thing I do is interrupt a thread and view its backtrace, which
> should help you in this instance.
>
> (all-threads)  ; or :proc, or (ccl:all-processes) iirc
> (interrupt-thread (nth <n> (all-threads)) #'break)
> :y <thread-number-to-yield-to>
> :b ; for backtrace
> <other common debugging features>
>
> Is your futures library available?  There are various Lisp libraries
> that provide parallel execution.  For example, Vladamir Sedach
> provides an eager futures library [
> http://common-lisp.net/project/eager-future/ ].  Also, I provide a
> "plet" primitive (and others, like "spec-mv-let") for ACL2, which is
> built on top of CL [
> http://www.cs.utexas.edu/users/moore/acl2/current/PLET.html ].  If
> you'd like more information about the latter, feel free to inquire
> (probably off the list-serve).
>
> David
>
> PS -- setf can be different than just using let.  Maybe using or not
> using special variables is part of the issue?
> PPS -- are you on CCL 1.9 or later?  There was a bug for a little bit
> right before the 1.9 release, but I'd be surprised if you were hitting
> it in this simple test case.
>
>
> On Thu, Mar 21, 2013 at 5:41 AM, Vijay Mathew
> <vijay.the.lisper at gmail.com> wrote:
> > Consider this code snippet which demonstrates a "futures" package for
> > executing computations asynchronously:
> >
> > (setf e (futures:make-pool-executor 2))
> > (setf f1 (futures:executor-submit e #'(lambda (x) (* x 2)) 100))
> > (setf f2 (futures:executor-submit e #'(lambda (x y) (+ x y)) 200 300))
> > (format t "~A~%" (futures:future-result f1))
> > (format t "~A~%" (futures:future-result f2))
> > (futures:executor-shutdown e nil)
> >
> > `pool-executor' internally uses a pool of ccl threads for executing the
> jobs
> > submitted to it. Now if I rewrite the same sample using `let' bindings,
> the
> > call to `future-result' just hangs. The threads actually run, but it
> seems
> > `future-result' somehow do not see the updated value of the internal
> > `result' slot.
> >
> > If I load this script, it just hangs the CCL REPL:
> >
> > (let ((e (futures:make-pool-executor 2)))
> >   (let ((f1 (futures:executor-submit e #'(lambda (x) (* x 2)) 100))
> >         (f2 (futures:executor-submit e #'(lambda (x y) (+ x y)) 200
> 300)))
> >     (format t "~A~%" (futures:future-result f1))
> >     (format t "~A~%" (futures:future-result f2))
> >     (futures:executor-shutdown e nil)))
> >
> > Also I would like to learn about the best way to debug programs that use
> CCL
> > threads.
> >
> > I am new to Common Lisp and the kind of support I am getting from this
> > mailing list is very encouraging!
> >
> > Thank you,
> >
> > --Vijay
> >
> >
> > _______________________________________________
> > Openmcl-devel mailing list
> > Openmcl-devel at clozure.com
> > http://clozure.com/mailman/listinfo/openmcl-devel
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.clozure.com/pipermail/openmcl-devel/attachments/20130321/3a6fda72/attachment.html>


More information about the Openmcl-devel mailing list