I am using cilk api, one parent process sends one message to 5 child processes. But each child process receives the message many times. Why?
Following is my code:
Code: Select all
(load "args.lsp")
(parse-args)
(setq process-number (int (ArgsTree "--process-number")))
(define (child-process)
(setq ppid (sys-info 6)) ; get parent pid
(setq cur-pid (sys-info 7))
(while true
(until (receive ppid msg)
(append-file (string cur-pid ".log") (string msg "\n"))
(sleep 1000)
)
)
)
; parent starts child processes
(dotimes (i process-number)
(spawn 'result (child-process) true)
)
;; parent send one msg to each child process
(setf child-process-list (sync))
(println "child-process-list: " child-process-list)
(dolist (cpid child-process-list)
(println "child process: " cpid)
(send cpid "test msg")
)
;; quit in 10 seconds
(sleep 10000)
(abort)
(exit)
./run-task.lsp --process-number=5
Then in five child process log files, I have these
My questions are:nil
test msg
test msg
test msg
test msg
test msg
test msg
test msg
test msg
test msg
1. why get nil message
2. why get one message repeatedly
3. why receive function needs parent process id(sender id) instead of child process id(receiver id)