Re: NdisInterLockedIncrement/Decrement macros
- From: soviet_bloke@xxxxxxxxxxx
- Date: 15 Jan 2007 19:28:53 -0800
Stephan,
It is not allowed because it is useless on x86, anyway.
Also, reading a variable will always be atomic on all CPUs, even on
RISC or whatever (assumed the variable is correctly aligned).
Thus, there is abosuletly no need for any locking here.
Don't forget about memory ordering - weak one may improve performance
due to such techniques as out-of-order issue, write-combining and
write-collapsing. However, these techniques may arise some certain
"issues".
Therefore, although there is no need for bus locking in itself here,
you still may need a memory barrier. In fact, I think this is why the
OP asked the original question, in the first place - due to LOCK
prefix, interlocked operation acts as a memory barrier, so that it
sorts these issues out.
In order to deal with the above issues, there is SFENCE instruction -
it guarantees that every store instruction that precedes in program
order the SFENCE is globally visible before any store instruction
which follows the fence is globally visible. If you don't want to use
assembly in your code, you can use KeMemoryBarrier() macro(for x86 it
is implemented as a SFENCE instruction)....
Anton Bassov
Stephan Wolf [MVP] wrote:
soviet_bloke@xxxxxxxxxxx wrote:
You are allowed to use LOCK prefix only with the instructions that I
mentioned above, and MOV is not among them.
It is not allowed because it is useless on x86, anyway.
Also, reading a variable will always be atomic on all CPUs, even on
RISC or whatever (assumed the variable is correctly aligned).
Thus, there is abosuletly no need for any locking here.
Stephan
.
- Follow-Ups:
- Re: NdisInterLockedIncrement/Decrement macros
- From: Maxim S. Shatskih
- Re: NdisInterLockedIncrement/Decrement macros
- References:
- Re: NdisInterLockedIncrement/Decrement macros
- From: Thomas F. Divine
- Re: NdisInterLockedIncrement/Decrement macros
- From: soviet_bloke
- Re: NdisInterLockedIncrement/Decrement macros
- From: Stephan Wolf [MVP]
- Re: NdisInterLockedIncrement/Decrement macros
- From: soviet_bloke
- Re: NdisInterLockedIncrement/Decrement macros
- From: Stephan Wolf [MVP]
- Re: NdisInterLockedIncrement/Decrement macros
- Prev by Date: Re: help to handle IRP_MN_STOP_DEVICE and IRP_MN_START_DEVICE in Usb device?
- Next by Date: Re: NdisInterLockedIncrement/Decrement macros
- Previous by thread: Re: NdisInterLockedIncrement/Decrement macros
- Next by thread: Re: NdisInterLockedIncrement/Decrement macros
- Index(es):
Relevant Pages
|