<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/3.3.2">
</HEAD>
<BODY>
When using thread-join! like this<BR>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="0">--><BR>
.............<BR>
.............<BR>
<BR>
(define t1 (thread-start! (make-thread (lambda () <BR>
                                           (debug-msg "Thread")))))<BR>
<BR>
(define t2 (thread-start! (make-thread (lambda () <BR>
                                          (thread-sleep! 5)<BR>
                                          (debug-msg "Thread Sleep")))))<BR>
<BR>
(define (test)<BR>
  (debug-msg "Prime Thread")<BR>
  (thread-join! t1)<BR>
  (thread-join! t2))<BR>
;; or <BR>
(define (test2)<BR>
  (debug-msg "Prime Thread")<BR>
  (let ((threads-list (list t1 t2)))<BR>
    (for-each (lambda (t) (thread-join! t))<BR>
       threads-list)))<BR>
<BR>
;;(test)<BR>
(test2)<BR>
<BR>
we got the following transcripts <BR>
<BR>
> gsi<BR>
> (load "pepe2.scm")<BR>
*****************<BR>
Prime Thread<BR>
Using Display<BR>
#<input-output-port #2 (console)><BR>
#<input-output-port #2 (console)><BR>
Using display with force output<BR>
#<input-output-port #2 (console)><BR>
#<input-output-port #2 (console)><BR>
"Using write"<BR>
#<input-output-port #2 (console)><BR>
#<input-output-port #2 (console)><BR>
*****************<BR>
Thread<BR>
Using Display<BR>
#<input-output-port #2 (console)><BR>
#<input-output-port #2 (console)><BR>
Using display with force output<BR>
#<input-output-port #2 (console)><BR>
#<input-output-port #2 (console)><BR>
"Using write"<BR>
#<input-output-port #2 (console)><BR>
#<input-output-port #2 (console)><BR>
*****************<BR>
Thread Sleep<BR>
Using Display<BR>
#<input-output-port #2 (console)><BR>
#<input-output-port #2 (console)><BR>
Using display with force output<BR>
#<input-output-port #2 (console)><BR>
#<input-output-port #2 (console)><BR>
"Using write"<BR>
#<input-output-port #2 (console)><BR>
#<input-output-port #2 (console)><BR>
"/home/pat/scheme-examples/pepe2.scm"<BR>
><BR>
<BR>
> gsi pepe2.scm<BR>
*****************<BR>
Prime Thread<BR>
Using Display<BR>
#<input-port #2 (stdin)><BR>
#<output-port #3 (stdout)><BR>
Using display with force output<BR>
#<input-port #2 (stdin)><BR>
#<output-port #3 (stdout)><BR>
"Using write"<BR>
#<input-port #2 (stdin)><BR>
#<output-port #3 (stdout)><BR>
*****************<BR>
Thread<BR>
Using Display<BR>
#<input-port #2 (stdin)><BR>
#<output-port #3 (stdout)><BR>
Using display with force output<BR>
#<input-port #2 (stdin)><BR>
#<output-port #3 (stdout)><BR>
"Using write"<BR>
#<input-port #2 (stdin)><BR>
#<output-port #3 (stdout)><BR>
*****************<BR>
Thread Sleep<BR>
Using Display<BR>
#<input-port #2 (stdin)><BR>
#<output-port #3 (stdout)><BR>
Using display with force output<BR>
#<input-port #2 (stdin)><BR>
#<output-port #3 (stdout)><BR>
"Using write"<BR>
#<input-port #2 (stdin)><BR>
#<output-port #3 (stdout)><BR>
><BR>
<BR>
>  gsc pepe2.scm<BR>
>  gcc pepe2.c pepe2_.c -lgambc -o pepe2<BR>
> ./pepe2<BR>
*****************<BR>
Prime Thread<BR>
Using Display<BR>
#<input-port #2 (stdin)><BR>
#<output-port #3 (stdout)><BR>
Using display with force output<BR>
#<input-port #2 (stdin)><BR>
#<output-port #3 (stdout)><BR>
"Using write"<BR>
#<input-port #2 (stdin)><BR>
#<output-port #3 (stdout)><BR>
*****************<BR>
Thread<BR>
Using Display<BR>
#<input-port #2 (stdin)><BR>
#<output-port #3 (stdout)><BR>
Using display with force output<BR>
#<input-port #2 (stdin)><BR>
#<output-port #3 (stdout)><BR>
"Using write"<BR>
#<input-port #2 (stdin)><BR>
#<output-port #3 (stdout)><BR>
*****************<BR>
Thread Sleep<BR>
Using Display<BR>
#<input-port #2 (stdin)><BR>
#<output-port #3 (stdout)><BR>
Using display with force output<BR>
#<input-port #2 (stdin)><BR>
#<output-port #3 (stdout)><BR>
"Using write"<BR>
#<input-port #2 (stdin)><BR>
#<output-port #3 (stdout)><BR>
><BR>
<BR>
Regards<BR>
pat<BR>
<BR>
Le samedi 04 juin 2005 à 16:36 -0300, leo lencioni a écrit : 
<BLOCKQUOTE TYPE=CITE>
<PRE>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">Sorry for not giving all information. Here are the details. </FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">Attached is pepe.scm (my test program) </FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">I also attached the following transcripts</FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">-->
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000"> gsi-commandline (running pepe.scm in the interpreter from the command line) </FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000"> gsi-interactivo      (running pepe.scm in the interpreter doing a</FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">(load "pepe.scm")</FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000"> gsc-commandline (running pepe.scm compiled) </FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000"> pepe.make          (makefile for compiling pepe.scm)</FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">-->
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">As you see I get output from threads only when running in the</FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">interpreter and doing a load command.</FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">-->
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">So my suspicions are: </FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">1) Primordial thread finishing too early, and aborting all threads. as</FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">indicated by Mr. Rault I will try with thread-join sentences so</FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">primordial will no end until all threads are finished.</FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">2) Incorrectly setting up current-input/output-port to each thread in</FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">compiled code.   so thread output goes to the correct place ....</FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">-->
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">Thanks for your help</FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">-->
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">-->
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">-->
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">-->
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">-->
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">On 6/4/05, <A HREF="mailto:ben@fuhok.net">ben@fuhok.net</A> <<A HREF="mailto:ben@fuhok.net">ben@fuhok.net</A>> wrote:</FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">> Are you using thread-join! to wait on the termination of the thread</FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">> that is calling disp-msg?</FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">> </FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">> It's kind of hard to debug this problem without seeing a little more</FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">> of your code.</FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">> </FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">> Regards,</FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">> </FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">> Ben</FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">> </FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">> </FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">> </FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">> On Sat, Jun 04, 2005 at 04:29:34AM -0300, leo lencioni wrote:</FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">> > I'am a scheme newbie and trying to learm scheme. I have the following function:</FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">> ></FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">> > (define (disp-msg msg)</FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">> >    (display msg)</FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">> >    (newline))</FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">> ></FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">> > I'am using it inside inside a thread to print debug info.</FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">> ></FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">> > (thread-start! (make-thread (lambda () (disp-msg "Hello")))</FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">> ></FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">> > Running it inside GSI gives no problem and everithing goes well. But</FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">> > when I compile it they show no output.  I'am compiling with gsc with</FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">> > no options. Linux/debian. Gambit 4.0 b13. What I'am doing wrong? I'am</FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">> > missing compiler options.</FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">> ></FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">> > Thanks for your help</FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">> > _______________________________________________</FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">> > Gambit-list mailing list</FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">> > <A HREF="mailto:Gambit-list@iro.umontreal.ca">Gambit-list@iro.umontreal.ca</A></FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">> > <A HREF="http://mailman.iro.umontreal.ca/mailman/listinfo/gambit-list">http://mailman.iro.umontreal.ca/mailman/listinfo/gambit-list</A></FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">> _______________________________________________</FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">> Gambit-list mailing list</FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">> <A HREF="mailto:Gambit-list@iro.umontreal.ca">Gambit-list@iro.umontreal.ca</A></FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">> <A HREF="http://mailman.iro.umontreal.ca/mailman/listinfo/gambit-list">http://mailman.iro.umontreal.ca/mailman/listinfo/gambit-list</A></FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">></FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">-->
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">-->
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">_______________________________________________</FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000">Gambit-list mailing list</FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000"><A HREF="mailto:Gambit-list@iro.umontreal.ca">Gambit-list@iro.umontreal.ca</A></FONT>
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="1">--><FONT COLOR="#000000"><A HREF="http://mailman.iro.umontreal.ca/mailman/listinfo/gambit-list">http://mailman.iro.umontreal.ca/mailman/listinfo/gambit-list</A></FONT>
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>