+2011-09-27 Pascal Obry <obry@adacore.com>
+
+ * s-osinte-hpux.ads, s-taprop-vxworks.adb, s-taspri-vxworks.ads,
+ s-taprop-tru64.adb, s-osinte-aix.ads, s-taspri-posix-noaltstack.ads,
+ s-taspri-mingw.ads, s-taprop-vms.adb, s-tpoben.adb, s-tpoben.ads,
+ s-taprop-mingw.adb, s-taprob.adb, s-taprob.ads,
+ s-osinte-solaris-posix.ads, s-taprop-solaris.adb, s-taspri-solaris.ads,
+ s-osinte-irix.ads, s-taprop-irix.adb, s-osinte-darwin.ads,
+ s-taspri-dummy.ads, s-taspri-posix.ads, s-taprop.ads,
+ s-taspri-vms.ads, s-osinte-freebsd.ads, s-taprop-hpux-dce.adb,
+ s-taspri-hpux-dce.ads, s-taspri-tru64.ads, s-taprop-dummy.adb,
+ s-taprop-posix.adb: Revert previous changes.
+ (Lock): Now a record containing the two possible lock
+ (mutex and read/write) defined in OS_Interface.
+ * s-taprop-linux.adb (Finalize_Protection): Use r/w lock for
+ 'R' locking policy.
+ (Initialize_Protection): Likewise.
+ (Lock): Likewise.
+ (Lock_Read_Only): Likewise.
+ (Unlock): Likewise.
+
2011-09-27 Pascal Obry <obry@adacore.com>
* s-taspri-posix-noaltstack.ads (RW_Lock): This type is now defined as
PTHREAD_SCOPE_PROCESS : constant := 1;
PTHREAD_SCOPE_SYSTEM : constant := 0;
- -- Read/Write lock not supported on AIX. To add support both types
- -- pthread_rwlock_t and pthread_rwlockattr_t must properly be defined
- -- with the associated routines pthread_rwlock_[init/destroy] and
- -- pthread_rwlock_[rdlock/wrlock/unlock].
-
- subtype pthread_rwlock_t is pthread_mutex_t;
- subtype pthread_rwlockattr_t is pthread_mutexattr_t;
-
-----------
-- Stack --
-----------
PTHREAD_SCOPE_PROCESS : constant := 2;
PTHREAD_SCOPE_SYSTEM : constant := 1;
- -- Read/Write lock not supported on Darwin. To add support both types
- -- pthread_rwlock_t and pthread_rwlockattr_t must properly be defined
- -- with the associated routines pthread_rwlock_[init/destroy] and
- -- pthread_rwlock_[rdlock/wrlock/unlock].
-
- subtype pthread_rwlock_t is pthread_mutex_t;
- subtype pthread_rwlockattr_t is pthread_mutexattr_t;
-
-----------
-- Stack --
-----------
PTHREAD_SCOPE_PROCESS : constant := 0;
PTHREAD_SCOPE_SYSTEM : constant := 2;
- -- Read/Write lock not supported on freebsd. To add support both types
- -- pthread_rwlock_t and pthread_rwlockattr_t must properly be defined
- -- with the associated routines pthread_rwlock_[init/destroy] and
- -- pthread_rwlock_[rdlock/wrlock/unlock].
-
- subtype pthread_rwlock_t is pthread_mutex_t;
- subtype pthread_rwlockattr_t is pthread_mutexattr_t;
-
-----------
-- Stack --
-----------
PTHREAD_SCOPE_PROCESS : constant := 2;
PTHREAD_SCOPE_SYSTEM : constant := 1;
- -- Read/Write lock not supported on HPUX. To add support both types
- -- pthread_rwlock_t and pthread_rwlockattr_t must properly be defined
- -- with the associated routines pthread_rwlock_[init/destroy] and
- -- pthread_rwlock_[rdlock/wrlock/unlock].
-
- subtype pthread_rwlock_t is pthread_mutex_t;
- subtype pthread_rwlockattr_t is pthread_mutexattr_t;
-
-----------
-- Stack --
-----------
PTHREAD_CREATE_DETACHED : constant := 1;
- -- Read/Write lock not supported on SGI. To add support both types
- -- pthread_rwlock_t and pthread_rwlockattr_t must properly be defined
- -- with the associated routines pthread_rwlock_[init/destroy] and
- -- pthread_rwlock_[rdlock/wrlock/unlock].
-
- subtype pthread_rwlock_t is pthread_mutex_t;
- subtype pthread_rwlockattr_t is pthread_mutexattr_t;
-
-----------
-- Stack --
-----------
type pthread_condattr_t is limited private;
type pthread_key_t is private;
- -- Read/Write lock not supported on Solaris. To add support both types
- -- pthread_rwlock_t and pthread_rwlockattr_t must properly be defined
- -- with the associated routines pthread_rwlock_[init/destroy] and
- -- pthread_rwlock_[rdlock/wrlock/unlock].
-
- subtype pthread_rwlock_t is pthread_mutex_t;
- subtype pthread_rwlockattr_t is pthread_mutexattr_t;
-
PTHREAD_CREATE_DETACHED : constant := 16#40#;
PTHREAD_SCOPE_PROCESS : constant := 0;
procedure Finalize_Protection (Object : in out Protection) is
begin
- if Locking_Policy = 'R' then
- Finalize_Lock (Object.RWL'Unrestricted_Access);
- else
- Finalize_Lock (Object.L'Unrestricted_Access);
- end if;
+ Finalize_Lock (Object.L'Unrestricted_Access);
end Finalize_Protection;
---------------------------
Init_Priority := System.Priority'Last;
end if;
- if Locking_Policy = 'R' then
- Initialize_Lock (Init_Priority, Object.RWL'Access);
- else
- Initialize_Lock (Init_Priority, Object.L'Access);
- end if;
+ Initialize_Lock (Init_Priority, Object.L'Access);
Object.Ceiling := System.Any_Priority (Init_Priority);
Object.New_Ceiling := System.Any_Priority (Init_Priority);
Object.Owner := Null_Task;
raise Program_Error;
end if;
- if Locking_Policy = 'R' then
- Write_Lock (Object.RWL'Access, Ceiling_Violation);
- else
- Write_Lock (Object.L'Access, Ceiling_Violation);
- end if;
+ Write_Lock (Object.L'Access, Ceiling_Violation);
if Parameters.Runtime_Traces then
Send_Trace_Info (PO_Lock);
raise Program_Error;
end if;
- if Locking_Policy = 'R' then
- Read_Lock (Object.RWL'Access, Ceiling_Violation);
- else
- Write_Lock (Object.L'Access, Ceiling_Violation);
- end if;
+ Read_Lock (Object.L'Access, Ceiling_Violation);
if Parameters.Runtime_Traces then
Send_Trace_Info (PO_Lock);
Object.Ceiling := Object.New_Ceiling;
end if;
- if Locking_Policy = 'R' then
- Unlock (Object.RWL'Access);
- else
- Unlock (Object.L'Access);
- end if;
+ Unlock (Object.L'Access);
if Parameters.Runtime_Traces then
Send_Trace_Info (PO_Unlock);
L : aliased Task_Primitives.Lock;
-- Lock used to ensure mutual exclusive access to the protected object
- RWL : aliased Task_Primitives.RW_Lock;
- -- Lock used to support conccurent readers to the protected object
-
Ceiling : System.Any_Priority;
-- Ceiling priority associated to the protected object
null;
end Finalize_Lock;
- procedure Finalize_Lock (L : not null access RW_Lock) is
- begin
- null;
- end Finalize_Lock;
-
procedure Finalize_Lock (L : not null access RTS_Lock) is
begin
null;
null;
end Initialize_Lock;
- procedure Initialize_Lock
- (Prio : System.Any_Priority;
- L : not null access RW_Lock)
- is
- begin
- null;
- end Initialize_Lock;
-
procedure Initialize_Lock
(L : not null access RTS_Lock; Level : Lock_Level) is
begin
---------------
procedure Read_Lock
- (L : not null access RW_Lock;
+ (L : not null access Lock;
Ceiling_Violation : out Boolean)
is
begin
null;
end Unlock;
- procedure Unlock (L : not null access RW_Lock) is
- begin
- null;
- end Unlock;
-
procedure Unlock
(L : not null access RTS_Lock;
Global_Lock : Boolean := False)
Ceiling_Violation := False;
end Write_Lock;
- procedure Write_Lock
- (L : not null access RW_Lock;
- Ceiling_Violation : out Boolean)
- is
- begin
- Ceiling_Violation := False;
- end Write_Lock;
-
procedure Write_Lock
(L : not null access RTS_Lock;
Global_Lock : Boolean := False)
pragma Assert (Result = 0);
end Initialize_Lock;
- procedure Initialize_Lock
- (Prio : System.Any_Priority;
- L : not null access RW_Lock)
- is
- begin
- Initialize_Lock (Prio, Lock (L.all)'Unrestricted_Access);
- end Initialize_Lock;
-
procedure Initialize_Lock
(L : not null access RTS_Lock;
Level : Lock_Level)
pragma Assert (Result = 0);
end Finalize_Lock;
- procedure Finalize_Lock (L : not null access RW_Lock) is
- begin
- Finalize_Lock (Lock (L.all)'Unrestricted_Access);
- end Finalize_Lock;
-
procedure Finalize_Lock (L : not null access RTS_Lock) is
Result : Interfaces.C.int;
begin
Ceiling_Violation := False;
end Write_Lock;
- procedure Write_Lock
- (L : not null access RW_Lock;
- Ceiling_Violation : out Boolean)
- is
- begin
- Write_Lock (Lock (L.all)'Unrestricted_Access, Ceiling_Violation);
- end Write_Lock;
-
procedure Write_Lock
(L : not null access RTS_Lock;
Global_Lock : Boolean := False)
---------------
procedure Read_Lock
- (L : not null access RW_Lock;
+ (L : not null access Lock;
Ceiling_Violation : out Boolean)
is
begin
pragma Assert (Result = 0);
end Unlock;
- procedure Unlock (L : not null access RW_Lock) is
- begin
- Unlock (Lock (L.all)'Unrestricted_Access);
- end Unlock;
-
procedure Unlock
(L : not null access RTS_Lock;
Global_Lock : Boolean := False)
pragma Assert (Result = 0);
end Initialize_Lock;
- procedure Initialize_Lock
- (Prio : System.Any_Priority;
- L : not null access RW_Lock)
- is
- begin
- Initialize_Lock (Prio, Lock (L.all)'Unrestricted_Access);
- end Initialize_Lock;
-
procedure Initialize_Lock
(L : not null access RTS_Lock;
Level : Lock_Level)
pragma Assert (Result = 0);
end Finalize_Lock;
- procedure Finalize_Lock (L : not null access RW_Lock) is
- begin
- Finalize_Lock (Lock (L.all)'Unrestricted_Access);
- end Finalize_Lock;
-
procedure Finalize_Lock (L : not null access RTS_Lock) is
Result : Interfaces.C.int;
begin
pragma Assert (Result = 0 or else Result = EINVAL);
end Write_Lock;
- procedure Write_Lock
- (L : not null access RW_Lock; Ceiling_Violation : out Boolean)
- is
- begin
- Write_Lock (Lock (L.all)'Unrestricted_Access, Ceiling_Violation);
- end Write_Lock;
-
procedure Write_Lock
(L : not null access RTS_Lock;
Global_Lock : Boolean := False)
---------------
procedure Read_Lock
- (L : not null access RW_Lock; Ceiling_Violation : out Boolean) is
+ (L : not null access Lock; Ceiling_Violation : out Boolean) is
begin
Write_Lock (L, Ceiling_Violation);
end Read_Lock;
pragma Assert (Result = 0);
end Unlock;
- procedure Unlock (L : not null access RW_Lock) is
- begin
- Unlock (Lock (L.all)'Unrestricted_Access);
- end Unlock;
-
procedure Unlock
(L : not null access RTS_Lock;
Global_Lock : Boolean := False)
Dispatching_Policy : Character;
pragma Import (C, Dispatching_Policy, "__gl_task_dispatching_policy");
+ Locking_Policy : Character;
+ pragma Import (C, Locking_Policy, "__gl_locking_policy");
+
Foreign_Task_Elaborated : aliased Boolean := True;
-- Used to identified fake tasks (i.e., non-Ada Threads)
is
pragma Unreferenced (Prio);
- Mutex_Attr : aliased pthread_mutexattr_t;
- Result : Interfaces.C.int;
-
begin
- Result := pthread_mutexattr_init (Mutex_Attr'Access);
- pragma Assert (Result = 0);
+ if Locking_Policy = 'R' then
+ declare
+ RWlock_Attr : aliased pthread_rwlockattr_t;
+ Result : Interfaces.C.int;
- Result := pthread_mutex_init (L, Mutex_Attr'Access);
+ begin
+ -- Set the rwlock to prefer writer to avoid writers starvation
- pragma Assert (Result = 0 or else Result = ENOMEM);
+ Result := pthread_rwlockattr_init (RWlock_Attr'Access);
+ pragma Assert (Result = 0);
- if Result = ENOMEM then
- raise Storage_Error with "Failed to allocate a lock";
- end if;
- end Initialize_Lock;
+ Result := pthread_rwlockattr_setkind_np
+ (RWlock_Attr'Access,
+ PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
+ pragma Assert (Result = 0);
- procedure Initialize_Lock
- (Prio : System.Any_Priority;
- L : not null access RW_Lock)
- is
- pragma Unreferenced (Prio);
+ Result := pthread_rwlock_init (L.RW'Access, RWlock_Attr'Access);
- RWlock_Attr : aliased pthread_rwlockattr_t;
- Result : Interfaces.C.int;
+ pragma Assert (Result = 0 or else Result = ENOMEM);
- begin
- -- Set the rwlock to prefer writer to avoid writers starvation
+ if Result = ENOMEM then
+ raise Storage_Error with "Failed to allocate a lock";
+ end if;
+ end;
- Result := pthread_rwlockattr_init (RWlock_Attr'Access);
- pragma Assert (Result = 0);
+ else
+ declare
+ Mutex_Attr : aliased pthread_mutexattr_t;
+ Result : Interfaces.C.int;
- Result := pthread_rwlockattr_setkind_np
- (RWlock_Attr'Access, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
- pragma Assert (Result = 0);
+ begin
+ Result := pthread_mutexattr_init (Mutex_Attr'Access);
+ pragma Assert (Result = 0);
- Result := pthread_rwlock_init (L, RWlock_Attr'Access);
+ Result := pthread_mutex_init (L.WO'Access, Mutex_Attr'Access);
- pragma Assert (Result = 0 or else Result = ENOMEM);
+ pragma Assert (Result = 0 or else Result = ENOMEM);
- if Result = ENOMEM then
- raise Storage_Error with "Failed to allocate a lock";
+ if Result = ENOMEM then
+ raise Storage_Error with "Failed to allocate a lock";
+ end if;
+ end;
end if;
end Initialize_Lock;
procedure Finalize_Lock (L : not null access Lock) is
Result : Interfaces.C.int;
begin
- Result := pthread_mutex_destroy (L);
- pragma Assert (Result = 0);
- end Finalize_Lock;
-
- procedure Finalize_Lock (L : not null access RW_Lock) is
- Result : Interfaces.C.int;
- begin
- Result := pthread_rwlock_destroy (L);
+ if Locking_Policy = 'R' then
+ Result := pthread_rwlock_destroy (L.RW'Access);
+ else
+ Result := pthread_mutex_destroy (L.WO'Access);
+ end if;
pragma Assert (Result = 0);
end Finalize_Lock;
is
Result : Interfaces.C.int;
begin
- Result := pthread_mutex_lock (L);
- Ceiling_Violation := Result = EINVAL;
-
- -- Assume the cause of EINVAL is a priority ceiling violation
-
- pragma Assert (Result = 0 or else Result = EINVAL);
- end Write_Lock;
+ if Locking_Policy = 'R' then
+ Result := pthread_rwlock_wrlock (L.RW'Access);
+ else
+ Result := pthread_mutex_lock (L.WO'Access);
+ end if;
- procedure Write_Lock
- (L : not null access RW_Lock;
- Ceiling_Violation : out Boolean)
- is
- Result : Interfaces.C.int;
- begin
- Result := pthread_rwlock_wrlock (L);
Ceiling_Violation := Result = EINVAL;
-- Assume the cause of EINVAL is a priority ceiling violation
---------------
procedure Read_Lock
- (L : not null access RW_Lock;
+ (L : not null access Lock;
Ceiling_Violation : out Boolean)
is
Result : Interfaces.C.int;
begin
- Result := pthread_rwlock_rdlock (L);
+ if Locking_Policy = 'R' then
+ Result := pthread_rwlock_rdlock (L.RW'Access);
+ else
+ Result := pthread_mutex_lock (L.WO'Access);
+ end if;
+
Ceiling_Violation := Result = EINVAL;
-- Assume the cause of EINVAL is a priority ceiling violation
procedure Unlock (L : not null access Lock) is
Result : Interfaces.C.int;
begin
- Result := pthread_mutex_unlock (L);
- pragma Assert (Result = 0);
- end Unlock;
-
- procedure Unlock (L : not null access RW_Lock) is
- Result : Interfaces.C.int;
- begin
- Result := pthread_rwlock_unlock (L);
+ if Locking_Policy = 'R' then
+ Result := pthread_rwlock_unlock (L.RW'Access);
+ else
+ Result := pthread_mutex_unlock (L.WO'Access);
+ end if;
pragma Assert (Result = 0);
end Unlock;
L.Priority := Prio;
end Initialize_Lock;
- procedure Initialize_Lock
- (Prio : System.Any_Priority;
- L : not null access RW_Lock)
- is
- begin
- Initialize_Lock (Prio, Lock (L.all)'Unrestricted_Access);
- end Initialize_Lock;
-
procedure Initialize_Lock
(L : not null access RTS_Lock; Level : Lock_Level)
is
DeleteCriticalSection (L.Mutex'Access);
end Finalize_Lock;
- procedure Finalize_Lock (L : not null access RW_Lock) is
- begin
- Finalize_Lock (Lock (L.all)'Unrestricted_Access);
- end Finalize_Lock;
-
procedure Finalize_Lock (L : not null access RTS_Lock) is
begin
DeleteCriticalSection (L);
Ceiling_Violation := False;
end Write_Lock;
- procedure Write_Lock
- (L : not null access RW_Lock; Ceiling_Violation : out Boolean) is
- begin
- Write_Lock (Lock (L.all)'Unrestricted_Access, Ceiling_Violation);
- end Write_Lock;
-
procedure Write_Lock
(L : not null access RTS_Lock;
Global_Lock : Boolean := False)
---------------
procedure Read_Lock
- (L : not null access RW_Lock; Ceiling_Violation : out Boolean) is
+ (L : not null access Lock; Ceiling_Violation : out Boolean) is
begin
Write_Lock (L, Ceiling_Violation);
end Read_Lock;
LeaveCriticalSection (L.Mutex'Access);
end Unlock;
- procedure Unlock (L : not null access RW_Lock) is
- begin
- Unlock (Lock (L.all)'Unrestricted_Access);
- end Unlock;
-
procedure Unlock
(L : not null access RTS_Lock; Global_Lock : Boolean := False) is
begin
pragma Assert (Result = 0);
end Initialize_Lock;
- procedure Initialize_Lock
- (Prio : System.Any_Priority;
- L : not null access RW_Lock)
- is
- begin
- Initialize_Lock (Prio, Lock (L.all)'Unrestricted_Access);
- end Initialize_Lock;
-
procedure Initialize_Lock
(L : not null access RTS_Lock; Level : Lock_Level)
is
pragma Assert (Result = 0);
end Finalize_Lock;
- procedure Finalize_Lock (L : not null access RW_Lock) is
- begin
- Finalize_Lock (Lock (L.all)'Unrestricted_Access);
- end Finalize_Lock;
-
procedure Finalize_Lock (L : not null access RTS_Lock) is
Result : Interfaces.C.int;
begin
pragma Assert (Result = 0 or else Result = EINVAL);
end Write_Lock;
- procedure Write_Lock
- (L : not null access RW_Lock; Ceiling_Violation : out Boolean)
- is
- begin
- Write_Lock (Lock (L.all)'Unrestricted_Access, Ceiling_Violation);
- end Write_Lock;
-
procedure Write_Lock
(L : not null access RTS_Lock;
Global_Lock : Boolean := False)
---------------
procedure Read_Lock
- (L : not null access RW_Lock; Ceiling_Violation : out Boolean) is
+ (L : not null access Lock; Ceiling_Violation : out Boolean) is
begin
Write_Lock (L, Ceiling_Violation);
end Read_Lock;
pragma Assert (Result = 0);
end Unlock;
- procedure Unlock (L : not null access RW_Lock) is
- begin
- Unlock (Lock (L.all)'Unrestricted_Access);
- end Unlock;
-
procedure Unlock
(L : not null access RTS_Lock; Global_Lock : Boolean := False)
is
end if;
end Initialize_Lock;
- procedure Initialize_Lock
- (Prio : System.Any_Priority;
- L : not null access RW_Lock)
- is
- begin
- Initialize_Lock (Prio, Lock (L.all)'Unrestricted_Access);
- end Initialize_Lock;
-
procedure Initialize_Lock
(L : not null access RTS_Lock;
Level : Lock_Level)
pragma Assert (Result = 0);
end Finalize_Lock;
- procedure Finalize_Lock (L : not null access RW_Lock) is
- begin
- Finalize_Lock (Lock (L.all)'Unrestricted_Access);
- end Finalize_Lock;
-
procedure Finalize_Lock (L : not null access RTS_Lock) is
Result : Interfaces.C.int;
begin
pragma Assert (Record_Lock (Lock_Ptr (L)));
end Write_Lock;
- procedure Write_Lock
- (L : not null access RW_Lock;
- Ceiling_Violation : out Boolean)
- is
- begin
- Write_Lock (Lock (L.all)'Unrestricted_Access, Ceiling_Violation);
- end Write_Lock;
-
procedure Write_Lock
(L : not null access RTS_Lock;
Global_Lock : Boolean := False)
---------------
procedure Read_Lock
- (L : not null access RW_Lock;
+ (L : not null access Lock;
Ceiling_Violation : out Boolean) is
begin
Write_Lock (L, Ceiling_Violation);
end if;
end Unlock;
- procedure Unlock (L : not null access RW_Lock) is
- begin
- Unlock (Lock (L.all)'Unrestricted_Access);
- end Unlock;
-
procedure Unlock
(L : not null access RTS_Lock;
Global_Lock : Boolean := False)
pragma Assert (Result = 0);
end Initialize_Lock;
- procedure Initialize_Lock
- (Prio : System.Any_Priority;
- L : not null access RW_Lock)
- is
- begin
- Initialize_Lock (Prio, Lock (L.all)'Unrestricted_Access);
- end Initialize_Lock;
-
procedure Initialize_Lock
(L : not null access RTS_Lock;
Level : Lock_Level)
pragma Assert (Result = 0);
end Finalize_Lock;
- procedure Finalize_Lock (L : not null access RW_Lock) is
- begin
- Finalize_Lock (Lock (L.all)'Unrestricted_Access);
- end Finalize_Lock;
-
procedure Finalize_Lock (L : not null access RTS_Lock) is
Result : Interfaces.C.int;
begin
Ceiling_Violation := False;
end Write_Lock;
- procedure Write_Lock
- (L : not null access RW_Lock;
- Ceiling_Violation : out Boolean)
- is
- begin
- Write_Lock (Lock (L.all)'Unrestricted_Access, Ceiling_Violation);
- end Write_Lock;
-
procedure Write_Lock
(L : not null access RTS_Lock;
Global_Lock : Boolean := False)
---------------
procedure Read_Lock
- (L : not null access RW_Lock;
+ (L : not null access Lock;
Ceiling_Violation : out Boolean)
is
begin
pragma Assert (Result = 0);
end Unlock;
- procedure Unlock (L : not null access RW_Lock) is
- begin
- Unlock (Lock (L.all)'Unrestricted_Access);
- end Unlock;
-
procedure Unlock
(L : not null access RTS_Lock;
Global_Lock : Boolean := False)
pragma Assert (Result = 0);
end Initialize_Lock;
- procedure Initialize_Lock
- (Prio : System.Any_Priority;
- L : not null access RW_Lock) is
- begin
- Initialize_Lock (Prio, Lock (L.all)'Unrestricted_Access);
- end Initialize_Lock;
-
procedure Initialize_Lock
(L : not null access RTS_Lock;
Level : Lock_Level)
pragma Assert (Result = 0);
end Finalize_Lock;
- procedure Finalize_Lock (L : not null access RW_Lock) is
- begin
- Finalize_Lock (Lock (L.all)'Unrestricted_Access);
- end Finalize_Lock;
-
procedure Finalize_Lock (L : not null access RTS_Lock) is
Result : Interfaces.C.int;
begin
-- Set_Priority (Self_ID, System.Any_Priority (L.Prio));
end Write_Lock;
- procedure Write_Lock
- (L : not null access RW_Lock;
- Ceiling_Violation : out Boolean)
- is
- begin
- Write_Lock (Lock (L.all)'Unrestricted_Access, Ceiling_Violation);
- end Write_Lock;
-
procedure Write_Lock
(L : not null access RTS_Lock;
Global_Lock : Boolean := False)
---------------
procedure Read_Lock
- (L : not null access RW_Lock;
+ (L : not null access Lock;
Ceiling_Violation : out Boolean)
is
begin
pragma Assert (Result = 0);
end Unlock;
- procedure Unlock (L : not null access RW_Lock) is
- begin
- Unlock (Lock (L.all)'Unrestricted_Access);
- end Unlock;
-
procedure Unlock
(L : not null access RTS_Lock;
Global_Lock : Boolean := False)
pragma Assert (L.Mutex /= 0);
end Initialize_Lock;
- procedure Initialize_Lock
- (Prio : System.Any_Priority;
- L : not null access RW_Lock)
- is
- begin
- Initialize_Lock (Prio, Lock (L.all)'Unrestricted_Access);
- end Initialize_Lock;
-
procedure Initialize_Lock
(L : not null access RTS_Lock;
Level : Lock_Level)
pragma Assert (Result = 0);
end Finalize_Lock;
- procedure Finalize_Lock (L : not null access RW_Lock) is
- begin
- Finalize_Lock (Lock (L.all)'Unrestricted_Access);
- end Finalize_Lock;
-
procedure Finalize_Lock (L : not null access RTS_Lock) is
Result : int;
begin
pragma Assert (Result = 0);
end Write_Lock;
- procedure Write_Lock
- (L : not null access RW_Lock;
- Ceiling_Violation : out Boolean)
- is
- begin
- Write_Lock (Lock (L.all)'Unrestricted_Access, Ceiling_Violation);
- end Write_Lock;
-
procedure Write_Lock
(L : not null access RTS_Lock;
Global_Lock : Boolean := False)
---------------
procedure Read_Lock
- (L : not null access RW_Lock;
+ (L : not null access Lock;
Ceiling_Violation : out Boolean)
is
begin
pragma Assert (Result = 0);
end Unlock;
- procedure Unlock (L : not null access RW_Lock) is
- begin
- Unlock (Lock (L.all)'Unrestricted_Access);
- end Unlock;
-
procedure Unlock
(L : not null access RTS_Lock;
Global_Lock : Boolean := False)
procedure Initialize_Lock
(Prio : System.Any_Priority;
L : not null access Lock);
- procedure Initialize_Lock
- (Prio : System.Any_Priority;
- L : not null access RW_Lock);
procedure Initialize_Lock
(L : not null access RTS_Lock;
Level : Lock_Level);
-- These operations raise Storage_Error if a lack of storage is detected
procedure Finalize_Lock (L : not null access Lock);
- procedure Finalize_Lock (L : not null access RW_Lock);
procedure Finalize_Lock (L : not null access RTS_Lock);
pragma Inline (Finalize_Lock);
-- Finalize a lock object, freeing any resources allocated by the
procedure Write_Lock
(L : not null access Lock;
Ceiling_Violation : out Boolean);
- procedure Write_Lock
- (L : not null access RW_Lock;
- Ceiling_Violation : out Boolean);
procedure Write_Lock
(L : not null access RTS_Lock;
Global_Lock : Boolean := False);
-- per-task lock is implicit in Exit_Task.
procedure Read_Lock
- (L : not null access RW_Lock;
+ (L : not null access Lock;
Ceiling_Violation : out Boolean);
pragma Inline (Read_Lock);
-- Lock a lock object for read access. After this operation returns,
procedure Unlock
(L : not null access Lock);
- procedure Unlock
- (L : not null access RW_Lock);
procedure Unlock
(L : not null access RTS_Lock;
Global_Lock : Boolean := False);
type Lock is new Integer;
- type RW_Lock is new Integer;
-
type RTS_Lock is new Integer;
type Suspension_Object is new Integer;
pragma Preelaborate;
type Lock is limited private;
- type RW_Lock is limited private;
-- Should be used for implementation of protected objects
type RTS_Lock is limited private;
Owner_Priority : Integer;
end record;
- type RW_Lock is new Lock;
-
type RTS_Lock is new System.OS_Interface.pthread_mutex_t;
type Suspension_Object is record
pragma Preelaborate;
type Lock is limited private;
- type RW_Lock is limited private;
-- Should be used for implementation of protected objects
type RTS_Lock is limited private;
Owner_Priority : Integer;
end record;
- type RW_Lock is new Lock;
-
type Condition_Variable is new System.Win32.HANDLE;
type RTS_Lock is new System.OS_Interface.CRITICAL_SECTION;
pragma Preelaborate;
type Lock is limited private;
- type RW_Lock is limited private;
-- Should be used for implementation of protected objects
type RTS_Lock is limited private;
private
- type Lock is new System.OS_Interface.pthread_mutex_t;
- type RW_Lock is new System.OS_Interface.pthread_rwlock_t;
+ type Lock is record
+ WO : System.OS_Interface.pthread_mutex_t;
+ RW : System.OS_Interface.pthread_rwlock_t;
+ end record;
+
type RTS_Lock is new System.OS_Interface.pthread_mutex_t;
type Suspension_Object is record
pragma Preelaborate;
type Lock is limited private;
- type RW_Lock is limited private;
-- Should be used for implementation of protected objects
type RTS_Lock is limited private;
private
- type Lock is new System.OS_Interface.pthread_mutex_t;
- type RW_Lock is new System.OS_Interface.pthread_rwlock_t;
+ type Lock is record
+ RW : aliased System.OS_Interface.pthread_rwlock_t;
+ WO : aliased System.OS_Interface.pthread_mutex_t;
+ end record;
+
type RTS_Lock is new System.OS_Interface.pthread_mutex_t;
type Suspension_Object is record
type Lock is limited private;
type Lock_Ptr is access all Lock;
- type RW_Lock is limited private;
-- Should be used for implementation of protected objects
type RTS_Lock is limited private;
Frozen : Boolean := False;
end record;
- type RW_Lock is new Lock;
-
type RTS_Lock is new Lock;
type Suspension_Object is record
pragma Preelaborate;
type Lock is limited private;
- type RW_Lock is limited private;
-- Should be used for implementation of protected objects
type RTS_Lock is limited private;
Ceiling : Interfaces.C.int;
end record;
- type RW_Lock is new Lock;
-
type RTS_Lock is new System.OS_Interface.pthread_mutex_t;
type Suspension_Object is record
pragma Preelaborate;
type Lock is limited private;
- type RW_Lock is limited private;
-- Should be used for implementation of protected objects
type RTS_Lock is limited private;
Prio_Save : Interfaces.C.int;
end record;
- type RW_Lock is new Lock;
-
type RTS_Lock is new System.OS_Interface.pthread_mutex_t;
type Suspension_Object is record
pragma Preelaborate;
type Lock is limited private;
- type RW_Lock is limited private;
-- Should be used for implementation of protected objects
type RTS_Lock is limited private;
-- Priority ceiling of lock
end record;
- type RW_Lock is new Lock;
-
type RTS_Lock is new Lock;
type Suspension_Object is record
return;
end if;
- if Locking_Policy = 'R' then
- STPO.Write_Lock (Object.RWL'Unrestricted_Access, Ceiling_Violation);
- else
- STPO.Write_Lock (Object.L'Unrestricted_Access, Ceiling_Violation);
- end if;
+ STPO.Write_Lock (Object.L'Unrestricted_Access, Ceiling_Violation);
if Single_Lock then
Lock_RTS;
Unlock_RTS;
end if;
- if Locking_Policy = 'R' then
- STPO.Write_Lock
- (Object.RWL'Unrestricted_Access, Ceiling_Violation);
- else
- STPO.Write_Lock (Object.L'Unrestricted_Access, Ceiling_Violation);
- end if;
+ STPO.Write_Lock (Object.L'Unrestricted_Access, Ceiling_Violation);
if Ceiling_Violation then
raise Program_Error with "Ceiling Violation";
Unlock_RTS;
end if;
- if Locking_Policy = 'R' then
- STPO.Unlock (Object.RWL'Unrestricted_Access);
- STPO.Finalize_Lock (Object.RWL'Unrestricted_Access);
- else
- STPO.Unlock (Object.L'Unrestricted_Access);
- STPO.Finalize_Lock (Object.L'Unrestricted_Access);
- end if;
+ STPO.Unlock (Object.L'Unrestricted_Access);
+
+ STPO.Finalize_Lock (Object.L'Unrestricted_Access);
end Finalize;
----------------------
-- pragma Assert (Self_Id.Deferral_Level = 0);
Initialization.Defer_Abort_Nestable (Self_ID);
-
- if Locking_Policy = 'R' then
- Initialize_Lock (Init_Priority, Object.RWL'Access);
- else
- Initialize_Lock (Init_Priority, Object.L'Access);
- end if;
-
+ Initialize_Lock (Init_Priority, Object.L'Access);
Initialization.Undefer_Abort_Nestable (Self_ID);
Object.Ceiling := System.Any_Priority (Init_Priority);
(STPO.Self.Deferral_Level > 0
or else not Restrictions.Abort_Allowed);
- if Locking_Policy = 'R' then
- Write_Lock (Object.RWL'Access, Ceiling_Violation);
- else
- Write_Lock (Object.L'Access, Ceiling_Violation);
- end if;
+ Write_Lock (Object.L'Access, Ceiling_Violation);
-- We are entering in a protected action, so that we increase the
-- protected object nesting level (if pragma Detect_Blocking is
raise Program_Error;
end if;
- if Locking_Policy = 'R' then
- Read_Lock (Object.RWL'Access, Ceiling_Violation);
- else
- Write_Lock (Object.L'Access, Ceiling_Violation);
- end if;
+ Read_Lock (Object.L'Access, Ceiling_Violation);
if Ceiling_Violation then
raise Program_Error with "Ceiling Violation";
Object.Ceiling := Object.New_Ceiling;
end if;
- if Locking_Policy = 'R' then
- Unlock (Object.RWL'Access);
- else
- Unlock (Object.L'Access);
- end if;
+ Unlock (Object.L'Access);
end Unlock_Entries;
end System.Tasking.Protected_Objects.Entries;
type Protection_Entries (Num_Entries : Protected_Entry_Index) is new
Ada.Finalization.Limited_Controlled
with record
- L : aliased Task_Primitives.Lock;
- RWL : aliased Task_Primitives.RW_Lock;
+ L : aliased Task_Primitives.Lock;
-- The underlying lock associated with a Protection_Entries.
-- Note that you should never (un)lock Object.L directly, but instead
-- use Lock_Entries/Unlock_Entries.