public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] vxworks: auto-registration of foreign threads
@ 2017-09-13 10:35 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2017-09-13 10:35 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jerome Guitton, Arnaud Charlet

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

To make Ada tasks and C threads interoperate better, we have added some
functionality to Self. Suppose a C main program (with threads) calls an
Ada procedure and the Ada procedure calls the tasking runtime system.
Eventually, a call will be made to self. Since the call is not coming
from an Ada task, there will be no corresponding ATCB.

What we do in Self is to catch references that do not come from
recognized Ada tasks, and create an ATCB for the calling thread.

The new ATCB will be "detached" from the normal Ada task master
hierarchy, much like the existing implicitly created signal-server
tasks.

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

2017-09-13  Jerome Guitton  <guitton@adacore.com>

	* libgnarl/s-tpopsp__vxworks-tls.adb,
	libgnarl/s-tpopsp__vxworks-rtp.adb, libgnarl/s-tpopsp__vxworks.adb
	(Self): Register thread if task id is null.


[-- Attachment #2: difs --]
[-- Type: text/plain, Size: 3956 bytes --]

Index: libgnarl/s-tpopsp__vxworks-tls.adb
===================================================================
--- libgnarl/s-tpopsp__vxworks-tls.adb	(revision 252075)
+++ libgnarl/s-tpopsp__vxworks-tls.adb	(working copy)
@@ -71,9 +71,29 @@
    -- Self --
    ----------
 
+   --  To make Ada tasks and C threads interoperate better, we have added some
+   --  functionality to Self. Suppose a C main program (with threads) calls an
+   --  Ada procedure and the Ada procedure calls the tasking runtime system.
+   --  Eventually, a call will be made to self. Since the call is not coming
+   --  from an Ada task, there will be no corresponding ATCB.
+
+   --  What we do in Self is to catch references that do not come from
+   --  recognized Ada tasks, and create an ATCB for the calling thread.
+
+   --  The new ATCB will be "detached" from the normal Ada task master
+   --  hierarchy, much like the existing implicitly created signal-server
+   --  tasks.
+
    function Self return Task_Id is
+      Result : constant Task_Id := ATCB;
    begin
-      return ATCB;
+      if Result /= null then
+         return Result;
+      else
+         --  If the value is Null then it is a non-Ada task
+
+         return Register_Foreign_Thread;
+      end if;
    end Self;
 
 end Specific;
Index: libgnarl/s-tpopsp__vxworks-rtp.adb
===================================================================
--- libgnarl/s-tpopsp__vxworks-rtp.adb	(revision 252075)
+++ libgnarl/s-tpopsp__vxworks-rtp.adb	(working copy)
@@ -72,9 +72,29 @@
    -- Self --
    ----------
 
+   --  To make Ada tasks and C threads interoperate better, we have added some
+   --  functionality to Self. Suppose a C main program (with threads) calls an
+   --  Ada procedure and the Ada procedure calls the tasking runtime system.
+   --  Eventually, a call will be made to self. Since the call is not coming
+   --  from an Ada task, there will be no corresponding ATCB.
+
+   --  What we do in Self is to catch references that do not come from
+   --  recognized Ada tasks, and create an ATCB for the calling thread.
+
+   --  The new ATCB will be "detached" from the normal Ada task master
+   --  hierarchy, much like the existing implicitly created signal-server
+   --  tasks.
+
    function Self return Task_Id is
+      Result : constant Task_Id := To_Task_Id (tlsValueGet (ATCB_Key));
    begin
-      return To_Task_Id (tlsValueGet (ATCB_Key));
+      if Result /= null then
+         return Result;
+      else
+         --  If the value is Null then it is a non-Ada task
+
+         return Register_Foreign_Thread;
+      end if;
    end Self;
 
 end Specific;
Index: libgnarl/s-tpopsp__vxworks.adb
===================================================================
--- libgnarl/s-tpopsp__vxworks.adb	(revision 252075)
+++ libgnarl/s-tpopsp__vxworks.adb	(working copy)
@@ -121,9 +121,29 @@
    -- Self --
    ----------
 
+   --  To make Ada tasks and C threads interoperate better, we have added some
+   --  functionality to Self. Suppose a C main program (with threads) calls an
+   --  Ada procedure and the Ada procedure calls the tasking runtime system.
+   --  Eventually, a call will be made to self. Since the call is not coming
+   --  from an Ada task, there will be no corresponding ATCB.
+
+   --  What we do in Self is to catch references that do not come from
+   --  recognized Ada tasks, and create an ATCB for the calling thread.
+
+   --  The new ATCB will be "detached" from the normal Ada task master
+   --  hierarchy, much like the existing implicitly created signal-server
+   --  tasks.
+
    function Self return Task_Id is
+      Result : constant Task_Id := To_Task_Id (ATCB_Key);
    begin
-      return To_Task_Id (ATCB_Key);
+      if Result /= null then
+         return Result;
+      else
+         --  If the value is Null then it is a non-Ada task
+
+         return Register_Foreign_Thread;
+      end if;
    end Self;
 
 end Specific;

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

only message in thread, other threads:[~2017-09-13 10:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-13 10:35 [Ada] vxworks: auto-registration of foreign threads 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).