gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSThread test failing


From: Wolfgang Lux
Subject: Re: NSThread test failing
Date: Mon, 12 Aug 2013 11:33:20 +0200

David Chisnall wrote:

> On 12 Aug 2013, at 03:44, Doug Warren <address@hidden> wrote:
> 
>>    backgroundTid = 0;
>>    [backThread performSelectorInBackground:@selector(run:) 
>> withObject:backThread];
>>    while(backgroundTid == 0)
>>        sleep(1);
>> 
> 
> I don't know if this is your issue, however your test relies on undefined 
> behaviour.  In C99, backgroundTid is not volatile and so the compiler is 
> entirely free to turn this into the equivalent of :
> 
> if (backgroundTid == 0)
>       while (1) { sleep(1); }

I doubt that your analysis is correct. Sleep is a function call and 
backgroundTid is a global variable. The compiler cannot (and must not) assume 
that backgroundTid is not changed during the call to sleep.

Wolfgang




reply via email to

[Prev in Thread] Current Thread [Next in Thread]