When we need that kind of code, the only replacement to embedded assembler
is a language standard that includes the facility we need. OS calls are not
the answer. But C doesn’t have the equivalent of an interlocked add, I wish
they had some facility to guarantee atomic behavior, for example, a square
bracket instead of a curly bracket would do, or maybe angle brackets, or
even a double bracket:
[myvar += mybumpvalue;]
< myvar += mybumpvalue; >
{{ myvar += mybumpvalue; }}
That of course allows the programmer to specify atomic blocks, not just
statements - and I mean atomic, that is, multiprocessor safe. And who cares
how the OS implements it.
Meanwhile, you guys DO realize, of course, :-), that not every call works on
every OS. Using pure, standard C or C++ makes your code more robust by
avoiding OS dependencies; and when the language doesn’t have the facilities
to do what we want, machine code is the way to go. The ideal OS isn’t the
one that has a call for everything, but the one that you take for granted
and that has a minimalist set of features that’s not expressable in a bog
standard way from inside the high level language we’re using.
And you know what, if I have to choose between feeding the hardware or the
OS trolls, I’ll choose the hardware 100% of the time !
Alberto.
-----Original Message-----
From: Peter Viscarola [mailto:xxxxx@osr.com]
Sent: Monday, June 16, 2003 9:45 AM
To: NT Developers Interest List
Subject: [ntdev] Re: InterlockedExhangeAdd
_asm {
mov eax, value
mov ecx, variable
xadd [ecx], eax
mov RetVal, eax
}
Gee, assembler language. I feel like I’m back in the 70’s…
You guys DO realize, of course, that all this embedded assembler won’t work
when you move your drivers to the AMD64 – which, before you say anything,
is turning out to be one HECK of a great desktop system… And, of course,
it won’t work on the Itanium either, if you care.
So, you might have a multi-O/S compliant solution, but one that won’t even
work on all Windows platforms.
Embedded _asm is evil,
Peter
OSR
You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it.