chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] thread makes csi eats lots of cpu


From: Elf
Subject: Re: [Chicken-users] thread makes csi eats lots of cpu
Date: Thu, 10 Jul 2008 20:19:05 -0700 (PDT)


You're running readline in csi, yes?  That blocks the threads.

-elf

On Fri, 11 Jul 2008, William Xu wrote:

Run the following program in csi:

 (use posix srfi-18)

 (thread-start! (let ((max 5)
                      (i 0))
                  (letrec ((thunk (lambda ()
                                    (when (< i max)
                                      (print i)
                                      (thread-sleep! 1)
                                      (set! i (+ i 1)))
                                    (thunk))))
                    thunk)))

I'm expecting it to print 0-5.  But the result is the following:

,----
| #;2> #<thread: thread0>
| #;3> 0
|
| what?
| Error: unbound variable: what?
| #;3> 1
| 2
| 3
| 4
`----

It prints the first number 0, which is called before thread-sleep!.
After that, it'll wait for me to input something random(here, "what?"),
then it'll continute running the thread.

The other problem is that after running this thread, and even after it's
finished, csi starts to takes up to around 97% cpu usage!! on my dual
core macbook.  Then I have to restart csi.






reply via email to

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