[racket] future on dual processor machine

From: Jos Koot (jos.koot at telefonica.net)
Date: Tue May 17 04:36:35 EDT 2011

Thanks, I patiently await the fix. I am not in a hurry. Thanks for keeping
me posted, Jos


From: users-bounces at racket-lang.org [mailto:users-bounces at racket-lang.org]
On Behalf Of James Swaine
Sent: 17 May 2011 07:02
To: users at racket-lang.org
Subject: Re: [racket] future on dual processor machine

It looks like you've found a futures bug.  This is being caused by the
interaction between futures and custodians (which DrRacket is using) --
we've identified a fix, but need a little more testing to ensure that it's
working properly.  I will keep you posted here. 



The program below has strange behaviour:
I run it from DrScheme on a dual core machine with two processors.
No other applications active.
When I run it the first time it uses 100% of both processors.
Running it again without leaving DrScheme, it apparently uses one processor
at a time only, although switching frequently. CPU usage histories mirror
each other. How come only one processor is used at a time during the second
Leaving DrScheme, restarting DrScheme and running again gives me 100% of
both processors again.
In all runs processor-count returns 2.
Thanks, Jos

DrRacket, version [3m].
Windows 7.
Intel Pentium dual core CPU E6500.

#lang racket
; check that both processors are used by means of
; windows tool for measurement of CPU usage.
(require racket/unsafe/ops)
(require racket/fixnum)
(require racket/future)
(processor-count) ; -> 2
(define N/2 #e1e8)
(define N (* 2 N/2))
(define V (make-fxvector N))
(define (set-V! f r) (unsafe-fxvector-set! V f r))

(define (task1)
 (for ((i (in-range 50)))
 (for ((k (in-range 0 N/2))) (set-V! k k))))

(define (task2)
 (for ((i (in-range 50)))
 (for ((k (in-range N/2 N))) (set-V! k k))))

; task1 fills the first half of vector V.
; task2 the second half.
; In both tasks the ((i (in-range 50))) is inserted in order to
; force the program to run long enough to see its parallel effects.

(define f (future task1))
(touch f)
; Clear memory avoiding memory overflow during next run.
(set! V #f)
(set! f #f)

-------------- next part --------------
An HTML attachment was scrubbed...

End of users Digest, Vol 69, Issue 45

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20110517/9d3148cc/attachment.html>

Posted on the users mailing list.