>>546
まさにビンゴです。
そうか、内部でCPUを解放させる処理が入っているので
CriticalSection()は遅いのか。

>>545
全部書かずに失礼。元のソースはこんなです。
CriticalSection()より8倍速く動きます。他に書き方はあるのかな?
__inline void lock(volatile int *ptr)
{
__asm
{
mov ecx, ptr
L0:
mov eax, 1
xchg eax, [ecx]
test eax, eax
jz end
L1:
mov eax, [ecx]
test eax, eax
jz L0
jmp L1
end:
}
}