Right, no fork under Windows. And I don't want to have multiple instances of the executable running concurrently. My goal is to run multiple simulations varying the parameters and check the execution time. So each simulation should all have the same processing power all the time which is definitely not guaranteed with too much process time slicing. ;-)
Stéphane Lesoinne Assistant INTELSIG group - Département E.E.I. Université de Liege B28 B-4000 Sart-Tilman (Liege 1) - Belgium Tel +32 4 3662652 Fax +32 4 3662649 Thomas Hruska a écrit : > > Brett McCoy wrote: > > On Tue, Apr 7, 2009 at 8:25 AM, Stephane Lesoinne > > <lesoi...@montefiore.ulg.ac.be > <mailto:lesoinne%40montefiore.ulg.ac.be>> wrote: > > > >> I'm trying to execute a loop on an external program file.exe in C > program. > >> I'm using _execl(...) command to achieve this on Windows XP with MSVC++ > >> 2008. > >> I've succeeded in running one instance of the process and now I would > >> like to execute the program file.exe many times but starting a new > >> "file.exe" process should wait the previous instance termination. > >> > >> If I only do > >> > >> int i; > >> for(i=0;i<3;i++){ > >> _execl("file.exe","test",NULL); > >> } > >> > >> this doesn't work because, the three execution of file.exe are started > >> too fast. > >> > >> So, how can I pause the execution of the calling process till the the > >> resume of the current file.exe process ? > > > > Did you try using system()? It only returns after the called program > > finishes running. > > > > Note that the exec...() family of calls will replace the current > > process image with the new one that has been called. Normally you > > would would fork() first and then call exec...(). > > > > -- Brett > > ---------------------------------------------------------- > > "In the rhythm of music a secret is hidden; > > If I were to divulge it, it would overturn the world." > > -- Jelaleddin Rumi > > That won't happen under Windows. Windows doesn't offer a mechanism to > do what Linux exec() does. > > -- > Thomas Hruska > CubicleSoft President > Ph: 517-803-4197 > > *NEW* MyTaskFocus 1.1 > Get on task. Stay on task. > > http://www.CubicleSoft.com/MyTaskFocus/ > <http://www.CubicleSoft.com/MyTaskFocus/> > >