Amit Aronovitch wrote:
On a 1-CPU machine, when you have global variables such as ints or floats, isn't reading and writing them atomic, and needs no locking?Maxim Vexler wrote:
Doesn't the kernel allocate each thread his own memory spaceNo. In fact, common memory is the major benefit of threads (when compared to e.g. forking a new process).
(including for var's which are global for that thread)?
Global variables which don't get used simultanuously by more than one thread (e.g. some cases where only the "main thread" touches them) are no problem.
However, when more than one thread might access them at the same time, you generally need to apply techniques like semphores or mutex to avoid data corruption.
what are the general rules this issue?
================================================================= To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
