[並行計算][Scheme][Racket] SRFI 18のmutexとcondition variable

RacketはSRFI 18に対応していることになっているが、mutex-lock!やcondition-variable-signal!などどの手続きはrequireしても定義されない。 mutexやcondition variableのような同期機構ではなく、チャネル通信などの機構を使えということなのだと思うが、ロックを使ったほうが素直に実装できる場合もある。 幸いセマフォはあるようなので、セマフォでmutexやcondition variableを次のように書いた。 ;;; mutex (define (make-mutex) (make-semaphore 1)) (define (mutex-lock! m) (semaphore-wait m)) (define (mutex-unlock-primitive! m) (semaphore-post m)) (define (mutex-unlock! m . rest) (let ((condvar (if (null? rest) #f (car rest)))) (mutex-unlock-primitive! m) (when condvar (condition-variable-wait! Continue reading [並行計算][Scheme][Racket] SRFI 18のmutexとcondition variable


Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /usr/home/bugyo/public_html/b-log/wp-includes/category.php on line 378

Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /usr/home/bugyo/public_html/b-log/wp-includes/category.php on line 379

Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /usr/home/bugyo/public_html/b-log/wp-includes/category.php on line 380

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /usr/home/bugyo/public_html/b-log/wp-includes/category.php on line 381

Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /usr/home/bugyo/public_html/b-log/wp-includes/category.php on line 382

Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /usr/home/bugyo/public_html/b-log/wp-includes/category.php on line 383
Posted in コンピュータ | Tagged , , , , , , | Leave a reply