April 26, 2008 Re: DMD 1.029 and 2.013 releases | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean Kelly | Sean Kelly wrote:
> I suppose the obvious question here is: what if I want to create a mutex
> in D?
Why do you need volatile for that?
|
April 26, 2008 Re: DMD 1.029 and 2.013 releases | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright wrote:
> Sean Kelly wrote:
>> I suppose the obvious question here is: what if I want to create a mutex
>> in D?
>
> Why do you need volatile for that?
To restrict compiler optimizations performed on the code.
Sean
|
April 26, 2008 Re: DMD 1.029 and 2.013 releases | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean Kelly | Sean Kelly wrote:
> Walter Bright wrote:
>> Sean Kelly wrote:
>>> I suppose the obvious question here is: what if I want to create a mutex
>>> in D?
>>
>> Why do you need volatile for that?
>
> To restrict compiler optimizations performed on the code.
The optimizer won't move global or pointer references across a function call boundary.
|
April 26, 2008 Re: DMD 1.029 and 2.013 releases | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright wrote: > Sean Kelly wrote: >> Walter Bright wrote: >>> Sean Kelly wrote: >>>> I suppose the obvious question here is: what if I want to create a mutex in D? >>> >>> Why do you need volatile for that? >> >> To restrict compiler optimizations performed on the code. > > The optimizer won't move global or pointer references across a function call boundary. Is that true for all compiler's or only DigitalMars ones? -- Lars Ivar Igesund blog at http://larsivi.net DSource, #d.tango & #D: larsivi Dancing the Tango |
April 26, 2008 Re: DMD 1.029 and 2.013 releases | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright wrote:
> Sean Kelly wrote:
>> Walter Bright wrote:
>>> Sean Kelly wrote:
>>>> I suppose the obvious question here is: what if I want to create a mutex
>>>> in D?
>>>
>>> Why do you need volatile for that?
>>
>> To restrict compiler optimizations performed on the code.
>
> The optimizer won't move global or pointer references across a function call boundary.
Even if the function is inlined?
Sean
|
April 26, 2008 Re: DMD 1.029 and 2.013 releases | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lars Ivar Igesund | Lars Ivar Igesund wrote:
> Walter Bright wrote:
>
>> Sean Kelly wrote:
>>> Walter Bright wrote:
>>>> Sean Kelly wrote:
>>>>> I suppose the obvious question here is: what if I want to create a
>>>>> mutex in D?
>>>> Why do you need volatile for that?
>>> To restrict compiler optimizations performed on the code.
>> The optimizer won't move global or pointer references across a function
>> call boundary.
>
> Is that true for all compiler's or only DigitalMars ones?
DM ones certainly. Others, I don't know about.
|
April 26, 2008 Re: DMD 1.029 and 2.013 releases | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean Kelly | Sean Kelly wrote:
> Walter Bright wrote:
>> Sean Kelly wrote:
>>> Walter Bright wrote:
>>>> Sean Kelly wrote:
>>>>> I suppose the obvious question here is: what if I want to create a mutex
>>>>> in D?
>>>>
>>>> Why do you need volatile for that?
>>>
>>> To restrict compiler optimizations performed on the code.
>>
>> The optimizer won't move global or pointer references across a function call boundary.
>
> Even if the function is inlined?
No, but a mutex involves an OS call. Inlining is also easily prevented.
|
April 26, 2008 Re: DMD 1.029 and 2.013 releases | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright wrote: > Lars Ivar Igesund wrote: >> Walter Bright wrote: >> >>> Sean Kelly wrote: >>>> Walter Bright wrote: >>>>> Sean Kelly wrote: >>>>>> I suppose the obvious question here is: what if I want to create a mutex in D? >>>>> Why do you need volatile for that? >>>> To restrict compiler optimizations performed on the code. >>> The optimizer won't move global or pointer references across a function call boundary. >> >> Is that true for all compiler's or only DigitalMars ones? > > DM ones certainly. Others, I don't know about. So you are saying that you're removing (or not going to implement) a feature due to a restriction in the DM optimizer? -- Lars Ivar Igesund blog at http://larsivi.net DSource, #d.tango & #D: larsivi Dancing the Tango |
April 26, 2008 Re: DMD 1.029 and 2.013 releases | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright wrote: > Sean Kelly wrote: >> Walter Bright wrote: >>> Sean Kelly wrote: >>>> Walter Bright wrote: >>>>> Sean Kelly wrote: >>>>>> I suppose the obvious question here is: what if I want to create a mutex >>>>>> in D? >>>>> >>>>> Why do you need volatile for that? >>>> >>>> To restrict compiler optimizations performed on the code. >>> >>> The optimizer won't move global or pointer references across a function call boundary. >> >> Even if the function is inlined? > > No, but a mutex involves an OS call. Inlining is also easily prevented. An OS call isn't always involved. See, for example: http://en.wikipedia.org/wiki/Futex. Sean |
April 26, 2008 Re: DMD 1.029 and 2.013 releases | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Reply to Walter,
> No, but a mutex involves an OS call. Inlining is also easily
> prevented.
>
using atomic ASM ops a (single process) mutex can be implemented with no OS interaction at all.
|
Copyright © 1999-2021 by the D Language Foundation