[LCP] Multi threading programming

Christopher Howard choward at indicium.us
Fri Feb 20 09:21:06 EST 2009


I'm am entirely unexperienced at multi threaded programming, but am about 
to try and figure it out. For one of my programs I wanted to create a 
simple "internal counter" function which which sleeps for 1000 
milliseconds, then increments a global variable which other functions can 
read. (I know this doesn't work as an accurate clock, but that is okay.)

My question: Does the global variable have to be some kind of atomic 
variable? Will this still work correctly if it is an int or a long int? I 
read something on the Internet about locking variables... does that apply 
here?

Any (simple) examples would also be appreciated. Thank you in advance.

-- 
Christopher Howard
http://indicium.us
http://theologia.indicium.us



More information about the linuxCprogramming mailing list