Threads and global variables (was:Programming style revisited)
Threads and global variables (was:Programming style revisited)
- Subject: Threads and global variables (was:Programming style revisited)
- From: Raff <email@hidden>
- Date: Sat, 17 Aug 2002 11:35:44 +0200
For this to be true the processor
would somehow have to be making a local copy of an object, moving stuff
around in memory and other assorted weirdness. Now, there are
definitely
issues with access the same variable across two processors, but that's a
more general problem that pointer comparison.
I.E.. The following scenario will result in a deadlock on most MP
architectures:
Thread 1 does:
myVar= 10
while Thread 2 is doing:
while(myVar<10);
But even this issue isn't really the processor's fault. The compiler is
sticking myVar into a register (on thread 2) and never checking memory
again. This situation could certainly occur with pointers but it is not
strictly a pointer problem.
-Kevin Elliott
Software Engineer
CharisMac Engineering
and how can we solve this situation in ObjC ?
(I think I had the case, but then I didn't understand the problem)
and I think I wille have the problem again, wanting every thread to
watch for a global BOOL flag called end,
to allow every thread to stop when one set the flag to TRUE.
So, the NSLock wouldn't be sufficient ?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.