[Ada] Add missing lock in PowerPC runtime

bosch@gnat.com bosch@gnat.com
Fri Oct 26 09:10:00 GMT 2001


2001-10-26  Joel Brobecker <brobecke@gnat.com>

	* 5zosinte.ads (null_pthread): new constant.
	
	* 5ztaprop.adb:
	(Initialize_TCB): Initialize thread ID to null, to be able to verify
	 later that this field has been set.
	(Finalize_TCB): ditto.
	(Suspend_Task): Verify that the thread ID is not null before using it.
	(Resume_Task): ditto.
	
	* s-tasdeb.adb:
	(Resume_All_Tasks): Lock the tasks list before using it.
	(Suspend_All_Tasks): ditto.

*** 5zosinte.ads	2001/06/05 14:00:31	1.16
--- 5zosinte.ads	2001/10/19 16:01:06	1.17
***************
*** 218,223 ****
--- 218,225 ----
     type pthread_t           is private;
     subtype Thread_Id        is pthread_t;
  
+    null_pthread : constant pthread_t;
+ 
     type pthread_mutex_t     is limited private;
     type pthread_cond_t      is limited private;
     type pthread_attr_t      is limited private;
***************
*** 541,546 ****
--- 543,550 ----
     end record;
  
     type pthread_t is new long;
+ 
+    null_pthread : constant pthread_t := 0;
  
     type pthread_key_t is new int;
  

*** 5ztaprop.adb	2001/07/16 13:30:03	1.41
--- 5ztaprop.adb	2001/10/19 16:01:24	1.42
***************
*** 728,733 ****
--- 728,735 ----
        Cond_Attr : aliased pthread_condattr_t;
  
     begin
+       Self_ID.Common.LL.Thread := null_pthread;
+ 
        Result := pthread_mutexattr_init (Mutex_Attr'Access);
        pragma Assert (Result = 0 or else Result = ENOMEM);
  
***************
*** 898,903 ****
--- 900,907 ----
          Unchecked_Deallocation (Ada_Task_Control_Block, Task_ID);
  
     begin
+       T.Common.LL.Thread := null_pthread;
+ 
        Result := pthread_mutex_destroy (T.Common.LL.L'Access);
        pragma Assert (Result = 0);
  
***************
*** 989,995 ****
       (T           : ST.Task_ID;
        Thread_Self : Thread_Id) return Boolean is
     begin
!       if T.Common.LL.Thread /= Thread_Self then
           return taskSuspend (T.Common.LL.Thread) = 0;
        else
           return True;
--- 993,1001 ----
       (T           : ST.Task_ID;
        Thread_Self : Thread_Id) return Boolean is
     begin
!       if T.Common.LL.Thread /= null_pthread
!         and then T.Common.LL.Thread /= Thread_Self
!       then
           return taskSuspend (T.Common.LL.Thread) = 0;
        else
           return True;
***************
*** 1004,1010 ****
       (T           : ST.Task_ID;
        Thread_Self : Thread_Id) return Boolean is
     begin
!       if T.Common.LL.Thread /= Thread_Self then
           return taskResume (T.Common.LL.Thread) = 0;
        else
           return True;
--- 1010,1018 ----
       (T           : ST.Task_ID;
        Thread_Self : Thread_Id) return Boolean is
     begin
!       if T.Common.LL.Thread /= null_pthread
!         and then T.Common.LL.Thread /= Thread_Self
!       then
           return taskResume (T.Common.LL.Thread) = 0;
        else
           return True;

*** s-tasdeb.adb	2001/03/07 16:32:45	1.23
--- s-tasdeb.adb	2001/10/19 16:01:37	1.24
***************
*** 499,510 ****
--- 499,513 ----
        R : Boolean;
  
     begin
+       STPO.Lock_All_Tasks_List;
        C := All_Tasks_List;
  
        while C /= null loop
           R := STPO.Resume_Task (C, Thread_Self);
           C := C.Common.All_Tasks_Link;
        end loop;
+ 
+       STPO.Unlock_All_Tasks_List;
     end Resume_All_Tasks;
  
     ----------
***************
*** 577,588 ****
--- 580,594 ----
        R : Boolean;
  
     begin
+       STPO.Lock_All_Tasks_List;
        C := All_Tasks_List;
  
        while C /= null loop
           R := STPO.Suspend_Task (C, Thread_Self);
           C := C.Common.All_Tasks_Link;
        end loop;
+ 
+       STPO.Unlock_All_Tasks_List;
     end Suspend_All_Tasks;
  
     ------------------------



More information about the Gcc-patches mailing list