[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: NSThread test failing
From: |
David Chisnall |
Subject: |
Re: NSThread test failing |
Date: |
Mon, 12 Aug 2013 09:20:24 +0100 |
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 would expect this program never to terminate. In C11, there is no
happens-before relationship between the store and the load and so the same is
allowed to happen but some other constraints are also in place.
David
-- Sent from my PDP-11