AROS: Add structure spinlock for SMP builds

In 2015 ABIv1 introduced support for spinlocks for SMP enabled builds (1) by
use of a special spinlock structure.

This structure was later updated to end up in its current form in 2017 (2)

This commit adds this record structure to both RTL (execd) and unit (exec).

The structure can be "enabled" by defining AROSPLATFORM_SMP during build.

1) b6045c27fd
2) 0ffdbdc48f
This commit is contained in:
magorium 2022-05-12 23:17:47 +02:00 committed by Charlie Balogh
parent b218393b57
commit b467de658d
2 changed files with 51 additions and 0 deletions

View File

@ -85,6 +85,28 @@ const
LTrue : LongInt = 1;
LFalse: LongInt = 0;
// spinlock
{$ifdef AROSPLATFORM_SMP}
type
TSpinLock =
record
case byte of
0: (slock:
bitpacked record // ensure bits are packed. this is a volatile structure
readcount: 0..$FFFFFF;
_pad2: 0..$7;
&write: 0..$1;
_pad1: 0..$7;
updating: 0..$1;
end);
1: (block: packed array[0..3] of byte; lock: uint32); // both fields are volatile
// The field s_Owner is set either to task owning the lock,
// or NULL if the lock is free/read mode or was acquired in interrupt/supervisor mode
2: (_skip: packed array[0..7] of byte; s_Owner: Pointer); // skip block and lock because that occupies most space
3: (pad_align: packed array[0..128-1] of byte); // ensure 128 byte record size
end;
{$endif}
type
// List Node Structure. Each member in a list starts with a Node
PNode = ^TNode;

View File

@ -23,6 +23,35 @@
{$include utild1.inc}
{ * aros spinlock definition
*********************************************************************
* }
{$ifdef AROSPLATFORM_SMP}
type
TSpinLock =
record
case byte of
0: (slock:
bitpacked record // ensure bits are packed. this is a volatile structure
readcount: 0..$FFFFFF;
_pad2: 0..$7;
&write: 0..$1;
_pad1: 0..$7;
updating: 0..$1;
end);
1: (block: packed array[0..3] of byte; lock: uint32); // both fields are volatile
// The field s_Owner is set either to task owning the lock,
// or NULL if the lock is free/read mode or was acquired in interrupt/supervisor mode
2: (_skip: packed array[0..7] of byte; s_Owner: Pointer); // skip block and lock because that occupies most space
3: (pad_align: packed array[0..128-1] of byte); // ensure 128 byte record size
end;
{$endif}
{ * exec node definitions
*********************************************************************
* }