TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [TCLUG:5462] "Race Condition"?



On 21 Apr, Michael Hicks wrote:
> I was wondering if someone could explain to me exactly what a 'race condition'
> is.  I've heard about it many times, but the context is usually weak and I can't
> quite figure it out.
> 
It has to do with multiple processes sharing memory.  One common one is
this:
process 1 reads memory address 400 and gets the number 4 from it.  
process 2 ready memory address 400 and gets the number 4
process 1 says that 4 is bad and 5 should be in there.  So it puts 5 in
memory address 400.
process 2 says 4 is good and so puts 4 back in memory address 400.

This is a very simple example of a race condition.  You should only
have to worry about it when using threads, or other concurrent
programming.

-- 
Jon Schewe 
http://tcfreenet.org/~schewe
schewe@tcfreenet.org