Re: Spawn a process without exec



I do that and it seems to work OK. It probably won't be instant: the
parent could set the flag and the child might not see the new value
for several milliseconds. But for most tasks that's not a problem IMO,
since thread create/join can be quite slow and you tend not to make
threads for very small jobs.

If you need finer grained control, you should use a mutex. It
guarantees the cache coherency you need for more exact
synchronisation. (this is my (limited) understanding anyway).

John

On Fri, 20 Aug 2004 02:18:24 +0300, Paul Pogonyshev <pogonyshev gmx net> wrote:
BTW, I assume one doesn't need any synchronization for things like
cancellation flags etc., right?  I.e. main thread could just

        ...
        child_thread->cancellation_flag = 1;
        ...

and the child thread could just

        while (!thread->cancellation_flag && !thread->job_done) {
          ...
        }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]