in reply to Logical Conundrum

There are many solutions to that problem. The simplest is that if the processes aren't supposed to run at once, don't start them in parallel! Start one, let it finish, start the next, let it finish, etc.

Otherwise, I'd use a lockfile, or a locking mechanism in a database. You say flock() doesn't work, but I fail to understand why. Since only one process at a time can have an exclusive lock at one time, this seems like an ideal mechanism.

Abigail

Replies are listed 'Best First'.
Re: Re: Logical Conundrum
by mcogan1966 (Monk) on Dec 01, 2003 at 16:00 UTC
    Actually, they DO have to run in parallel, or else the results will take several minutes to generate, rather than just 10-15 seconds. This is crucial, as no one wants to wait long for a multi-headed search engine to print out results.

    As for flock() not working, it's not that it doesn't work, it's that I had the same logic issue as with a flag. But I think I've found the way around that. I'm going to write it up, test it, then post it back here to this thread once I've got it worked out.

      As for flock() not working, it's not that it doesn't work, it's that I had the same logic issue as with a flag.
      I don't understand your logic issues. That is, if you want only one process to act at once (as you said in your original post). But now that you say that you do want them to run in parallel, I'm confused. What do you really want? One-by-one, or in parallel? You can't have both.

      Abigail

        To help clarify for mcogan1966:

        From what he said in the cb, he comes across as wanting to do all the data munging at once, but print out the results together (unmixed) at the end of the processing. So it's kind of one-by-one and parallel combined. Parallel computing , one-by-one results. Which is an ideal use of flock(), for which he seems to be having some odd issues. He hasn't posted code to show us what might be going wrong, but it seems he is passing the locked handle to forked children. Which is just far too wrong :)