Browse Source

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) https://github.com/aros-development-team/AROS/commit/b6045c27fdb925491cc8081837b978d288f057a3
2) https://github.com/aros-development-team/AROS/commit/0ffdbdc48f6b5add7efb3cc193fa98739dedeff3
magorium 3 years ago
parent
commit
b467de658d
2 changed files with 51 additions and 0 deletions
  1. 22 0
      packages/arosunits/src/exec.pas
  2. 29 0
      rtl/aros/i386/execd.inc

+ 22 - 0
packages/arosunits/src/exec.pas

@@ -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;

+ 29 - 0
rtl/aros/i386/execd.inc

@@ -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
   *********************************************************************
   * }