[gambit-list] [Snow-users-list] Using Termite + Snow

andrew cooke andrew at acooke.org
Tue Sep 25 19:24:54 EDT 2007


Hmmm.  Thanks.  That fixed the compile problem, but I now get
*** ERROR IN ##thread-deadlock-action! -- Deadlock detected
even though the same code (just mapping +1 on 1,2,3) works fine in gsc (ie
typed in directly as below, without the Snow package stuff).

Is there something extra I need to do in order to enable Termite in Snow?

The error occurs on the first recv, btw.

Thanks,
Andrew


qp5 lines: gsc
Gambit v4.0.1

> (define (acu-pmap f lst)
    (let ((parent (self)))
      (map (lambda (pid)
             (write (list "recv" pid)) (newline)
             (recv ((,pid reply) reply)))
        (map (lambda (x)
               (write (list "spawn")) (newline)
               (spawn (lambda () (! parent (list (self) (f x))))))
          lst))))
> (acu-pmap (lambda (x) (+ 1 x)) '(1 2 3))
("spawn")
("spawn")
("spawn")
("recv" #<thread #2>)
("recv" #<thread #3>)
("recv" #<thread #4>)
(2 3 4)



but...

(cond-expand
 (gambit
  (##namespace ("" self spawn recv))
  (define (acu-pmap f lst)
    (let ((parent (self)))
      (map (lambda (pid)
             (write (list "recv" pid)) (newline)
             (recv ((,pid reply) reply)))
        (map (lambda (x)
               (write (list "spawn")) (newline)
               (spawn (lambda () (! parent (list (self) (f x))))))
          lst)))))
 (else
  (define (acu-pmap f lst) (map f lst))))

...

(write (list "test pmap" (acu-pmap (lambda (x) (+ 1 x)) '(1 2 3))))

...

("spawn")
("spawn")
("spawn")
("recv" #<thread #2>)
*** ERROR IN ##thread-deadlock-action! -- Deadlock detected




> On 24-Sep-07, at 11:53 PM, andrew cooke wrote:
>
>>
>> [Not sure whether to use Gambit or Snow list - hope duplication not a
>> problem]
>>
>> I have just installed Gambit (4.0.1), Termite (tarball) and Snow
>> (1.1.1).
>> Things seem OK, in that the following works:
>>
>>> gsi
>> Gambit v4.0.1
>>
>>> (self)
>> #<thread #1 primordial>
>>
>> So I then defined the following in a Snow package:
>>
>> (cond-expand
>>  (gambit
>>   (define (acu-pmap f lst)
>>     (let ((parent (self)))
>>       (map (lambda (pid)
>>              (recv ((,pid reply) reply)))
>>            (map (lambda (x)
>>                   (spawn (lambda () (! parent (list (self) (f x))))))
>>                 lst)))))
>>  (else
>>   (define (acu-pmap f lst) (map f lst))))
>>
>> However, when I try to use code that calls acu-pmap I get the error
>> (line
>> 30 is the "let"):
>> *** ERROR IN ac-utils/v1#acu-pmap, "ac-utils.scm"@30.20 -- Unbound
>> variable: ac-utils/v1#self
>>
>> Can anyone suggest why this doesn't work and/or how I can fix it?
>>
>> Thanks,
>> Andrew
>
> Snow will prepend the package name to "self", i.e "mypack#self",
> because self is not imported from another package.  I suggest you (or
> Guillaume Germain) write a "termite" package which exports functions
> like self, make-node, etc.  Alternatively just add this namespace
> declaration at the top:
>
> (##namespace ("" self make-node))
>
> You will need to add all the Termite functions/special forms that you
> want to import.
>
> Marc
>
>





More information about the Gambit-list mailing list