[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-users] thread makes csi eats lots of cpu
From: |
William Xu |
Subject: |
[Chicken-users] thread makes csi eats lots of cpu |
Date: |
Fri, 11 Jul 2008 10:16:20 +0900 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.2.50 (darwin) |
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.
--
William
http://williamxu.net9.org
The animals are not as stupid as one thinks -- they have neither
doctors nor lawyers.
-- L. Docquier
- [Chicken-users] thread makes csi eats lots of cpu,
William Xu <=