Perhaps you could set something like this up using Jenkins: http://jenkins-ci.org/
One idea for how it might be done:
- The Jenkins master node launches a job on Machine A
- The program running on Machine A contacts the master node (via the Jenkins REST API) to launch a job on Machine B
- Machine A then starts polling the master node, waiting for Machine B's job to go into a completed state
- Machine A continues with its work once the Machine B job is complete
Note that you might be able to dispense with the need for a third machine on which to run the Jenkins server software, and instead make your A or B machine serve a double role as the Jenkins master node as well as a job runner.
This approach means you'd end up with code specific to the Jenkins API code in the processes you're launching on A and B, but nonetheless it might be fairly quick to implement.