开发者

timing control for parallel processes

how can i control two processes to run alternately in separate terminal windows. for example i run the code for each on separate te开发者_JAVA百科rminal windows at 11:59 and both of them wait for the time to be 12:00. at this moment process one starts execution and process two waits for say 10 seconds. then they switch, process two executes and process one waits. in this way they take turns until the process is complete.


Pipes, or named pipes? Each process waits in a read for the other to write a byte to it.

Also, possibly use signal files. Process B sleeps for 100 ms, checks for file Foo, and repeats. When process A creates the file, process B deletes it, and proceeds. Then the reverse happens with file Bar.


You can use System V semaphores or Windows named mutexes (via CreateMutex). You could even resort to file locks. Which OS are you on and what are your restrictions?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜