[gambit-list] Threads IO question
Patrice Rault
parault2 at wanadoo.fr
Sun Jun 5 02:09:53 EDT 2005
When using thread-join! like this
.............
.............
(define t1 (thread-start! (make-thread (lambda ()
(debug-msg "Thread")))))
(define t2 (thread-start! (make-thread (lambda ()
(thread-sleep! 5)
(debug-msg "Thread Sleep")))))
(define (test)
(debug-msg "Prime Thread")
(thread-join! t1)
(thread-join! t2))
;; or
(define (test2)
(debug-msg "Prime Thread")
(let ((threads-list (list t1 t2)))
(for-each (lambda (t) (thread-join! t))
threads-list)))
;;(test)
(test2)
we got the following transcripts
> gsi
> (load "pepe2.scm")
*****************
Prime Thread
Using Display
#<input-output-port #2 (console)>
#<input-output-port #2 (console)>
Using display with force output
#<input-output-port #2 (console)>
#<input-output-port #2 (console)>
"Using write"
#<input-output-port #2 (console)>
#<input-output-port #2 (console)>
*****************
Thread
Using Display
#<input-output-port #2 (console)>
#<input-output-port #2 (console)>
Using display with force output
#<input-output-port #2 (console)>
#<input-output-port #2 (console)>
"Using write"
#<input-output-port #2 (console)>
#<input-output-port #2 (console)>
*****************
Thread Sleep
Using Display
#<input-output-port #2 (console)>
#<input-output-port #2 (console)>
Using display with force output
#<input-output-port #2 (console)>
#<input-output-port #2 (console)>
"Using write"
#<input-output-port #2 (console)>
#<input-output-port #2 (console)>
"/home/pat/scheme-examples/pepe2.scm"
>
> gsi pepe2.scm
*****************
Prime Thread
Using Display
#<input-port #2 (stdin)>
#<output-port #3 (stdout)>
Using display with force output
#<input-port #2 (stdin)>
#<output-port #3 (stdout)>
"Using write"
#<input-port #2 (stdin)>
#<output-port #3 (stdout)>
*****************
Thread
Using Display
#<input-port #2 (stdin)>
#<output-port #3 (stdout)>
Using display with force output
#<input-port #2 (stdin)>
#<output-port #3 (stdout)>
"Using write"
#<input-port #2 (stdin)>
#<output-port #3 (stdout)>
*****************
Thread Sleep
Using Display
#<input-port #2 (stdin)>
#<output-port #3 (stdout)>
Using display with force output
#<input-port #2 (stdin)>
#<output-port #3 (stdout)>
"Using write"
#<input-port #2 (stdin)>
#<output-port #3 (stdout)>
>
> gsc pepe2.scm
> gcc pepe2.c pepe2_.c -lgambc -o pepe2
> ./pepe2
*****************
Prime Thread
Using Display
#<input-port #2 (stdin)>
#<output-port #3 (stdout)>
Using display with force output
#<input-port #2 (stdin)>
#<output-port #3 (stdout)>
"Using write"
#<input-port #2 (stdin)>
#<output-port #3 (stdout)>
*****************
Thread
Using Display
#<input-port #2 (stdin)>
#<output-port #3 (stdout)>
Using display with force output
#<input-port #2 (stdin)>
#<output-port #3 (stdout)>
"Using write"
#<input-port #2 (stdin)>
#<output-port #3 (stdout)>
*****************
Thread Sleep
Using Display
#<input-port #2 (stdin)>
#<output-port #3 (stdout)>
Using display with force output
#<input-port #2 (stdin)>
#<output-port #3 (stdout)>
"Using write"
#<input-port #2 (stdin)>
#<output-port #3 (stdout)>
>
Regards
pat
Le samedi 04 juin 2005 à 16:36 -0300, leo lencioni a écrit :
> Sorry for not giving all information. Here are the details.
> Attached is pepe.scm (my test program)
> I also attached the following transcripts
>
> gsi-commandline (running pepe.scm in the interpreter from the command line)
> gsi-interactivo (running pepe.scm in the interpreter doing a
> (load "pepe.scm")
> gsc-commandline (running pepe.scm compiled)
> pepe.make (makefile for compiling pepe.scm)
>
> As you see I get output from threads only when running in the
> interpreter and doing a load command.
>
> So my suspicions are:
> 1) Primordial thread finishing too early, and aborting all threads. as
> indicated by Mr. Rault I will try with thread-join sentences so
> primordial will no end until all threads are finished.
> 2) Incorrectly setting up current-input/output-port to each thread in
> compiled code. so thread output goes to the correct place ....
>
> Thanks for your help
>
>
>
>
>
> On 6/4/05, ben at fuhok.net <ben at fuhok.net> wrote:
> > Are you using thread-join! to wait on the termination of the thread
> > that is calling disp-msg?
> >
> > It's kind of hard to debug this problem without seeing a little more
> > of your code.
> >
> > Regards,
> >
> > Ben
> >
> >
> >
> > On Sat, Jun 04, 2005 at 04:29:34AM -0300, leo lencioni wrote:
> > > I'am a scheme newbie and trying to learm scheme. I have the following function:
> > >
> > > (define (disp-msg msg)
> > > (display msg)
> > > (newline))
> > >
> > > I'am using it inside inside a thread to print debug info.
> > >
> > > (thread-start! (make-thread (lambda () (disp-msg "Hello")))
> > >
> > > Running it inside GSI gives no problem and everithing goes well. But
> > > when I compile it they show no output. I'am compiling with gsc with
> > > no options. Linux/debian. Gambit 4.0 b13. What I'am doing wrong? I'am
> > > missing compiler options.
> > >
> > > Thanks for your help
> > > _______________________________________________
> > > Gambit-list mailing list
> > > Gambit-list at iro.umontreal.ca
> > > http://mailman.iro.umontreal.ca/mailman/listinfo/gambit-list
> > _______________________________________________
> > Gambit-list mailing list
> > Gambit-list at iro.umontreal.ca
> > http://mailman.iro.umontreal.ca/mailman/listinfo/gambit-list
> >
>
>
> _______________________________________________
> Gambit-list mailing list
> Gambit-list at iro.umontreal.ca
> http://mailman.iro.umontreal.ca/mailman/listinfo/gambit-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20050605/2d546127/attachment.htm>
More information about the Gambit-list
mailing list