public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Ensure System.Tasking.Debug.Known_Tasks component access is atomic
@ 2021-06-30  9:30 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-06-30  9:30 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 445 bytes --]

Multiple threads can access the elements of
System.Tasking.Debug.Known_Tasks concurrently. While the compiler will
generally produce code that reads and writes Task_Ids atomically since
Task_Id is word size, it is best to be explicit to prevent data race
issues that may arise from non-atomic component accesses.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* libgnarl/s-tasdeb.ads (Known_Tasks): Add Atomic_Components
	aspect.

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 740 bytes --]

diff --git a/gcc/ada/libgnarl/s-tasdeb.ads b/gcc/ada/libgnarl/s-tasdeb.ads
--- a/gcc/ada/libgnarl/s-tasdeb.ads
+++ b/gcc/ada/libgnarl/s-tasdeb.ads
@@ -65,9 +65,11 @@ package System.Tasking.Debug is
    -- General GDB support --
    -------------------------
 
-   Known_Tasks : array (0 .. 999) of Task_Id := (others => null);
+   Known_Tasks : array (0 .. 999) of Task_Id := (others => null)
+     with Atomic_Components;
    --  Global array of tasks read by gdb, and updated by Create_Task and
-   --  Finalize_TCB
+   --  Finalize_TCB. Ensure access to its components is atomic to allow
+   --  lock-free concurrent access.
 
    Debug_Event_Activating           : constant := 1;
    Debug_Event_Run                  : constant := 2;



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-06-30  9:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-30  9:30 [Ada] Ensure System.Tasking.Debug.Known_Tasks component access is atomic Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).