maverick_xinwei
maverick_xinwei

Reputation: 33

How to parrallize two sequential commands with the other commands in TCL ?

I have 3 C programs (prog1, prog2, prog3) that I want to call from Tcl. But they have some dependencies :

  1. prog1 must be finished before prog2 is called.
  2. prog1 needs to be called before prog3.
  3. prog1 won't finish(blocked) until prog3 starts executing.
  4. prog3 won't finish until prog2 finishes.

So , some pseudo code to show what I want to achieve.

(prog1 ; prog2) &

prog3

How can I do it in TCL ?

Upvotes: 1

Views: 223

Answers (2)

maverick_xinwei
maverick_xinwei

Reputation: 33

The following solution work fine for me:

exec sh -c "prog1; prog2" & 
exec prog3

Upvotes: 1

Brad Lanam
Brad Lanam

Reputation: 5763

First create a helper script to run prog1 and prog2 (this could be a premade script instead of creating it dynamically):

set fh [open prog1prog2.tcl w]
puts $fh {exec prog1}
puts $fh {exec prog2 &}
close $fh

Then run the script:

exec [info nameofexecutable] prog1prog2.tcl &
exec prog3

If you don't need to wait for the programs to finish, the last exec can have an ampersand appended.

Upvotes: 0

Related Questions