summaryrefslogtreecommitdiff
path: root/gcc/ada/s-taenca.adb
diff options
context:
space:
mode:
authorGeert Bosch <bosch@gcc.gnu.org>2002-03-08 21:11:04 +0100
committerGeert Bosch <bosch@gcc.gnu.org>2002-03-08 21:11:04 +0100
commit07fc65c47c45af6439208797e1ab26f7daedb666 (patch)
treeb584a79288c93215b05fb451943291ccd039388b /gcc/ada/s-taenca.adb
parent24965e7a8ac518b99a3bd7ef5b2d8d88f96bf514 (diff)
downloadgcc-07fc65c47c45af6439208797e1ab26f7daedb666.tar.gz
41intnam.ads, [...]: Merge in ACT changes.
* 41intnam.ads, 42intnam.ads, 4aintnam.ads, 4cintnam.ads, 4dintnam.ads, 4gintnam.ads, 4hintnam.ads, 4lintnam.ads, 4mintnam.ads, 4pintnam.ads, 4rintnam.ads, 4sintnam.ads, 4uintnam.ads, 4vcalend.adb, 4zintnam.ads, 52system.ads, 5amastop.adb, 5asystem.ads, 5ataprop.adb, 5atpopsp.adb, 5avxwork.ads, 5bosinte.adb, 5bsystem.ads, 5esystem.ads, 5fsystem.ads, 5ftaprop.adb, 5ginterr.adb, 5gmastop.adb, 5gsystem.ads, 5gtaprop.adb, 5gtasinf.adb, 5gtasinf.ads, 5hparame.ads, 5hsystem.ads, 5htaprop.adb, 5htraceb.adb, 5itaprop.adb, 5ksystem.ads, 5kvxwork.ads, 5lintman.adb, 5lsystem.ads, 5mvxwork.ads, 5ninmaop.adb, 5nosinte.ads, 5ntaprop.adb, 5ointerr.adb, 5omastop.adb, 5oosinte.adb, 5osystem.ads, 5otaprop.adb, 5otaspri.ads, 5pvxwork.ads, 5qtaprop.adb, 5sintman.adb, 5ssystem.ads, 5staprop.adb, 5stpopse.adb, 5svxwork.ads, 5tosinte.ads, 5uintman.adb, 5vasthan.adb, 5vinmaop.adb, 5vinterr.adb, 5vintman.adb, 5vmastop.adb, 5vparame.ads, 5vsystem.ads, 5vtaprop.adb, 5vtpopde.adb, 5wmemory.adb, 5wsystem.ads, 5wtaprop.adb, 5ysystem.ads, 5zinterr.adb, 5zintman.adb, 5zosinte.adb, 5zosinte.ads, 5zsystem.ads, 5ztaprop.adb, 6vcpp.adb, 6vcstrea.adb, 7sintman.adb, 7staprop.adb, 7stpopsp.adb, 9drpc.adb, Make-lang.in, Makefile.in, a-caldel.adb, a-comlin.ads, a-dynpri.adb, a-except.adb, a-except.ads, a-finali.adb, a-ncelfu.ads, a-reatim.adb, a-retide.adb, a-stream.ads, a-ststio.adb, a-ststio.ads, a-stwifi.adb, a-tags.adb, a-tasatt.adb, a-textio.adb, a-tideau.adb, a-tiflau.adb, a-tigeau.adb, a-tigeau.ads, a-tiinau.adb, a-timoau.adb, a-witeio.adb, a-wtdeau.adb, a-wtenau.adb, a-wtflau.adb, a-wtgeau.adb, a-wtgeau.ads, a-wtinau.adb, a-wtmoau.adb, ada-tree.def, ada-tree.h, adaint.c, adaint.h, ali-util.adb, ali.adb, ali.ads, atree.adb, atree.ads, atree.h, back_end.adb, bcheck.adb, bindgen.adb, bindusg.adb, checks.adb, comperr.adb, config-lang.in, csets.adb, csets.ads, cstand.adb, cstreams.c, debug.adb, debug.ads, decl.c, einfo.adb, einfo.ads, einfo.h, elists.h, errout.adb, errout.ads, eval_fat.adb, exp_aggr.adb, exp_attr.adb, exp_ch11.adb, exp_ch12.adb, exp_ch13.adb, exp_ch2.adb, exp_ch3.adb, exp_ch3.ads, exp_ch4.adb, exp_ch5.adb, exp_ch6.adb, exp_ch7.adb, exp_ch7.ads, exp_ch9.adb, exp_ch9.ads, exp_dbug.adb, exp_dbug.ads, exp_disp.ads, exp_dist.adb, exp_fixd.adb, exp_intr.adb, exp_pakd.adb, exp_prag.adb, exp_strm.adb, exp_util.adb, exp_util.ads, expander.adb, expect.c, fe.h, fmap.adb, fmap.ads, fname-uf.adb, freeze.adb, frontend.adb, g-awk.adb, g-cgideb.adb, g-comlin.adb, g-comlin.ads, g-debpoo.adb, g-dirope.adb, g-dirope.ads, g-dyntab.adb, g-expect.adb, g-expect.ads, g-io.ads, g-io_aux.adb, g-io_aux.ads, g-locfil.adb, g-locfil.ads, g-os_lib.adb, g-os_lib.ads, g-regexp.adb, g-regpat.adb, g-socket.adb, g-socket.ads, g-spipat.adb, g-table.adb, g-trasym.adb, g-trasym.ads, gigi.h, gmem.c, gnat1drv.adb, gnatbind.adb, gnatbl.c, gnatchop.adb, gnatcmd.adb, gnatdll.adb, gnatfind.adb, gnatlbr.adb, gnatlink.adb, gnatls.adb, gnatmem.adb, gnatprep.adb, gnatvsn.ads, gnatxref.adb, hlo.adb, hostparm.ads, i-cobol.adb, i-cpp.adb, i-cstrea.ads, i-cstrin.adb, i-pacdec.adb, i-vxwork.ads, impunit.adb, init.c, inline.adb, io-aux.c, layout.adb, lib-load.adb, lib-util.adb, lib-writ.adb, lib-writ.ads, lib-xref.adb, lib-xref.ads, lib.adb, lib.ads, make.adb, makeusg.adb, mdll.adb, memroot.adb, misc.c, mlib-tgt.adb, mlib-utl.adb, mlib-utl.ads, mlib.adb, namet.adb, namet.ads, namet.h, nlists.h, nmake.adb, nmake.ads, nmake.adt, opt.adb, opt.ads, osint.adb, osint.ads, output.adb, output.ads, par-ch2.adb, par-ch3.adb, par-ch5.adb, par-prag.adb, par-tchk.adb, par-util.adb, par.adb, prj-attr.adb, prj-dect.adb, prj-env.adb, prj-env.ads, prj-nmsc.adb, prj-part.adb, prj-proc.adb, prj-strt.adb, prj-tree.adb, prj-tree.ads, prj.adb, prj.ads, raise.c, raise.h, repinfo.adb, restrict.adb, restrict.ads, rident.ads, rtsfind.adb, rtsfind.ads, s-arit64.adb, s-asthan.adb, s-atacco.adb, s-atacco.ads, s-auxdec.adb, s-crc32.adb, s-crc32.ads, s-direio.adb, s-fatgen.adb, s-fileio.adb, s-finimp.adb, s-gloloc.adb, s-gloloc.ads, s-interr.adb, s-mastop.adb, s-mastop.ads, s-memory.adb, s-parame.ads, s-parint.adb, s-pooglo.adb, s-pooloc.adb, s-rpc.adb, s-secsta.adb, s-sequio.adb, s-shasto.adb, s-soflin.adb, s-soflin.ads, s-stache.adb, s-taasde.adb, s-taasde.ads, s-tadeca.adb, s-tadeca.ads, s-tadert.adb, s-tadert.ads, s-taenca.adb, s-taenca.ads, s-taprob.adb, s-taprop.ads, s-tarest.adb, s-tasdeb.adb, s-tasini.adb, s-tasini.ads, s-taskin.adb, s-taskin.ads, s-tasque.adb, s-tasque.ads, s-tasren.adb, s-tasren.ads, s-tassta.adb, s-tasuti.adb, s-tasuti.ads, s-tataat.adb, s-tataat.ads, s-tpoben.adb, s-tpoben.ads, s-tpobop.adb, s-tposen.adb, s-tposen.ads, s-traceb.adb, s-traceb.ads, s-unstyp.ads, s-widenu.adb, scn-nlit.adb, scn.adb, sem.adb, sem_aggr.adb, sem_attr.adb, sem_attr.ads, sem_case.adb, sem_ch10.adb, sem_ch11.adb, sem_ch11.ads, sem_ch12.adb, sem_ch13.adb, sem_ch13.ads, sem_ch2.adb, sem_ch3.adb, sem_ch3.ads, sem_ch4.adb, sem_ch5.adb, sem_ch6.adb, sem_ch6.ads, sem_ch7.adb, sem_ch8.adb, sem_ch8.ads, sem_ch9.adb, sem_disp.adb, sem_dist.adb, sem_elab.adb, sem_elim.adb, sem_elim.ads, sem_eval.adb, sem_intr.adb, sem_mech.adb, sem_prag.adb, sem_res.adb, sem_type.adb, sem_util.adb, sem_util.ads, sem_vfpt.adb, sem_warn.adb, sinfo.adb, sinfo.ads, sinfo.h, sinput-l.adb, sinput-l.ads, sinput.adb, sinput.ads, snames.adb, snames.ads, snames.h, sprint.adb, sprint.ads, stringt.adb, stringt.ads, stringt.h, style.adb, switch.adb, switch.ads, sysdep.c, system.ads, table.adb, targparm.adb, targparm.ads, targtyps.c, tbuild.adb, tbuild.ads, tracebak.c, trans.c, tree_gen.adb, tree_io.adb, treepr.adb, treepr.ads, treeprs.ads, treeprs.adt, ttypes.ads, types.adb, types.ads, types.h, uintp.ads, urealp.ads, usage.adb, utils.c, utils2.c, validsw.adb, xnmake.adb, xr_tabls.adb, xr_tabls.ads, xref_lib.adb, xref_lib.ads : Merge in ACT changes. * 1ssecsta.adb, 1ssecsta.ads, a-chlat9.ads, a-cwila9.ads, g-enblsp.adb, g-md5.adb, g-md5.ads, gnatname.adb, gnatname.ads, mkdir.c, osint-b.adb, osint-b.ads, osint-c.adb, osint-c.ads, osint-l.adb, osint-l.ads, osint-m.adb, osint-m.ads : New files * 3lsoccon.ads, 5qparame.ads, 5qvxwork.ads, 5smastop.adb, 5zparame.ads, gnatmain.adb, gnatmain.ads, gnatpsys.adb : Removed * mdllfile.adb, mdllfile.ads, mdlltool.adb, mdlltool.ads : Renamed to mdll-fil.ad[bs] and mdll-util.ad[bs] * mdll-fil.adb, mdll-fil.ads, mdll-utl.adb, mdll-utl.ads : Renamed from mdllfile.ad[bs] and mdlltool.ad[bs] From-SVN: r50451
Diffstat (limited to 'gcc/ada/s-taenca.adb')
-rw-r--r--gcc/ada/s-taenca.adb375
1 files changed, 193 insertions, 182 deletions
diff --git a/gcc/ada/s-taenca.adb b/gcc/ada/s-taenca.adb
index bf9afbaedad..c44fca2763f 100644
--- a/gcc/ada/s-taenca.adb
+++ b/gcc/ada/s-taenca.adb
@@ -6,9 +6,9 @@
-- --
-- B o d y --
-- --
--- $Revision: 1.36 $
+-- $Revision$
-- --
--- Copyright (C) 1991-2001, Florida State University --
+-- Copyright (C) 1992-2001, Free Software Foundation, Inc. --
-- --
-- GNARL is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -29,17 +29,10 @@
-- covered by the GNU Public License. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. It is --
--- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
--- State University (http://www.gnat.com). --
+-- now maintained by Ada Core Technologies, Inc. (http://www.gnat.com). --
-- --
------------------------------------------------------------------------------
--- This package provides internal RTS calls implementing operations
--- that apply to general entry calls, that is, calls to either
--- protected or task entries.
-
--- These declarations are not part of the GNARL interface
-
with System.Task_Primitives.Operations;
-- used for STPO.Write_Lock
-- Unlock
@@ -67,17 +60,26 @@ with System.Tasking.Queuing;
with System.Tasking.Utilities;
-- used for Exit_One_ATC_Level
+with System.Parameters;
+-- used for Single_Lock
+-- Runtime_Traces
+
+with System.Traces;
+-- used for Send_Trace_Info
+
package body System.Tasking.Entry_Calls is
package STPO renames System.Task_Primitives.Operations;
- use System.Task_Primitives;
- use System.Tasking.Protected_Objects.Entries;
- use System.Tasking.Protected_Objects.Operations;
+ use Parameters;
+ use Task_Primitives;
+ use Protected_Objects.Entries;
+ use Protected_Objects.Operations;
+ use System.Traces;
-- DO NOT use Protected_Objects.Lock or Protected_Objects.Unlock
-- internally. Those operations will raise Program_Error, which
- -- we do are not prepared to handle inside the RTS. Instead, use
+ -- we are not prepared to handle inside the RTS. Instead, use
-- System.Task_Primitives lock operations directly on Protection.L.
-----------------------
@@ -101,23 +103,28 @@ package body System.Tasking.Entry_Calls is
-- hold an ATCB lock, something which is not permitted. Since
-- the server cannot be obtained reliably, it must be obtained unreliably
-- and then checked again once it has been locked.
+ --
+ -- If Single_Lock and server is a PO, release RTS_Lock.
procedure Unlock_Server (Entry_Call : Entry_Call_Link);
-- STPO.Unlock the server targeted by Entry_Call. The server must
-- be locked before calling this.
+ --
+ -- If Single_Lock and server is a PO, take RTS_Lock on exit.
procedure Unlock_And_Update_Server
(Self_ID : Task_ID;
Entry_Call : Entry_Call_Link);
-- Similar to Unlock_Server, but services entry calls if the
-- server is a protected object.
+ --
+ -- If Single_Lock and server is a PO, take RTS_Lock on exit.
procedure Check_Pending_Actions_For_Entry_Call
(Self_ID : Task_ID;
Entry_Call : Entry_Call_Link);
- pragma Inline (Check_Pending_Actions_For_Entry_Call);
-- This procedure performs priority change of a queued call and
- -- dequeuing of an entry call when an the call is cancelled.
+ -- dequeuing of an entry call when the call is cancelled.
-- If the call is dequeued the state should be set to Cancelled.
procedure Poll_Base_Priority_Change_At_Entry_Call
@@ -147,6 +154,8 @@ package body System.Tasking.Entry_Calls is
(Self_ID : Task_ID;
Entry_Call : Entry_Call_Link)
is
+ pragma Warnings (Off, Self_ID);
+
use type Ada.Exceptions.Exception_Id;
procedure Internal_Raise (X : Ada.Exceptions.Exception_Id);
@@ -177,8 +186,7 @@ package body System.Tasking.Entry_Calls is
procedure Check_Pending_Actions_For_Entry_Call
(Self_ID : Task_ID;
- Entry_Call : Entry_Call_Link)
- is
+ Entry_Call : Entry_Call_Link) is
begin
pragma Assert (Self_ID = Entry_Call.Self);
@@ -240,9 +248,19 @@ package body System.Tasking.Entry_Calls is
-- We had very bad luck, interleaving with TWO different
-- requeue operations. Go around the loop and try again.
- STPO.Yield;
+ if Single_Lock then
+ STPO.Unlock_RTS;
+ STPO.Yield;
+ STPO.Lock_RTS;
+ else
+ STPO.Yield;
+ end if;
else
+ if Single_Lock then
+ STPO.Unlock_RTS;
+ end if;
+
Lock_Entries (Test_PO, Ceiling_Violation);
-- ????
@@ -250,7 +268,7 @@ package body System.Tasking.Entry_Calls is
-- when cancelling a call, to allow for the possibility
-- that the priority of the caller has been raised
-- beyond that of the protected entry call by
- -- Ada.Dynamic_Priorities.STPO.Set_Priority.
+ -- Ada.Dynamic_Priorities.Set_Priority.
-- If the current task has a higher priority than the ceiling
-- of the protected object, temporarily lower it. It will
@@ -262,6 +280,10 @@ package body System.Tasking.Entry_Calls is
Old_Base_Priority : System.Any_Priority;
begin
+ if Single_Lock then
+ STPO.Lock_RTS;
+ end if;
+
STPO.Write_Lock (Current_Task);
Old_Base_Priority := Current_Task.Common.Base_Priority;
Current_Task.New_Base_Priority := Test_PO.Ceiling;
@@ -269,6 +291,10 @@ package body System.Tasking.Entry_Calls is
(Current_Task);
STPO.Unlock (Current_Task);
+ if Single_Lock then
+ STPO.Unlock_RTS;
+ end if;
+
-- Following lock should not fail
Lock_Entries (Test_PO);
@@ -280,6 +306,10 @@ package body System.Tasking.Entry_Calls is
exit when To_Address (Test_PO) = Entry_Call.Called_PO;
Unlock_Entries (Test_PO);
+
+ if Single_Lock then
+ STPO.Lock_RTS;
+ end if;
end if;
else
@@ -303,24 +333,26 @@ package body System.Tasking.Entry_Calls is
procedure Poll_Base_Priority_Change_At_Entry_Call
(Self_ID : Task_ID;
- Entry_Call : Entry_Call_Link)
- is
+ Entry_Call : Entry_Call_Link) is
begin
- if Initialization.Dynamic_Priority_Support
- and then Self_ID.Pending_Priority_Change
- then
+ if Dynamic_Priority_Support and then Self_ID.Pending_Priority_Change then
-- Check for ceiling violations ???
Self_ID.Pending_Priority_Change := False;
if Self_ID.Common.Base_Priority = Self_ID.New_Base_Priority then
- STPO.Unlock (Self_ID);
- STPO.Yield;
- STPO.Write_Lock (Self_ID);
+ if Single_Lock then
+ STPO.Unlock_RTS;
+ STPO.Yield;
+ STPO.Lock_RTS;
+ else
+ STPO.Unlock (Self_ID);
+ STPO.Yield;
+ STPO.Write_Lock (Self_ID);
+ end if;
else
if Self_ID.Common.Base_Priority < Self_ID.New_Base_Priority then
-
-- Raising priority
Self_ID.Common.Base_Priority := Self_ID.New_Base_Priority;
@@ -331,9 +363,16 @@ package body System.Tasking.Entry_Calls is
Self_ID.Common.Base_Priority := Self_ID.New_Base_Priority;
STPO.Set_Priority (Self_ID, Self_ID.Common.Base_Priority);
- STPO.Unlock (Self_ID);
- STPO.Yield;
- STPO.Write_Lock (Self_ID);
+
+ if Single_Lock then
+ STPO.Unlock_RTS;
+ STPO.Yield;
+ STPO.Lock_RTS;
+ else
+ STPO.Unlock (Self_ID);
+ STPO.Yield;
+ STPO.Write_Lock (Self_ID);
+ end if;
end if;
end if;
@@ -354,36 +393,25 @@ package body System.Tasking.Entry_Calls is
-- Reset_Priority --
--------------------
- -- Reset the priority of a task completing an accept statement to
- -- the value it had before the call.
-
procedure Reset_Priority
- (Acceptor_Prev_Priority : Rendezvous_Priority;
- Acceptor : Task_ID) is
+ (Acceptor : Task_ID;
+ Acceptor_Prev_Priority : Rendezvous_Priority) is
begin
+ pragma Assert (Acceptor = STPO.Self);
+
+ -- Since we limit this kind of "active" priority change to be done
+ -- by the task for itself, we don't need to lock Acceptor.
+
if Acceptor_Prev_Priority /= Priority_Not_Boosted then
STPO.Set_Priority (Acceptor, Acceptor_Prev_Priority,
Loss_Of_Inheritance => True);
end if;
end Reset_Priority;
- -- ???
- -- Check why we don't need any kind of lock to do this.
- -- Do we limit this kind of "active" priority change to be done
- -- by the task for itself only?
-
------------------------------
-- Try_To_Cancel_Entry_Call --
------------------------------
- -- This is used to implement the Cancel_Task_Entry_Call and
- -- Cancel_Protected_Entry_Call.
- -- Try to cancel async. entry call.
- -- Effect includes Abort_To_Level and Wait_For_Completion.
- -- Cancelled = True iff the cancelation was successful, i.e.,
- -- the call was not Done before this call.
- -- On return, the call is off-queue and the ATC level is reduced by one.
-
procedure Try_To_Cancel_Entry_Call (Succeeded : out Boolean) is
Entry_Call : Entry_Call_Link;
Self_ID : constant Task_ID := STPO.Self;
@@ -394,13 +422,16 @@ package body System.Tasking.Entry_Calls is
Entry_Call := Self_ID.Entry_Calls (Self_ID.ATC_Nesting_Level)'Access;
-- Experimentation has shown that abort is sometimes (but not
- -- always) already deferred when Cancel_X_Entry_Call is called.
+ -- always) already deferred when Cancel_xxx_Entry_Call is called.
-- That may indicate an error. Find out what is going on. ???
pragma Assert (Entry_Call.Mode = Asynchronous_Call);
- pragma Assert (Self_ID = Self);
-
Initialization.Defer_Abort_Nestable (Self_ID);
+
+ if Single_Lock then
+ STPO.Lock_RTS;
+ end if;
+
STPO.Write_Lock (Self_ID);
Entry_Call.Cancellation_Attempted := True;
@@ -408,14 +439,19 @@ package body System.Tasking.Entry_Calls is
Self_ID.Pending_ATC_Level := Entry_Call.Level - 1;
end if;
- Entry_Calls.Wait_For_Completion (Self_ID, Entry_Call);
+ Entry_Calls.Wait_For_Completion (Entry_Call);
STPO.Unlock (Self_ID);
+
+ if Single_Lock then
+ STPO.Unlock_RTS;
+ end if;
+
Succeeded := Entry_Call.State = Cancelled;
if Succeeded then
Initialization.Undefer_Abort_Nestable (Self_ID);
else
- -- ????
+ -- ???
Initialization.Undefer_Abort_Nestable (Self_ID);
@@ -456,13 +492,26 @@ package body System.Tasking.Entry_Calls is
if Called_PO.Pending_Action then
Called_PO.Pending_Action := False;
Caller := STPO.Self;
+
+ if Single_Lock then
+ STPO.Lock_RTS;
+ end if;
+
STPO.Write_Lock (Caller);
Caller.New_Base_Priority := Called_PO.Old_Base_Priority;
Initialization.Change_Base_Priority (Caller);
STPO.Unlock (Caller);
+
+ if Single_Lock then
+ STPO.Unlock_RTS;
+ end if;
end if;
Unlock_Entries (Called_PO);
+
+ if Single_Lock then
+ STPO.Lock_RTS;
+ end if;
end if;
end Unlock_And_Update_Server;
@@ -483,106 +532,101 @@ package body System.Tasking.Entry_Calls is
if Called_PO.Pending_Action then
Called_PO.Pending_Action := False;
Caller := STPO.Self;
+
+ if Single_Lock then
+ STPO.Lock_RTS;
+ end if;
+
STPO.Write_Lock (Caller);
Caller.New_Base_Priority := Called_PO.Old_Base_Priority;
Initialization.Change_Base_Priority (Caller);
STPO.Unlock (Caller);
+
+ if Single_Lock then
+ STPO.Unlock_RTS;
+ end if;
end if;
Unlock_Entries (Called_PO);
+
+ if Single_Lock then
+ STPO.Lock_RTS;
+ end if;
end if;
end Unlock_Server;
-------------------------
- -- Wait_For_Completion--
+ -- Wait_For_Completion --
-------------------------
- -- Call this only when holding Self_ID locked
-
- -- If this is a conditional call, it should be cancelled when it
- -- becomes abortable. This is checked in the loop below.
+ procedure Wait_For_Completion (Entry_Call : Entry_Call_Link) is
+ Self_Id : constant Task_ID := Entry_Call.Self;
+ begin
+ -- If this is a conditional call, it should be cancelled when it
+ -- becomes abortable. This is checked in the loop below.
- -- We do the same thing for Asynchronous_Call. Executing the following
- -- loop will clear the Pending_Action field if there is no
- -- Pending_Action. We want the call made from Cancel_Task_Entry_Call
- -- to check the abortion level so that we make sure that the Cancelled
- -- field reflect the status of an Asynchronous_Call properly.
- -- This problem came up when the triggered statement and the abortable
- -- part depend on entries of the same task. When a cancellation is
- -- delivered, Undefer_Abort in the call made from abortable part
- -- sets the Pending_Action bit to false. However, the call is actually
- -- made to cancel the Asynchronous Call so that we need to check its
- -- status here again. Otherwise we may end up waiting for a cancelled
- -- call forever.
+ if Parameters.Runtime_Traces then
+ Send_Trace_Info (W_Completion);
+ end if;
- -- ????? .........
- -- Recheck the logic of the above old comment. It may be stale.
-
- procedure Wait_For_Completion
- (Self_ID : Task_ID;
- Entry_Call : Entry_Call_Link)
- is
- begin
- pragma Assert (Self_ID = Entry_Call.Self);
- Self_ID.Common.State := Entry_Caller_Sleep;
+ Self_Id.Common.State := Entry_Caller_Sleep;
loop
- Check_Pending_Actions_For_Entry_Call (Self_ID, Entry_Call);
+ Check_Pending_Actions_For_Entry_Call (Self_Id, Entry_Call);
exit when Entry_Call.State >= Done;
- STPO.Sleep (Self_ID, Entry_Caller_Sleep);
+ STPO.Sleep (Self_Id, Entry_Caller_Sleep);
end loop;
- Self_ID.Common.State := Runnable;
- Utilities.Exit_One_ATC_Level (Self_ID);
+ Self_Id.Common.State := Runnable;
+ Utilities.Exit_One_ATC_Level (Self_Id);
+
+ if Parameters.Runtime_Traces then
+ Send_Trace_Info (M_Call_Complete);
+ end if;
end Wait_For_Completion;
--------------------------------------
-- Wait_For_Completion_With_Timeout --
--------------------------------------
- -- This routine will lock Self_ID.
-
- -- This procedure waits for the entry call to
- -- be served, with a timeout. It tries to cancel the
- -- call if the timeout expires before the call is served.
-
- -- If we wake up from the timed sleep operation here,
- -- it may be for several possible reasons:
-
- -- 1) The entry call is done being served.
- -- 2) There is an abort or priority change to be served.
- -- 3) The timeout has expired (Timedout = True)
- -- 4) There has been a spurious wakeup.
-
- -- Once the timeout has expired we may need to continue to wait if
- -- the call is already being serviced. In that case, we want to go
- -- back to sleep, but without any timeout. The variable Timedout is
- -- used to control this. If the Timedout flag is set, we do not need
- -- to STPO.Sleep with a timeout. We just sleep until we get a wakeup for
- -- some status change.
-
- -- The original call may have become abortable after waking up.
- -- We want to check Check_Pending_Actions_For_Entry_Call again
- -- in any case.
-
procedure Wait_For_Completion_With_Timeout
- (Self_ID : Task_ID;
- Entry_Call : Entry_Call_Link;
+ (Entry_Call : Entry_Call_Link;
Wakeup_Time : Duration;
- Mode : Delay_Modes)
+ Mode : Delay_Modes;
+ Yielded : out Boolean)
is
+ Self_Id : constant Task_ID := Entry_Call.Self;
Timedout : Boolean := False;
- Yielded : Boolean := False;
use type Ada.Exceptions.Exception_Id;
begin
- Initialization.Defer_Abort_Nestable (Self_ID);
- STPO.Write_Lock (Self_ID);
+ -- This procedure waits for the entry call to be served, with a timeout.
+ -- It tries to cancel the call if the timeout expires before the call is
+ -- served.
+
+ -- If we wake up from the timed sleep operation here, it may be for
+ -- several possible reasons:
+
+ -- 1) The entry call is done being served.
+ -- 2) There is an abort or priority change to be served.
+ -- 3) The timeout has expired (Timedout = True)
+ -- 4) There has been a spurious wakeup.
+
+ -- Once the timeout has expired we may need to continue to wait if the
+ -- call is already being serviced. In that case, we want to go back to
+ -- sleep, but without any timeout. The variable Timedout is used to
+ -- control this. If the Timedout flag is set, we do not need to
+ -- STPO.Sleep with a timeout. We just sleep until we get a wakeup for
+ -- some status change.
+
+ -- The original call may have become abortable after waking up. We want
+ -- to check Check_Pending_Actions_For_Entry_Call again in any case.
- pragma Assert (Entry_Call.Self = Self_ID);
pragma Assert (Entry_Call.Mode = Timed_Call);
- Self_ID.Common.State := Entry_Caller_Sleep;
+
+ Yielded := False;
+ Self_Id.Common.State := Entry_Caller_Sleep;
-- Looping is necessary in case the task wakes up early from the
-- timed sleep, due to a "spurious wakeup". Spurious wakeups are
@@ -591,22 +635,29 @@ package body System.Tasking.Entry_Calls is
-- when the condition is signaled. See the same loop in the
-- ordinary Wait_For_Completion, above.
+ if Parameters.Runtime_Traces then
+ Send_Trace_Info (WT_Completion, Wakeup_Time);
+ end if;
+
loop
- Check_Pending_Actions_For_Entry_Call (Self_ID, Entry_Call);
+ Check_Pending_Actions_For_Entry_Call (Self_Id, Entry_Call);
exit when Entry_Call.State >= Done;
- STPO.Timed_Sleep (Self_ID, Wakeup_Time, Mode,
+ STPO.Timed_Sleep (Self_Id, Wakeup_Time, Mode,
Entry_Caller_Sleep, Timedout, Yielded);
if Timedout then
+ if Parameters.Runtime_Traces then
+ Send_Trace_Info (E_Timeout);
+ end if;
-- Try to cancel the call (see Try_To_Cancel_Entry_Call for
-- corresponding code in the ATC case).
Entry_Call.Cancellation_Attempted := True;
- if Self_ID.Pending_ATC_Level >= Entry_Call.Level then
- Self_ID.Pending_ATC_Level := Entry_Call.Level - 1;
+ if Self_Id.Pending_ATC_Level >= Entry_Call.Level then
+ Self_Id.Pending_ATC_Level := Entry_Call.Level - 1;
end if;
-- The following loop is the same as the loop and exit code
@@ -615,39 +666,13 @@ package body System.Tasking.Entry_Calls is
-- has actually completed or been cancelled successfully.
loop
- Check_Pending_Actions_For_Entry_Call (Self_ID, Entry_Call);
+ Check_Pending_Actions_For_Entry_Call (Self_Id, Entry_Call);
exit when Entry_Call.State >= Done;
- STPO.Sleep (Self_ID, Entry_Caller_Sleep);
+ STPO.Sleep (Self_Id, Entry_Caller_Sleep);
end loop;
- Self_ID.Common.State := Runnable;
- Utilities.Exit_One_ATC_Level (Self_ID);
-
- STPO.Unlock (Self_ID);
-
- if Entry_Call.State = Cancelled then
- Initialization.Undefer_Abort_Nestable (Self_ID);
- else
- -- ????
-
- Initialization.Undefer_Abort_Nestable (Self_ID);
-
- -- Ideally, abort should no longer be deferred at this
- -- point, so we should be able to call Check_Exception.
- -- The loop below should be considered temporary,
- -- to work around the possiblility that abort may be
- -- deferred more than one level deep.
-
- if Entry_Call.Exception_To_Raise /=
- Ada.Exceptions.Null_Id then
-
- while Self_ID.Deferral_Level > 0 loop
- Initialization.Undefer_Abort_Nestable (Self_ID);
- end loop;
-
- Entry_Calls.Check_Exception (Self_ID, Entry_Call);
- end if;
- end if;
+ Self_Id.Common.State := Runnable;
+ Utilities.Exit_One_ATC_Level (Self_Id);
return;
end if;
@@ -656,32 +681,29 @@ package body System.Tasking.Entry_Calls is
-- This last part is the same as ordinary Wait_For_Completion,
-- and is only executed if the call completed without timing out.
- Self_ID.Common.State := Runnable;
- Utilities.Exit_One_ATC_Level (Self_ID);
- STPO.Unlock (Self_ID);
-
- Initialization.Undefer_Abort_Nestable (Self_ID);
-
- if not Yielded then
- STPO.Yield;
+ if Parameters.Runtime_Traces then
+ Send_Trace_Info (M_Call_Complete);
end if;
+
+ Self_Id.Common.State := Runnable;
+ Utilities.Exit_One_ATC_Level (Self_Id);
end Wait_For_Completion_With_Timeout;
--------------------------
-- Wait_Until_Abortable --
--------------------------
- -- Wait to start the abortable part of an async. select statement
- -- until the trigger entry call becomes abortable.
-
procedure Wait_Until_Abortable
- (Self_ID : Task_ID;
- Call : Entry_Call_Link)
- is
+ (Self_ID : Task_ID;
+ Call : Entry_Call_Link) is
begin
pragma Assert (Self_ID.ATC_Nesting_Level > 0);
pragma Assert (Call.Mode = Asynchronous_Call);
+ if Parameters.Runtime_Traces then
+ Send_Trace_Info (W_Completion);
+ end if;
+
STPO.Write_Lock (Self_ID);
Self_ID.Common.State := Entry_Caller_Sleep;
@@ -693,21 +715,10 @@ package body System.Tasking.Entry_Calls is
Self_ID.Common.State := Runnable;
STPO.Unlock (Self_ID);
- end Wait_Until_Abortable;
-
- -- It might seem that we should be holding the server's lock when
- -- we test Call.State above.
- -- In an earlier version, the code above temporarily unlocked the
- -- caller and locked the server just for checking Call.State.
- -- The unlocking of the caller risked missing a wakeup
- -- (an error) and locking the server had no apparent value.
- -- We should not need the server's lock, since once Call.State
- -- is set to Was_Abortable or beyond, it never goes back below
- -- Was_Abortable until this task starts another entry call.
-
- -- ????
- -- It seems that other calls to Lock_Server may also risk missing
- -- wakeups. We need to check that they do not have this problem.
+ if Parameters.Runtime_Traces then
+ Send_Trace_Info (M_Call_Complete);
+ end if;
+ end Wait_Until_Abortable;
end System.Tasking.Entry_Calls;