views:

22

answers:

2

how can i control two processes to run alternately in separate terminal windows. for example i run the code for each on separate terminal 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.

A: 

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.

Mike Dunlavey
i am using ubuntu 9.04. i have never done this before so if you could tell me where to start, it would be great. the complete idea is that the two terminal windows run on a single PC with another computer that acts as receiver connected via specialized hardware (ever heard of the usrp). the receiver PC identifies data from the individual sources and puts them in individual files. the two terminal processes should take turns to transmit.
omrihsan
@omrihsan: I'm not familiar with ubuntu, but since both terminal apps are in one machine and can see a common file system, signalling files should work as I outlined.
Mike Dunlavey
A: 

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?

disown
i am using ubuntu 9.04.the complete idea is that the two terminal windows run on a single PC with another computer that acts as receiver connected via specialized hardware (ever heard of the usrp). the receiver PC identifies data from the individual sources and puts them in individual files. the two terminal processes should take turns to transmit.
omrihsan