Subj : Re: Challenge: Multithreading & Synchronization To : comp.programming.threads From : Giancarlo Niccolai Date : Mon May 23 2005 03:54 pm doug wrote: > > Actually, I have a (hopefully) quick question. Is the above algorithm > safe > in a system where you dynamically create the recursive mutex? E.g. one > thread allocates a control block (which includes creating a recursive > mutex), and a second thread comes along later and attempts to acquire the > sema4. Is it not possible that this second thread might misread > uninitialised 'garbage' from the owner field, and may think it already > owns > the sema4? (Pretty low odds, I know, but still finite.) Theoretically yes, but then the problem is NOT in the mutex, but in your app, trying to access a non initialized mutex when it is still not available. Doing this kind of things results in anything between a correct operation and a core dump, inclusive, depending by the odds, whichever kind of data is a stake: a recursive mutex, a normal mutex, or any object at all... So, I suppose the problem is not quite relevant. Mutexes are ANYHOW to be initialized in a safe moment in the first place... Gian. .