diff options
author | Ekaitz Zarraga <ekaitz@elenq.tech> | 2024-12-16 22:17:51 +0100 |
---|---|---|
committer | Ekaitz Zarraga <ekaitz@elenq.tech> | 2024-12-16 22:18:07 +0100 |
commit | d1fd250867ccd56dcaae0da0387d616e310d59ca (patch) | |
tree | 4213663d0daa0efcbf36d885f44c327edb99848d | |
parent | d6ce26104985c313a2795487769e7109657dcb79 (diff) |
simulation: synchronized logger
-rw-r--r-- | TODO.md | 1 | ||||
-rw-r--r-- | simulation.scm | 17 |
2 files changed, 16 insertions, 2 deletions
@@ -10,4 +10,3 @@ retransmissions) - Fix interference calculation -> IMPORTANT - Signal strength, location and rssi (complex, just an extra) -- Make logger concurrency-friendly -> IMPORTANT diff --git a/simulation.scm b/simulation.scm index 09cc16d..01bc347 100644 --- a/simulation.scm +++ b/simulation.scm @@ -25,9 +25,21 @@ (begin exp ...) (loop))) +;; Synchronized logger +(define *output-channel* (make-channel)) +(define (logger) + (forever + (let ((msg (get-message *output-channel*))) + (display msg)))) + (define (ll f . data) (let ((now (gettimeofday))) - (format #t "~a~a - ~?~%" (car now) (cdr now) f data))) + (spawn-fiber + (lambda () + (put-message + *output-channel* + (format #f "~a~a - ~?~%" (car now) (cdr now) f data)))))) + ;; type can be: ;; 'start @@ -197,6 +209,9 @@ (define (run-simulation) + ;; We need a synchronized logger running in a fiber + (spawn-fiber logger) + (let* ((radio-chn (make-channel)) (end-devices (make-hash-table)) (gateways (make-hash-table))) |