I hope a fix for this will be back-ported for many Delphi versions.

I hope a fix for this will be back-ported for many Delphi versions.

System.pas:

procedure YieldProcessor;
{$IF (defined(CPUX86) or defined(CPUX64)) and defined(ASSEMBLER)}
asm
PAUSE
end;
{$ELSE}
begin
end;
{$ENDIF}

Called from TMonitor.Spin, TThread.SpinWait and TInternalConditionVariable.LockQueue.

Duplicates in TMonitor.Spin TThread.SpinWait, TInternalConditionVariable.LockQueue and getmem.inc.



Originally shared by Kristian Köhntopp

The "Pause" instruction changed timing dramatically in Skylake. Spinlock implementation based on pause will need adjustments.
https://aloiskraus.wordpress.com/2018/06/16/why-skylakex-cpus-are-sometimes-50-slower-how-intel-has-broken-existing-code/

Comments