Hi

 

The following runs 100% of my CPU, but when I uncomment the when-clause nothing happens (0% CPU)

(processor-count) yields 8 on my PC.

 

#lang racket

 

(define sema (make-semaphore 1))

 

(define (make-th i)

(λ ()

  (let loop ((a 0))

#;(when (zero? (modulo a #e1e6))

    (semaphore-wait sema)

    "do what you have to do without disturbing other futures"

    (semaphore-post sema))

   (loop (add1 a)))))

 

(for ((i (in-range (processor-count)))) (future (make-th i)))

 

(sleep 10)

(exit)

 

Can’t I use semaphores in futures? Help please.

I have used semaphores earlier without trouble.

Jos (Jacob J. A. Koot)

 

PS My version:

Welcome to DrRacket, version 8.2 [cs].

Language: racket [custom]; memory limit: 6000 MB.

 

--
You received this message because you are subscribed to the Google Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/2E9C7601-1AC5-42A3-BA23-0B759791CD1B%40hxcore.ol.

Reply via email to