• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Threads and global variables (was:Programming style revisited)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.
  • Follow-Ups:
    • Re: Threads and global variables (was:Programming style revisited)
      • From: Robert Goldsmith <email@hidden>
  • Prev by Date: Re: File's Owner
  • Next by Date: Need help
  • Previous by thread: NSTextFieldCell & editWithFrame
  • Next by thread: Re: Threads and global variables (was:Programming style revisited)
  • Index(es):
    • Date
    • Thread