• 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
Re: Endless loop but only with release build
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Endless loop but only with release build


  • Subject: Re: Endless loop but only with release build
  • From: Jim Correia <email@hidden>
  • Date: Sat, 30 Sep 2006 15:10:03 -0400

On Sep 30, 2006, at 12:02 PM, Antonio Nunes wrote:

The code below works fine in debug builds

[...]

	// Wait until the converting thread has terminated, if it exists
	while (_isConverting) {
		;
	}

[...]

Could this be a compiler bug

No. In the release build the compiler is applying optimizations given the information at its disposal. It sees that the same value is tested over and over again, so arranges to load the value only once when optimizations are on. (Look at the disassembly to verify this in your Release build.)


Using the volatlle type qualifier gives the compiler and optimizer more information to work with. (But see below.)

or is this not a good way to handle states across threads?

Even if you made changes to get this working, it is still very inefficient. You have a busy loop doing nothing but chewing cycles waiting for some other task to finish. There is likely a better solution, but you aren't going to get a quick or easy answer because we don't know the architecture of your program. Writing a multi- threaded application correctly is hard. At the very least, you'll want to start by reading the documentation Matt pointed you at.


Jim

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Endless loop but only with release build (From: Antonio Nunes <email@hidden>)

  • Prev by Date: Re: Endless loop but only with release build
  • Next by Date: Re: CoreDate: Inverse relationship... (follow up)
  • Previous by thread: Re: Endless loop but only with release build
  • Next by thread: Re: Endless loop but only with release build
  • Index(es):
    • Date
    • Thread