[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-users] Problem with threads
From: |
Jeronimo Pellegrini |
Subject: |
[Chicken-users] Problem with threads |
Date: |
Fri, 19 Nov 2010 15:10:28 -0200 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
Hello,
I'm using Chicken from git/master branch (commit
ddaacdfdb11a0a1c0d1e6363b1af3af78746575c).
I recently noticed a change in the behavior of Chicken's
scheduler. See this program:
(use srfi-18)
(define looping-thread
(let ((loop (lambda () (do ((i 0 (add1 i)))
(#f)
(print ':: i)))))
(thread-start! (make-thread loop))))
This does not start the thread on my system (Linux/AMD64), not
even after several seconds, until I did (thread-join! looping-thread).
It also seems to run when I change its quantum:
(thread-quantum-set! looping-thread 10)
But it seems to run for a while only, and then sleeps undefinetly
again.
I udnerstand that Chicken implements SRFI-18 and not SRFI-21,
but isn't there any way to force the scheduler to actually make
one thread start working without pausing indefinetly like that,
other than using thread-join!?
I'm asking becuase I have a didactic implementation of thread pools,
but after creating N threads in a pool, I can't
call thread-join! (because al those threads loop forever, and
I'd like to send tasks from the REPL -- and the REPL would not be
available anymore if I issued thread-join! there).
Also, I believe I've found a little bug. When I force a deadlock:
(define a (make-mutex))
(mutex-lock! a)
(mutex-lock! a)
I get this error:
Error: bad argument count - received 1 but expected 0: #<procedure (##sys#halt)>
Call history:
<syntax> (mutex-lock! a)
<eval> (mutex-lock! a) <--
Looks like this is because scheduler.scm uses (##sys#halt "deadlock")
at line 166, but ##sys#halt has zero arity (if I understand correctly it's
defined in line 216 of library.scm).
Thanks,
J.
- [Chicken-users] Problem with threads,
Jeronimo Pellegrini <=