diff options
Diffstat (limited to 'gcc/ada/s-taprop-linux.adb')
-rw-r--r-- | gcc/ada/s-taprop-linux.adb | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/gcc/ada/s-taprop-linux.adb b/gcc/ada/s-taprop-linux.adb index 08bbac10f40..b9c3c5e6ae9 100644 --- a/gcc/ada/s-taprop-linux.adb +++ b/gcc/ada/s-taprop-linux.adb @@ -701,21 +701,10 @@ package body System.Task_Primitives.Operations is end if; Self_ID.Common.LL.Thread := pthread_self; + Self_ID.Common.LL.LWP := lwp_self; Specific.Set (Self_ID); - Lock_RTS; - - for J in Known_Tasks'Range loop - if Known_Tasks (J) = null then - Known_Tasks (J) := Self_ID; - Self_ID.Known_Tasks_Index := J; - exit; - end if; - end loop; - - Unlock_RTS; - if Use_Alternate_Stack then declare Stack : aliased stack_t; @@ -1094,7 +1083,19 @@ package body System.Task_Primitives.Operations is S.State := False; else S.Waiting := True; - Result := pthread_cond_wait (S.CV'Access, S.L'Access); + + loop + -- loop in case pthread_cond_wait returns earlier than + -- expected (e.g. in case of EINTR caused by a signal). + -- This should not happen on current implementation of pthread + -- under Linux, but POSIX does not guarantee it, so this may + -- change in the future. + + Result := pthread_cond_wait (S.CV'Access, S.L'Access); + pragma Assert (Result = 0 or else Result = EINTR); + + exit when not S.Waiting; + end loop; end if; Result := pthread_mutex_unlock (S.L'Access); @@ -1255,6 +1256,12 @@ package body System.Task_Primitives.Operations is Alternate_Stack'Address; end if; + -- Make environment task known here because it doesn't go through + -- Activate_Tasks, which does it for all other tasks. + + Known_Tasks (Known_Tasks'First) := Environment_Task; + Environment_Task.Known_Tasks_Index := Known_Tasks'First; + Enter_Task (Environment_Task); -- Install the abort-signal handler |