Re: powerd

From: Fredrik Lindberg <fli+freebsd-current_at_shapeshifter.se>
Date: Tue, 06 Dec 2005 15:41:58 +0100
Giorgos Keramidas wrote:
> On 2005-12-06 14:18, Fredrik Lindberg <fli+freebsd-current_at_shapeshifter.se> wrote:
> 
>>Dag-Erling Sm?rgrav wrote:
>>
>>>Fredrik Lindberg <fli+freebsd-current_at_shapeshifter.se> writes:
>>>
>>>>Dag-Erling Sm?rgrav wrote:
>>>>
>>>>>If the devd loop is an *alternative* to the polling loop, there's
>>>>>even less reason to use threads.
>>>>
>>>>Yes it's an alternative, reading a variable versus doing a sysctl call
>>>>each interation. It seemed like I good idea, when I first wrote this
>>>>(almost a year ago), to have a thread providing a cached value of the
>>>>AC state. But maybe I was trying to be too smart or something.
>>>
>>>Yes.  Not only is it a bad design idea, but the implementation is
>>>wrong, and likely to fail badly when compiled at high optimization
>>>levels.
>>
>>Ignoring the fact that it does work with -O3 (gcc 3.4.4), could you
>>please explain why it has the potential of failing with high
>>optimizations.
> 
> 
> I haven't looked at the source code, but I think what Dag-Erling means
> is that optimizing compilers, in high optimization mode, may inhibit
> sequential read operations of the same variable, trying to 'optimize'
> many read operations that would (to the best of their knowledge) return
> the same result.
> 
> This is never going to happen if the variable is declared as 'volatile'
> though, so I'm not sure if it applies in this case, until I look at the
> sources of powerd.
> 

Ah, ok. I was thinking of something like that. Anyway, thank you
for explaining this.

Fredrik Lindberg
Received on Tue Dec 06 2005 - 13:42:35 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:48 UTC