Subj : Re: deadlock avoidance To : comp.programming.threads From : Giancarlo Niccolai Date : Thu Jul 07 2005 12:47 pm Satendra wrote: > Hi Jose, > I guess my statement was misinterpreted. What i meant by atomic here > is that if we have lets say an integer i with initial value 0 .Thread > T1 unconditionally modified to 2 (i = 2) then T2 at any time will read > it as either 0 or 2 but nothing in between, I agree that with c++ > objects this might not be true. I still don't understand why a function > who is just checking/reading the value of a global variable can't be > reentrant ? > Reentrancy is not directly connected to threading. As someother has already explained, what you propose is not threadsafe, but for what concern reentrancy: a reentrant function is function whose status is always "initialized" anew when called, and that requires no status memory except the one that can be provided with parameters. A function reading a global data requires status informations that are not provided via parameters, and so it's not reentrant. Incidentally, reentrant functions are also threadsafe, because their status is initialized anew (or bookkept via parameters) at every call of every thread calling them, hence my emphasis on them. My other mail (which had not yet appeared :-( explains it. Bests, Giancarlo Niccolai. .