I want to slow down a script to a number of cycles per
second with:

  (thread-sleep! (/ 1 12))

That however fails so I ended up importing numbers and
adapting the line to:

  (thread-sleep! (exact->inexact (/ 1 12)))

This call usually blocks within 10 retries. I don't
have a clue what is going on and know little about
scheme but it looks like something about numbers.
These always work:

  (thread-sleep! 0.083)

  (thread-sleep! (/ (round (*
    (exact->inexact (/ 1 12)) 1000)) 1000))

Anybody knows what is the problem?

Here is a script:

------------------------------------------------>8---

CHICKEN
(c)2008-2010 The Chicken Team
(c)2000-2007 Felix L. Winkelmann
Version 4.6.0
freebsd-unix-gnu-x86 [ manyargs dload ptables ]
compiled 2010-10-04 on jail-906 (FreeBSD)

; loading ./.csirc ...
; loading /home/fo/.chicken/lib/chicken/5/readline.import.so ...
; loading /home/fo/.chicken/lib/chicken/5/scheme.import.so ...
; loading /home/fo/.chicken/lib/chicken/5/chicken.import.so ...
; loading /home/fo/.chicken/lib/chicken/5/foreign.import.so ...
; loading /home/fo/.chicken/lib/chicken/5/ports.import.so ...
; loading /home/fo/.chicken/lib/chicken/5/data-structures.import.so ...
; loading /home/fo/.chicken/lib/chicken/5/posix.import.so ...
; loading /home/fo/.chicken/lib/chicken/5/readline.so ...
#;1> (require-extension srfi-18)
; loading library srfi-18 ...
#;2> (require-extension  numbers)

 --- SNIP ---

; loading /home/fo/.chicken/lib/chicken/5/numbers.import.so ...
; loading /home/fo/.chicken/lib/chicken/5/regex.import.so ...
; loading /home/fo/.chicken/lib/chicken/5/numbers.so ...
#;3> (thread-sleep! 1)
#;4> (thread-sleep! (/ (round (* (exact->inexact (/ 1 12)) 1000)) 1000))
#;5> (thread-sleep! (exact->inexact (/ 1 12))) ; <== BLOCKED!
^C
   Call history:

   <syntax>   (thread-sleep! (exact->inexact (/ 1 12)))
   <syntax>   (exact->inexact (/ 1 12))
   <syntax>   (/ 1 12)
   <eval>     (thread-sleep! (exact->inexact (/ 1 12)))
   <eval>     (exact->inexact (/ 1 12))
   <eval>     (/ 1 12)
   print-call-chain     <--

*** user interrupt ***

------------------------------------------------>8---

Regards,
Karel Miklav

_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to