Subject: Re: call/cc
From: (Rob Warnock)
Date: Sat, 08 Apr 2006 05:50:16 -0500
Newsgroups: comp.lang.lisp
Message-ID: <>
Philippe Lorin  <> wrote:
| - There doesn't seem to be much documentation about CMUCL's mp package. 
| The best I found is:

That one's pretty good, based as it is on the actual output of
DESCRIBE, though it appears to be based on CMUCL-18e, whereas
CMUCL-19c is current, so you might want to repeat the DESCRIBE
for yourself with whichever version you're using.

| Isn't there anything better, more synthetic?

For questions not answered by DESCRIBE, the easiest thing
[and most accurate] would be to just read the code in the
CMUCL source distribution [which is what I did, once I started
using it seriously], in the file "src/code/multi-proc.lisp".

But if you want something *less* accurate but more narrative  ;-}  ;-}
you might try one of these:

| - The following:
| (mp:make-process (lambda () (print 1) (terpri)))
| works as I'd expect (it prints "1") in a REPL run from the console, or 
| in the *inferior-lisp* buffer in Slime, but in the *slime-repl cmucl* 
| buffer it doesn't print anything. Why?

Sorry, I don't use SLIME, so I can't comment.

| - Finally, while your code looks OK, it doesn't seem to work for me; 
| maybe I'm missing something. If I do:
|    (defun p (x) (print x) (terpri))
|    (defparameter *c*
|       (cstart
|        (p 1)
|        (yield)
|        (p 2)))
| It immediately runs all the body, writing:
|    1
|    2

Oops! Sorry, I *did* say it was untested!  ;-}

I've actually never used MP:DISABLE-PROCESS and MP:ENABLE-PROCESS
before [all the threads I write run to completion (possibly blocking
on I/O)], and I didn't notice that MP:DISABLE-PROCESS *doesn't* give
up the CPU. I think you'll find things work better for you if you
change the definition of YIELD from:

    (defun yield ()
      (mp:disable-process mp:*current-process*))


    (defun yield ()
      (mp:disable-process mp:*current-process*)


    cmu> (defparameter *c*
	   (p 1)
	   (p 2)))

    cmu> (progn (cstep *c*) (mp:process-yield))

    cmu> (progn (cstep *c*) (mp:process-yield))


Is that more like what you expected?


p.s. If you try typing just (CSTEP *C*) to the REPL you'll quickly
discover why I did (PROGN (CSTEP *C*) (MP:PROCESS-YIELD)) instead!  ;-}

p.p.s. Also note that I typo'd MP:ENABLE-PROCESS & MP:DISABLE-PROCESS
as MP-ENABLE-PROCESS & MP-DISABLE-PROCESS in my original posting. Oops.

Rob Warnock			<>
627 26th Avenue			<URL:>
San Mateo, CA 94403		(650)572-2607