unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* no output from ice-9 `format' after `make-thread'
@ 2002-11-02 22:59 Eric Hanchrow
  2002-11-03  0:00 ` Marius Vollmer
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Hanchrow @ 2002-11-02 22:59 UTC (permalink / raw)



Guile 1.6.0
Linux offby1 2.4.18 #1 Wed Aug 14 22:07:05 PDT 2002 i686 unknown

configured with `--prefix=/usr/local/guile1.6-threads --with-threads'

buildstamp = Thu Oct 31 06:05:53 PST 2002
LIBS =  -lqthreads -lpthread -lcrypt -lm 
libguileinterface = 15:0:3
guileversion = 1.6.0
pkgincludedir = /usr/local/guile1.6-threads/include/guile
pkglibdir = /usr/local/guile1.6-threads/lib/guile
pkgdatadir = /usr/local/guile1.6-threads/share/guile
includedir = /usr/local/guile1.6-threads/include
mandir = /usr/local/guile1.6-threads/man
infodir = /usr/local/guile1.6-threads/info
libdir = /usr/local/guile1.6-threads/lib
localstatedir = /usr/local/guile1.6-threads/var
sharedstatedir = /usr/local/guile1.6-threads/com
sysconfdir = /usr/local/guile1.6-threads/etc
datadir = /usr/local/guile1.6-threads/share
libexecdir = /usr/local/guile1.6-threads/libexec
sbindir = /usr/local/guile1.6-threads/sbin
bindir = /usr/local/guile1.6-threads/bin
exec_prefix = /usr/local/guile1.6-threads
prefix = /usr/local/guile1.6-threads
top_srcdir = top_srcdir_absolute@
srcdir = /usr/local/src/guile-1.6.0/libguile

unmodified source

no deviations from the standard procedure for installing Guile

here's a snippet that demonstrates the behavior I'm wondering about:

    (use-modules (ice-9 threads))
    (use-modules (ice-9 format))
    (for-each
     (lambda (sym)
       (make-thread
        (lambda ()
          (display (format #f "Hey you: ~A~%" sym))
          )))
     (list 'bob 'sam))

Invoke the snippet with `guile -s snippet.scm'.  Note the total lack
of output.

Compare this to what happens if you comment out `(use-modules (ice-9
format))', thus presumably bringing in a different `format' procedure:
you see output as I'd expect, namely

    Hey you: bob
    Hey you: sam

Also compare this to what happens if you eliminate the call to
`make-thread', like this:

    (use-modules (ice-9 format))
    (for-each
     (lambda (sym)
       (display (format #f "Hey you: ~A~%" sym)))
     (list 'bob 'sam))

This, too, produces the output shown above.

The bug, or at least my confusion, is that the first version produces
no output.

-- 
PGP Fingerprint: 3E7B A3F3 96CA 8958 ACC5  C8BD 6337 0041 C01C 5276


_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://mail.gnu.org/mailman/listinfo/bug-guile


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: no output from ice-9 `format' after `make-thread'
  2002-11-02 22:59 no output from ice-9 `format' after `make-thread' Eric Hanchrow
@ 2002-11-03  0:00 ` Marius Vollmer
  2002-11-04 18:52   ` Neil Jerram
  0 siblings, 1 reply; 4+ messages in thread
From: Marius Vollmer @ 2002-11-03  0:00 UTC (permalink / raw)
  Cc: bug-guile

Eric Hanchrow <offby1@blarg.net> writes:

> Invoke the snippet with `guile -s snippet.scm'.  Note the total lack
> of output.

The process exits before it can produce any output.  "guile -s" exits
as soon as the main thread exits.  (The builtin simple-format is
probably fast enough to produce output anyway.)

Try this:

    (use-modules (ice-9 threads))
    (use-modules (ice-9 format))

    (define safe-format
      (let ((m (make-mutex)))
        (lambda args
          (with-mutex m
            (apply format args)))))

    (let ((ts (map (lambda (sym)
                     (make-thread
                      (lambda ()
                        (sleep (random 4))
                        (safe-format #t "Hey you: ~A~%" sym))))
                   (list 'bob 'sam 'huey 'luey 'duey))))
      (for-each join-thread ts))

It uses join-thread to wait for the threads to finish.

Note also that (ice-9 format) is not thread safe... (which I'm going
to fix soonish (when nothing preempts me)).

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405


_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://mail.gnu.org/mailman/listinfo/bug-guile


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: no output from ice-9 `format' after `make-thread'
  2002-11-03  0:00 ` Marius Vollmer
@ 2002-11-04 18:52   ` Neil Jerram
  2002-11-17 15:00     ` Marius Vollmer
  0 siblings, 1 reply; 4+ messages in thread
From: Neil Jerram @ 2002-11-04 18:52 UTC (permalink / raw)
  Cc: Eric Hanchrow, bug-guile

>>>>> "Marius" == Marius Vollmer <mvo@zagadka.ping.de> writes:

    Marius> Note also that (ice-9 format) is not thread safe...

And also -- if it makes any difference -- not async safe.  I saw an
interesting bug the other day when GC happened somewhere in the middle
of (ice-9 format), and then:

GC -> after-gc-hook -> something that calls format again.

It wasn't happy about it.

    Marius> (which I'm going to fix soonish (when nothing preempts
    Marius> me)).

<groan>

        Neil



_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://mail.gnu.org/mailman/listinfo/bug-guile


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: no output from ice-9 `format' after `make-thread'
  2002-11-04 18:52   ` Neil Jerram
@ 2002-11-17 15:00     ` Marius Vollmer
  0 siblings, 0 replies; 4+ messages in thread
From: Marius Vollmer @ 2002-11-17 15:00 UTC (permalink / raw)
  Cc: Eric Hanchrow, bug-guile

Neil Jerram <neil@ossau.uklinux.net> writes:

> >>>>> "Marius" == Marius Vollmer <mvo@zagadka.ping.de> writes:
> 
>     Marius> Note also that (ice-9 format) is not thread safe...
> 
> And also -- if it makes any difference -- not async safe.

Yeah, right, I didn't think about this.  When format is reimplemented
to nbe reentrant, then that will be fixed as well.  Currently, I have
only wrapped format in a monitor, which is not really good enough...

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405


_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://mail.gnu.org/mailman/listinfo/bug-guile


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-11-17 15:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-11-02 22:59 no output from ice-9 `format' after `make-thread' Eric Hanchrow
2002-11-03  0:00 ` Marius Vollmer
2002-11-04 18:52   ` Neil Jerram
2002-11-17 15:00     ` Marius Vollmer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).