Just in order to ease debugging (at pthread level). No functional change. Committed on trunk
2012-03-07 Tristan Gingold <ging...@adacore.com> * s-taprop-vms.adb (Create_Task): set thread name. * s-osinte-vms.ads (pthread_attr_setname_np): Declare.
Index: s-taprop-vms.adb =================================================================== --- s-taprop-vms.adb (revision 185051) +++ s-taprop-vms.adb (working copy) @@ -780,6 +780,7 @@ function Thread_Body_Access is new Ada.Unchecked_Conversion (System.Aux_DEC.Short_Address, Thread_Body); + Task_Name : String (1 .. System.Parameters.Max_Task_Image_Length + 1); begin -- Since the initial signal mask of a thread is inherited from the -- creator, we need to set our local signal mask to mask all signals @@ -809,6 +810,18 @@ (Attributes'Access, PTHREAD_EXPLICIT_SCHED); pragma Assert (Result = 0); + if T.Common.Task_Image_Len > 0 then + -- Set thread name to ease debugging + + Task_Name (1 .. T.Common.Task_Image_Len) := + T.Common.Task_Image (1 .. T.Common.Task_Image_Len); + Task_Name (T.Common.Task_Image_Len + 1) := ASCII.NUL; + + Result := pthread_attr_setname_np + (Attributes'Access, Task_Name'Address, Null_Address); + pragma Assert (Result = 0); + end if; + -- Note: the use of Unrestricted_Access in the following call is needed -- because otherwise we have an error of getting a access-to-volatile -- value which points to a non-volatile object. But in this case it is Index: s-osinte-vms.ads =================================================================== --- s-osinte-vms.ads (revision 185051) +++ s-osinte-vms.ads (working copy) @@ -520,6 +520,12 @@ sched_param : int) return int; pragma Import (C, pthread_attr_setschedparam, "PTHREAD_ATTR_SETSCHEDPARAM"); + function pthread_attr_setname_np + (attr : access pthread_attr_t; + name : System.Address; + mbz : System.Address) return int; + pragma Import (C, pthread_attr_setname_np, "PTHREAD_ATTR_SETNAME_NP"); + function sched_yield return int; --------------------------