guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Coop threads reliability !?


From: Andrea Pippa
Subject: Coop threads reliability !?
Date: Sun, 21 Oct 2001 16:11:25 +0200

Hi everybody !

I'm using guile in a project, and this project needs threads. For the
use I do, coop threads are just fine, since I just have some event
processing loops to manage. My problem is that coop threads seem to be
somewhat unaffidable... !? is that a known issue in guile or is that
something new ? I'm using guile 1.5.2, and the bug is that...
pratically... sometimes some thread hang without any motivation.
That happens in my application that is quite complex, and threads
sometimes may even terminate because of my bugs, but happens sometimes
even in that code:

(define mutex (make-mutex))

(call-with-new-thread
 (lambda ()
   (do ((x 1 (+ x 1)))
       (#f #t)
     (begin
       (lock-mutex mutex)
       (display "******")
       (display (string-append "A:" (number->string x) "\n"))
       (unlock-mutex mutex)
       )))

 (lambda args args))

(call-with-new-thread
 (lambda ()
   (do ((x 1 (+ x 1)))
       (#f #t)
     (begin
       (lock-mutex mutex)
       (display "******")
       (display (string-append "B:" (number->string x) "\n"))
       (unlock-mutex mutex)
       )))
 (lambda args args))

(do ((x 1 (+ x 1)))
    (#f #t)
  (begin
    (lock-mutex mutex)
    (display "++++++")
    (display (string-append "C:" (number->string x) "\n"))
    (unlock-mutex mutex)
    )))

What happens (sometimes, completely random) is that this outputs only
first 5 numbers of A thread, then hangs.
To me this happens something like 1 every 20/30 run, but if I code more
complex examples, this becomes much worse. If you like I can send a
somewhat more complex example (a bit longer though) that hangs 1 every
5/6...
PS: this example hangs sometimes even if I remove the mutex thing, just
keeping the 3 loops printing wild numbers without having exclusive
access to the output.

... any idea !? any help would be really appreciated ! thanks !! (ps:
I've not subscribes the mailing list, so please reply to my address...
thanks !:)

Bye !

Pyper.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]