unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* ice-9 threads parallel
@ 2011-10-26 15:38 Vok Vojwo
  2011-10-26 18:02 ` Andy Wingo
  0 siblings, 1 reply; 2+ messages in thread
From: Vok Vojwo @ 2011-10-26 15:38 UTC (permalink / raw)
  To: guile-user

On my system current-processor-count returns 2. I use random with the
same seed: first in normal evaluation order and second in parallel.
But the two evaluations return the same result. I expected that the
order of the random numbers differs but it is the same. Why?

This is the example:

(use-modules (ice-9 threads))

(define (slow-random)
  (sleep 1)
  (random 10))

(begin
  (set! *random-state* (seed->random-state 42))
  (values
   (list
     (slow-random)
     (slow-random)
     (slow-random)
     (slow-random)
     (slow-random))
   (list
     (slow-random)
     (slow-random)
     (slow-random)
     (slow-random)
     (slow-random))))

(begin
  (set! *random-state* (seed->random-state 42))
  (parallel
   (list
     (slow-random)
     (slow-random)
     (slow-random)
     (slow-random)
     (slow-random))
   (list
     (slow-random)
     (slow-random)
     (slow-random)
     (slow-random)
     (slow-random))))

(current-processor-count)



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-10-26 18:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-26 15:38 ice-9 threads parallel Vok Vojwo
2011-10-26 18:02 ` Andy Wingo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).