syndicate-2017/racket/syndicate/examples/actor/ceu-leds.rkt

24 lines
790 B
Racket
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#lang syndicate
;; After [1], figure 1.
;;
;; [1] F. SantAnna, N. Rodriguez, R. Ierusalimschy, O. Landsiedel,
;; and P. Tsigas, “Safe system-level concurrency on
;; resource-constrained nodes,” Proc. 11th ACM Conf. Embed. Networked
;; Sens. Syst. - SenSys 13, vol. 13, pp. 114, 2013.
(require/activate syndicate/drivers/timestate)
(define (led-on) (printf "LED ON\n"))
(define (led-off) (printf "led off\n"))
;;---------------------------------------------------------------------------
(spawn (on-stop (led-off))
(on-start (let loop ()
(led-on)
(sleep 2)
(led-off)
(sleep 1)
(loop)))
(stop-when-timeout 10000)) ;; in the paper, it's 1 minute = 60000 milliseconds