synchronized vs. C volatile
SK
sk at metrokings.com
Mon Aug 9 21:00:32 PDT 2010
On Mon, Aug 9, 2010 at 9:55 AM, Lutger <lutger.blijdestijn at gmail.com> wrote:
>
> I'm not an expert on this, but if I am not mistaken the shared type
qualifier
> will handle the barriers, require atomic ops and prevent reordering
compiler
> optimizations so it looks like this one will take care of what volatile
used to
> do, right?
>
>
Seems the latest dmd in svn hasn't implemented shared atomics yet anyway.
If it had, we'd see a lock prefix in use.
$ cat main.d
shared int x = 1;
int main()
{
x = x + 1;
++x;
return 0;
}
$ dmd -O -w -wi main.d
$ objdump -d main.o
main.o: file format elf32-i386
Disassembly of section .text:
00000000 <.text>:
0: c3 ret
1: 60 pusha
2: b8 14 00 00 00 mov $0x14,%eax
7: b9 00 00 00 00 mov $0x0,%ecx
c: 8b 11 mov (%ecx),%edx
e: 89 10 mov %edx,(%eax)
10: 89 01 mov %eax,(%ecx)
12: 61 popa
13: c3 ret
Disassembly of section .text._Dmain:
00000000 <_Dmain>:
0: 55 push %ebp
1: a1 00 00 00 00 mov 0x0,%eax
6: 40 inc %eax
7: a3 00 00 00 00 mov %eax,0x0
c: 8b ec mov %esp,%ebp
e: 31 c0 xor %eax,%eax
10: 83 05 00 00 00 00 01 addl $0x1,0x0
17: 5d pop %ebp
18: c3 ret
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20100809/5437c311/attachment-0001.html>
More information about the Digitalmars-d
mailing list