Commit 0bf08bfe by Joel Brobecker Committed by Geert Bosch

5zosinte.ads (null_pthread): new constant.

	* 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.

From-SVN: r46548
parent 7a3a8c06
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- $Revision: 1.16 $ -- $Revision$
-- -- -- --
-- Copyright (C) 1997-2001 Free Software Foundation, Inc. -- -- Copyright (C) 1997-2001 Free Software Foundation, Inc. --
-- -- -- --
...@@ -218,6 +218,8 @@ package System.OS_Interface is ...@@ -218,6 +218,8 @@ package System.OS_Interface is
type pthread_t is private; type pthread_t is private;
subtype Thread_Id is pthread_t; subtype Thread_Id is pthread_t;
null_pthread : constant pthread_t;
type pthread_mutex_t is limited private; type pthread_mutex_t is limited private;
type pthread_cond_t is limited private; type pthread_cond_t is limited private;
type pthread_attr_t is limited private; type pthread_attr_t is limited private;
...@@ -542,6 +544,8 @@ private ...@@ -542,6 +544,8 @@ private
type pthread_t is new long; type pthread_t is new long;
null_pthread : constant pthread_t := 0;
type pthread_key_t is new int; type pthread_key_t is new int;
-- These are to store the pthread_keys that are created with -- These are to store the pthread_keys that are created with
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- $Revision: 1.41 $ -- $Revision$
-- -- -- --
-- Copyright (C) 1991-2001 Florida State University -- -- Copyright (C) 1991-2001 Florida State University --
-- -- -- --
...@@ -728,6 +728,8 @@ package body System.Task_Primitives.Operations is ...@@ -728,6 +728,8 @@ package body System.Task_Primitives.Operations is
Cond_Attr : aliased pthread_condattr_t; Cond_Attr : aliased pthread_condattr_t;
begin begin
Self_ID.Common.LL.Thread := null_pthread;
Result := pthread_mutexattr_init (Mutex_Attr'Access); Result := pthread_mutexattr_init (Mutex_Attr'Access);
pragma Assert (Result = 0 or else Result = ENOMEM); pragma Assert (Result = 0 or else Result = ENOMEM);
...@@ -898,6 +900,8 @@ package body System.Task_Primitives.Operations is ...@@ -898,6 +900,8 @@ package body System.Task_Primitives.Operations is
Unchecked_Deallocation (Ada_Task_Control_Block, Task_ID); Unchecked_Deallocation (Ada_Task_Control_Block, Task_ID);
begin begin
T.Common.LL.Thread := null_pthread;
Result := pthread_mutex_destroy (T.Common.LL.L'Access); Result := pthread_mutex_destroy (T.Common.LL.L'Access);
pragma Assert (Result = 0); pragma Assert (Result = 0);
...@@ -989,7 +993,9 @@ package body System.Task_Primitives.Operations is ...@@ -989,7 +993,9 @@ package body System.Task_Primitives.Operations is
(T : ST.Task_ID; (T : ST.Task_ID;
Thread_Self : Thread_Id) return Boolean is Thread_Self : Thread_Id) return Boolean is
begin begin
if T.Common.LL.Thread /= Thread_Self then if T.Common.LL.Thread /= null_pthread
and then T.Common.LL.Thread /= Thread_Self
then
return taskSuspend (T.Common.LL.Thread) = 0; return taskSuspend (T.Common.LL.Thread) = 0;
else else
return True; return True;
...@@ -1004,7 +1010,9 @@ package body System.Task_Primitives.Operations is ...@@ -1004,7 +1010,9 @@ package body System.Task_Primitives.Operations is
(T : ST.Task_ID; (T : ST.Task_ID;
Thread_Self : Thread_Id) return Boolean is Thread_Self : Thread_Id) return Boolean is
begin begin
if T.Common.LL.Thread /= Thread_Self then if T.Common.LL.Thread /= null_pthread
and then T.Common.LL.Thread /= Thread_Self
then
return taskResume (T.Common.LL.Thread) = 0; return taskResume (T.Common.LL.Thread) = 0;
else else
return True; return True;
......
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.
2001-10-26 Richard Kenner <kenner@gnat.com> 2001-10-26 Richard Kenner <kenner@gnat.com>
* decl.c (gnat_to_gnu_entity, case E_General_Access_Type): * decl.c (gnat_to_gnu_entity, case E_General_Access_Type):
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- $Revision: 1.23 $ -- $Revision$
-- -- -- --
-- Copyright (C) 1997-2001 Free Software Foundation, Inc. -- -- Copyright (C) 1997-2001 Free Software Foundation, Inc. --
-- -- -- --
...@@ -499,12 +499,15 @@ package body System.Tasking.Debug is ...@@ -499,12 +499,15 @@ package body System.Tasking.Debug is
R : Boolean; R : Boolean;
begin begin
STPO.Lock_All_Tasks_List;
C := All_Tasks_List; C := All_Tasks_List;
while C /= null loop while C /= null loop
R := STPO.Resume_Task (C, Thread_Self); R := STPO.Resume_Task (C, Thread_Self);
C := C.Common.All_Tasks_Link; C := C.Common.All_Tasks_Link;
end loop; end loop;
STPO.Unlock_All_Tasks_List;
end Resume_All_Tasks; end Resume_All_Tasks;
---------- ----------
...@@ -577,12 +580,15 @@ package body System.Tasking.Debug is ...@@ -577,12 +580,15 @@ package body System.Tasking.Debug is
R : Boolean; R : Boolean;
begin begin
STPO.Lock_All_Tasks_List;
C := All_Tasks_List; C := All_Tasks_List;
while C /= null loop while C /= null loop
R := STPO.Suspend_Task (C, Thread_Self); R := STPO.Suspend_Task (C, Thread_Self);
C := C.Common.All_Tasks_Link; C := C.Common.All_Tasks_Link;
end loop; end loop;
STPO.Unlock_All_Tasks_List;
end Suspend_All_Tasks; end Suspend_All_Tasks;
------------------------ ------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment