if you want to avoid the critical section and you're only concerned with the one variable, I'd use some assembly, e.g.
with edx containing the step: Inc thread: lock inc ptr [edx] Dec thread: lock inc ptr [edx] or use the xadd op. check out http://www.codemaestro.com/reviews/review00000104.html On 7/17/07, Ross Levis <[EMAIL PROTECTED]> wrote: > > I'm trying to avoid using a critical section due to time overhead. In one > thread I have a global integer incrementing roughly every 20 milliseconds > using Inc(x,y). In another thread I have the same integer decreasing using > Dec(x,y) at about the same speed. > > Is it critical to have these in a critical section? I've been testing it > here for a few days continuously and it appears to work fine without one. > > Even with a dual processor and each thread running on a separate > processor, > is it possible for one memory location to be written precisely at the same > time? It doesn't matter which occurs first or in which order. > > Cheers, > Ross. > > > _______________________________________________ > Delphi mailing list -> [email protected] > http://www.elists.org/mailman/listinfo/delphi > -- www.galdur.net gsm:690 8366 skype: bladhlaupi _______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi

