Re: locking with shared variables

2003-11-21 Thread Stefan Bergler
Yes. I got you. This way it makes sense. You lock the variable locally as you work with it / modify it. I was not thinking of this concept. I concentrated more on my problem to have a scheduler thread that distributes the work among some worker threads. (And even a bit more complex). Therefore

Re: locking with shared variables

2003-11-20 Thread Mike Pomraning
On Thu, 20 Nov 2003, Stefan Bergler wrote: > It is sufficient to have ONE lock within ONE thread, to own the shared > variable as long as this lock is within the scope of the thread. This > lock is kind of inheritet by any called sub function and it does not > make a difference if the subfunction

locking with shared variables

2003-11-20 Thread Stefan Bergler
Hi! I was not sure about the 'scope' of a lock. So I wrote a little test program which might be usefull for others too. You can try to change the behaviour by un-/commenting the two marked locks and the cond_wait(). (If someone wants to add it anywhere, please feel free to do so.) I think the