Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / gcc / ada / s-tposen.adb
blobe5bf8fb26c9c6cef8f58005b62adcdf2c4d80803
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
4 -- --
5 -- S Y S T E M . T A S K I N G . P R O T E C T E D _ O B J E C T S . --
6 -- S I N G L E _ E N T R Y --
7 -- --
8 -- B o d y --
9 -- --
10 -- Copyright (C) 1998-2005, Free Software Foundation, Inc. --
11 -- --
12 -- GNARL is free software; you can redistribute it and/or modify it under --
13 -- terms of the GNU General Public License as published by the Free Soft- --
14 -- ware Foundation; either version 2, or (at your option) any later ver- --
15 -- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
18 -- for more details. You should have received a copy of the GNU General --
19 -- Public License distributed with GNARL; see file COPYING. If not, write --
20 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
21 -- Boston, MA 02110-1301, USA. --
22 -- --
23 -- As a special exception, if other files instantiate generics from this --
24 -- unit, or you link this unit with other files to produce an executable, --
25 -- this unit does not by itself cause the resulting executable to be --
26 -- covered by the GNU General Public License. This exception does not --
27 -- however invalidate any other reasons why the executable file might be --
28 -- covered by the GNU Public License. --
29 -- --
30 -- GNARL was developed by the GNARL team at Florida State University. --
31 -- Extensive contributions were provided by Ada Core Technologies, Inc. --
32 -- --
33 ------------------------------------------------------------------------------
35 pragma Style_Checks (All_Checks);
36 -- Turn off subprogram ordering check, since restricted GNARLI
37 -- subprograms are gathered together at end.
39 -- This package provides an optimized version of Protected_Objects.Operations
40 -- and Protected_Objects.Entries making the following assumptions:
42 -- PO has only one entry
43 -- There is only one caller at a time (No_Entry_Queue)
44 -- There is no dynamic priority support (No_Dynamic_Priorities)
45 -- No Abort Statements
46 -- (No_Abort_Statements, Max_Asynchronous_Select_Nesting => 0)
47 -- PO are at library level
48 -- No Requeue
49 -- None of the tasks will terminate (no need for finalization)
51 -- This interface is intended to be used in the ravenscar and restricted
52 -- profiles, the compiler is responsible for ensuring that the conditions
53 -- mentioned above are respected, except for the No_Entry_Queue restriction
54 -- that is checked dynamically in this package, since the check cannot be
55 -- performed at compile time, and is relatively cheap (see PO_Do_Or_Queue,
56 -- Service_Entry).
58 pragma Polling (Off);
59 -- Turn off polling, we do not want polling to take place during tasking
60 -- operations. It can cause infinite loops and other problems.
62 pragma Suppress (All_Checks);
64 with System.Task_Primitives.Operations;
65 -- used for Self
66 -- Finalize_Lock
67 -- Write_Lock
68 -- Unlock
70 with Ada.Exceptions;
71 -- used for Exception_Id
72 -- Raise_Exception
74 with System.Parameters;
75 -- used for Single_Lock
77 package body System.Tasking.Protected_Objects.Single_Entry is
79 package STPO renames System.Task_Primitives.Operations;
81 use Parameters;
83 -----------------------
84 -- Local Subprograms --
85 -----------------------
87 procedure Send_Program_Error
88 (Self_Id : Task_Id;
89 Entry_Call : Entry_Call_Link);
90 pragma Inline (Send_Program_Error);
91 -- Raise Program_Error in the caller of the specified entry call
93 --------------------------
94 -- Entry Calls Handling --
95 --------------------------
97 procedure Wakeup_Entry_Caller
98 (Self_ID : Task_Id;
99 Entry_Call : Entry_Call_Link;
100 New_State : Entry_Call_State);
101 pragma Inline (Wakeup_Entry_Caller);
102 -- This is called at the end of service of an entry call,
103 -- to abort the caller if he is in an abortable part, and
104 -- to wake up the caller if he is on Entry_Caller_Sleep.
105 -- Call it holding the lock of Entry_Call.Self.
107 -- Timed_Call or Simple_Call:
108 -- The caller is waiting on Entry_Caller_Sleep, in
109 -- Wait_For_Completion, or Wait_For_Completion_With_Timeout.
111 procedure Wait_For_Completion (Entry_Call : Entry_Call_Link);
112 pragma Inline (Wait_For_Completion);
113 -- This procedure suspends the calling task until the specified entry call
114 -- has either been completed or cancelled. On exit, the call will not be
115 -- queued. This waits for calls on protected entries.
116 -- Call this only when holding Self_ID locked.
118 procedure Wait_For_Completion_With_Timeout
119 (Entry_Call : Entry_Call_Link;
120 Wakeup_Time : Duration;
121 Mode : Delay_Modes);
122 -- Same as Wait_For_Completion but it waits for a timeout with the value
123 -- specified in Wakeup_Time as well.
125 procedure Check_Exception
126 (Self_ID : Task_Id;
127 Entry_Call : Entry_Call_Link);
128 pragma Inline (Check_Exception);
129 -- Raise any pending exception from the Entry_Call.
130 -- This should be called at the end of every compiler interface procedure
131 -- that implements an entry call.
132 -- The caller should not be holding any locks, or there will be deadlock.
134 procedure PO_Do_Or_Queue
135 (Self_Id : Task_Id;
136 Object : Protection_Entry_Access;
137 Entry_Call : Entry_Call_Link);
138 -- This procedure executes or queues an entry call, depending
139 -- on the status of the corresponding barrier. It assumes that the
140 -- specified object is locked.
142 ---------------------
143 -- Check_Exception --
144 ---------------------
146 procedure Check_Exception
147 (Self_ID : Task_Id;
148 Entry_Call : Entry_Call_Link)
150 pragma Warnings (Off, Self_ID);
152 procedure Internal_Raise (X : Ada.Exceptions.Exception_Id);
153 pragma Import (C, Internal_Raise, "__gnat_raise_with_msg");
155 use type Ada.Exceptions.Exception_Id;
157 E : constant Ada.Exceptions.Exception_Id :=
158 Entry_Call.Exception_To_Raise;
160 begin
161 if E /= Ada.Exceptions.Null_Id then
162 Internal_Raise (E);
163 end if;
164 end Check_Exception;
166 ------------------------
167 -- Send_Program_Error --
168 ------------------------
170 procedure Send_Program_Error
171 (Self_Id : Task_Id;
172 Entry_Call : Entry_Call_Link)
174 Caller : constant Task_Id := Entry_Call.Self;
175 begin
176 Entry_Call.Exception_To_Raise := Program_Error'Identity;
178 if Single_Lock then
179 STPO.Lock_RTS;
180 end if;
182 STPO.Write_Lock (Caller);
183 Wakeup_Entry_Caller (Self_Id, Entry_Call, Done);
184 STPO.Unlock (Caller);
186 if Single_Lock then
187 STPO.Unlock_RTS;
188 end if;
189 end Send_Program_Error;
191 -------------------------
192 -- Wait_For_Completion --
193 -------------------------
195 procedure Wait_For_Completion (Entry_Call : Entry_Call_Link) is
196 Self_Id : constant Task_Id := Entry_Call.Self;
197 begin
198 Self_Id.Common.State := Entry_Caller_Sleep;
199 STPO.Sleep (Self_Id, Entry_Caller_Sleep);
200 Self_Id.Common.State := Runnable;
201 end Wait_For_Completion;
203 --------------------------------------
204 -- Wait_For_Completion_With_Timeout --
205 --------------------------------------
207 procedure Wait_For_Completion_With_Timeout
208 (Entry_Call : Entry_Call_Link;
209 Wakeup_Time : Duration;
210 Mode : Delay_Modes)
212 Self_Id : constant Task_Id := Entry_Call.Self;
213 Timedout : Boolean;
214 Yielded : Boolean;
216 use type Ada.Exceptions.Exception_Id;
218 begin
219 -- This procedure waits for the entry call to be served, with a timeout.
220 -- It tries to cancel the call if the timeout expires before the call is
221 -- served.
223 -- If we wake up from the timed sleep operation here, it may be for the
224 -- following possible reasons:
226 -- 1) The entry call is done being served.
227 -- 2) The timeout has expired (Timedout = True)
229 -- Once the timeout has expired we may need to continue to wait if the
230 -- call is already being serviced. In that case, we want to go back to
231 -- sleep, but without any timeout. The variable Timedout is used to
232 -- control this. If the Timedout flag is set, we do not need to Sleep
233 -- with a timeout. We just sleep until we get a wakeup for some status
234 -- change.
236 pragma Assert (Entry_Call.Mode = Timed_Call);
237 Self_Id.Common.State := Entry_Caller_Sleep;
239 STPO.Timed_Sleep
240 (Self_Id, Wakeup_Time, Mode, Entry_Caller_Sleep, Timedout, Yielded);
242 if Timedout then
243 Entry_Call.State := Cancelled;
244 else
245 Entry_Call.State := Done;
246 end if;
248 Self_Id.Common.State := Runnable;
249 end Wait_For_Completion_With_Timeout;
251 -------------------------
252 -- Wakeup_Entry_Caller --
253 -------------------------
255 -- This is called at the end of service of an entry call, to abort the
256 -- caller if he is in an abortable part, and to wake up the caller if it
257 -- is on Entry_Caller_Sleep. It assumes that the call is already off-queue.
259 -- (This enforces the rule that a task must be off-queue if its state is
260 -- Done or Cancelled.) Call it holding the lock of Entry_Call.Self.
262 -- Timed_Call or Simple_Call:
263 -- The caller is waiting on Entry_Caller_Sleep, in
264 -- Wait_For_Completion, or Wait_For_Completion_With_Timeout.
266 -- Conditional_Call:
267 -- The caller might be in Wait_For_Completion,
268 -- waiting for a rendezvous (possibly requeued without abort)
269 -- to complete.
271 procedure Wakeup_Entry_Caller
272 (Self_ID : Task_Id;
273 Entry_Call : Entry_Call_Link;
274 New_State : Entry_Call_State)
276 pragma Warnings (Off, Self_ID);
278 Caller : constant Task_Id := Entry_Call.Self;
280 begin
281 pragma Assert (New_State = Done or else New_State = Cancelled);
282 pragma Assert
283 (Caller.Common.State /= Terminated and then
284 Caller.Common.State /= Unactivated);
286 Entry_Call.State := New_State;
287 STPO.Wakeup (Caller, Entry_Caller_Sleep);
288 end Wakeup_Entry_Caller;
290 -----------------------
291 -- Restricted GNARLI --
292 -----------------------
294 --------------------------------
295 -- Complete_Single_Entry_Body --
296 --------------------------------
298 procedure Complete_Single_Entry_Body (Object : Protection_Entry_Access) is
299 pragma Warnings (Off, Object);
301 begin
302 -- Nothing needs to do (Object.Call_In_Progress.Exception_To_Raise
303 -- has already been set to Null_Id).
305 null;
306 end Complete_Single_Entry_Body;
308 --------------------------------------------
309 -- Exceptional_Complete_Single_Entry_Body --
310 --------------------------------------------
312 procedure Exceptional_Complete_Single_Entry_Body
313 (Object : Protection_Entry_Access;
314 Ex : Ada.Exceptions.Exception_Id) is
315 begin
316 Object.Call_In_Progress.Exception_To_Raise := Ex;
317 end Exceptional_Complete_Single_Entry_Body;
319 ---------------------------------
320 -- Initialize_Protection_Entry --
321 ---------------------------------
323 procedure Initialize_Protection_Entry
324 (Object : Protection_Entry_Access;
325 Ceiling_Priority : Integer;
326 Compiler_Info : System.Address;
327 Entry_Body : Entry_Body_Access)
329 Init_Priority : Integer := Ceiling_Priority;
330 begin
331 if Init_Priority = Unspecified_Priority then
332 Init_Priority := System.Priority'Last;
333 end if;
335 STPO.Initialize_Lock (Init_Priority, Object.L'Access);
336 Object.Ceiling := System.Any_Priority (Init_Priority);
337 Object.Owner := Null_Task;
338 Object.Compiler_Info := Compiler_Info;
339 Object.Call_In_Progress := null;
340 Object.Entry_Body := Entry_Body;
341 Object.Entry_Queue := null;
342 end Initialize_Protection_Entry;
344 ----------------
345 -- Lock_Entry --
346 ----------------
348 -- Compiler interface only.
349 -- Do not call this procedure from within the run-time system.
351 procedure Lock_Entry (Object : Protection_Entry_Access) is
352 Ceiling_Violation : Boolean;
354 begin
355 -- If pragma Detect_Blocking is active then, as described in the ARM
356 -- 9.5.1, par. 15, we must check whether this is an external call on a
357 -- protected subprogram with the same target object as that of the
358 -- protected action that is currently in progress (i.e., if the caller
359 -- is already the protected object's owner). If this is the case hence
360 -- Program_Error must be raised.
362 if Detect_Blocking and then Object.Owner = Self then
363 raise Program_Error;
364 end if;
366 STPO.Write_Lock (Object.L'Access, Ceiling_Violation);
368 if Ceiling_Violation then
369 raise Program_Error;
370 end if;
372 -- We are entering in a protected action, so that we increase the
373 -- protected object nesting level (if pragma Detect_Blocking is
374 -- active), and update the protected object's owner.
376 if Detect_Blocking then
377 declare
378 Self_Id : constant Task_Id := Self;
380 begin
381 -- Update the protected object's owner
383 Object.Owner := Self_Id;
385 -- Increase protected object nesting level
387 Self_Id.Common.Protected_Action_Nesting :=
388 Self_Id.Common.Protected_Action_Nesting + 1;
389 end;
390 end if;
391 end Lock_Entry;
393 --------------------------
394 -- Lock_Read_Only_Entry --
395 --------------------------
397 -- Compiler interface only
399 -- Do not call this procedure from within the runtime system
401 procedure Lock_Read_Only_Entry (Object : Protection_Entry_Access) is
402 Ceiling_Violation : Boolean;
404 begin
405 -- If pragma Detect_Blocking is active then, as described in the ARM
406 -- 9.5.1, par. 15, we must check whether this is an external call on a
407 -- protected subprogram with the same target object as that of the
408 -- protected action that is currently in progress (i.e., if the caller
409 -- is already the protected object's owner). If this is the case hence
410 -- Program_Error must be raised.
412 -- Note that in this case (getting read access), several tasks may
413 -- have read ownership of the protected object, so that this method of
414 -- storing the (single) protected object's owner does not work
415 -- reliably for read locks. However, this is the approach taken for two
416 -- major reasosn: first, this function is not currently being used (it
417 -- is provided for possible future use), and second, it largely
418 -- simplifies the implementation.
420 if Detect_Blocking and then Object.Owner = Self then
421 raise Program_Error;
422 end if;
424 STPO.Read_Lock (Object.L'Access, Ceiling_Violation);
426 if Ceiling_Violation then
427 raise Program_Error;
428 end if;
430 -- We are entering in a protected action, so that we increase the
431 -- protected object nesting level (if pragma Detect_Blocking is
432 -- active), and update the protected object's owner.
434 if Detect_Blocking then
435 declare
436 Self_Id : constant Task_Id := Self;
438 begin
439 -- Update the protected object's owner
441 Object.Owner := Self_Id;
443 -- Increase protected object nesting level
445 Self_Id.Common.Protected_Action_Nesting :=
446 Self_Id.Common.Protected_Action_Nesting + 1;
447 end;
448 end if;
449 end Lock_Read_Only_Entry;
451 --------------------
452 -- PO_Do_Or_Queue --
453 --------------------
455 procedure PO_Do_Or_Queue
456 (Self_Id : Task_Id;
457 Object : Protection_Entry_Access;
458 Entry_Call : Entry_Call_Link)
460 Barrier_Value : Boolean;
462 begin
463 -- When the Action procedure for an entry body returns, it must be
464 -- completed (having called [Exceptional_]Complete_Entry_Body).
466 Barrier_Value := Object.Entry_Body.Barrier (Object.Compiler_Info, 1);
468 if Barrier_Value then
469 if Object.Call_In_Progress /= null then
471 -- This violates the No_Entry_Queue restriction, send
472 -- Program_Error to the caller.
474 Send_Program_Error (Self_Id, Entry_Call);
475 return;
476 end if;
478 Object.Call_In_Progress := Entry_Call;
479 Object.Entry_Body.Action
480 (Object.Compiler_Info, Entry_Call.Uninterpreted_Data, 1);
481 Object.Call_In_Progress := null;
483 if Single_Lock then
484 STPO.Lock_RTS;
485 end if;
487 STPO.Write_Lock (Entry_Call.Self);
488 Wakeup_Entry_Caller (Self_Id, Entry_Call, Done);
489 STPO.Unlock (Entry_Call.Self);
491 if Single_Lock then
492 STPO.Unlock_RTS;
493 end if;
495 elsif Entry_Call.Mode /= Conditional_Call then
496 if Object.Entry_Queue /= null then
498 -- This violates the No_Entry_Queue restriction, send
499 -- Program_Error to the caller.
501 Send_Program_Error (Self_Id, Entry_Call);
502 return;
503 else
504 Object.Entry_Queue := Entry_Call;
505 end if;
507 else
508 -- Conditional_Call
510 if Single_Lock then
511 STPO.Lock_RTS;
512 end if;
514 STPO.Write_Lock (Entry_Call.Self);
515 Wakeup_Entry_Caller (Self_Id, Entry_Call, Cancelled);
516 STPO.Unlock (Entry_Call.Self);
518 if Single_Lock then
519 STPO.Unlock_RTS;
520 end if;
521 end if;
523 exception
524 when others =>
525 Send_Program_Error
526 (Self_Id, Entry_Call);
527 end PO_Do_Or_Queue;
529 ----------------------------
530 -- Protected_Single_Count --
531 ----------------------------
533 function Protected_Count_Entry (Object : Protection_Entry) return Natural is
534 begin
535 if Object.Entry_Queue /= null then
536 return 1;
537 else
538 return 0;
539 end if;
540 end Protected_Count_Entry;
542 ---------------------------------
543 -- Protected_Single_Entry_Call --
544 ---------------------------------
546 procedure Protected_Single_Entry_Call
547 (Object : Protection_Entry_Access;
548 Uninterpreted_Data : System.Address;
549 Mode : Call_Modes)
551 Self_Id : constant Task_Id := STPO.Self;
552 Entry_Call : Entry_Call_Record renames Self_Id.Entry_Calls (1);
553 Ceiling_Violation : Boolean;
555 begin
556 -- If pragma Detect_Blocking is active then Program_Error must be
557 -- raised if this potentially blocking operation is called from a
558 -- protected action.
560 if Detect_Blocking
561 and then Self_Id.Common.Protected_Action_Nesting > 0
562 then
563 Ada.Exceptions.Raise_Exception
564 (Program_Error'Identity, "potentially blocking operation");
565 end if;
567 STPO.Write_Lock (Object.L'Access, Ceiling_Violation);
569 if Ceiling_Violation then
570 raise Program_Error;
571 end if;
573 Entry_Call.Mode := Mode;
574 Entry_Call.State := Now_Abortable;
575 Entry_Call.Uninterpreted_Data := Uninterpreted_Data;
576 Entry_Call.Exception_To_Raise := Ada.Exceptions.Null_Id;
578 PO_Do_Or_Queue (Self_Id, Object, Entry_Call'Access);
579 Unlock_Entry (Object);
581 -- The call is either `Done' or not. It cannot be cancelled since there
582 -- is no ATC construct.
584 pragma Assert (Entry_Call.State /= Cancelled);
586 if Entry_Call.State /= Done then
587 if Single_Lock then
588 STPO.Lock_RTS;
589 end if;
591 STPO.Write_Lock (Self_Id);
592 Wait_For_Completion (Entry_Call'Access);
593 STPO.Unlock (Self_Id);
595 if Single_Lock then
596 STPO.Unlock_RTS;
597 end if;
598 end if;
600 Check_Exception (Self_Id, Entry_Call'Access);
601 end Protected_Single_Entry_Call;
603 -----------------------------------
604 -- Protected_Single_Entry_Caller --
605 -----------------------------------
607 function Protected_Single_Entry_Caller
608 (Object : Protection_Entry) return Task_Id is
609 begin
610 return Object.Call_In_Progress.Self;
611 end Protected_Single_Entry_Caller;
613 -------------------
614 -- Service_Entry --
615 -------------------
617 procedure Service_Entry (Object : Protection_Entry_Access) is
618 Self_Id : constant Task_Id := STPO.Self;
619 Entry_Call : constant Entry_Call_Link := Object.Entry_Queue;
620 Caller : Task_Id;
622 begin
623 if Entry_Call /= null
624 and then Object.Entry_Body.Barrier (Object.Compiler_Info, 1)
625 then
626 Object.Entry_Queue := null;
628 if Object.Call_In_Progress /= null then
630 -- Violation of No_Entry_Queue restriction, raise exception
632 Send_Program_Error (Self_Id, Entry_Call);
633 Unlock_Entry (Object);
634 return;
635 end if;
637 Object.Call_In_Progress := Entry_Call;
638 Object.Entry_Body.Action
639 (Object.Compiler_Info, Entry_Call.Uninterpreted_Data, 1);
640 Object.Call_In_Progress := null;
641 Caller := Entry_Call.Self;
642 Unlock_Entry (Object);
644 if Single_Lock then
645 STPO.Lock_RTS;
646 end if;
648 STPO.Write_Lock (Caller);
649 Wakeup_Entry_Caller (Self_Id, Entry_Call, Done);
650 STPO.Unlock (Caller);
652 if Single_Lock then
653 STPO.Unlock_RTS;
654 end if;
656 else
657 -- Just unlock the entry
659 Unlock_Entry (Object);
660 end if;
662 exception
663 when others =>
664 Send_Program_Error (Self_Id, Entry_Call);
665 Unlock_Entry (Object);
666 end Service_Entry;
668 ---------------------------------------
669 -- Timed_Protected_Single_Entry_Call --
670 ---------------------------------------
672 -- Compiler interface only. Do not call from within the RTS.
674 procedure Timed_Protected_Single_Entry_Call
675 (Object : Protection_Entry_Access;
676 Uninterpreted_Data : System.Address;
677 Timeout : Duration;
678 Mode : Delay_Modes;
679 Entry_Call_Successful : out Boolean)
681 Self_Id : constant Task_Id := STPO.Self;
682 Entry_Call : Entry_Call_Record renames Self_Id.Entry_Calls (1);
683 Ceiling_Violation : Boolean;
685 begin
686 -- If pragma Detect_Blocking is active then Program_Error must be
687 -- raised if this potentially blocking operation is called from a
688 -- protected action.
690 if Detect_Blocking
691 and then Self_Id.Common.Protected_Action_Nesting > 0
692 then
693 Ada.Exceptions.Raise_Exception
694 (Program_Error'Identity, "potentially blocking operation");
695 end if;
697 STPO.Write_Lock (Object.L'Access, Ceiling_Violation);
699 if Ceiling_Violation then
700 raise Program_Error;
701 end if;
703 Entry_Call.Mode := Timed_Call;
704 Entry_Call.State := Now_Abortable;
705 Entry_Call.Uninterpreted_Data := Uninterpreted_Data;
706 Entry_Call.Exception_To_Raise := Ada.Exceptions.Null_Id;
708 PO_Do_Or_Queue (Self_Id, Object, Entry_Call'Access);
709 Unlock_Entry (Object);
711 -- Try to avoid waiting for completed calls.
712 -- The call is either `Done' or not. It cannot be cancelled since there
713 -- is no ATC construct and the timed wait has not started yet.
715 pragma Assert (Entry_Call.State /= Cancelled);
717 if Entry_Call.State = Done then
718 Check_Exception (Self_Id, Entry_Call'Access);
719 Entry_Call_Successful := True;
720 return;
721 end if;
723 if Single_Lock then
724 STPO.Lock_RTS;
725 else
726 STPO.Write_Lock (Self_Id);
727 end if;
729 Wait_For_Completion_With_Timeout (Entry_Call'Access, Timeout, Mode);
731 if Single_Lock then
732 STPO.Unlock_RTS;
733 else
734 STPO.Unlock (Self_Id);
735 end if;
737 pragma Assert (Entry_Call.State >= Done);
739 Check_Exception (Self_Id, Entry_Call'Access);
740 Entry_Call_Successful := Entry_Call.State = Done;
741 end Timed_Protected_Single_Entry_Call;
743 ------------------
744 -- Unlock_Entry --
745 ------------------
747 procedure Unlock_Entry (Object : Protection_Entry_Access) is
748 begin
749 -- We are exiting from a protected action, so that we decrease the
750 -- protected object nesting level (if pragma Detect_Blocking is
751 -- active), and remove ownership of the protected object.
753 if Detect_Blocking then
754 declare
755 Self_Id : constant Task_Id := Self;
757 begin
758 -- Calls to this procedure can only take place when being within
759 -- a protected action and when the caller is the protected
760 -- object's owner.
762 pragma Assert (Self_Id.Common.Protected_Action_Nesting > 0
763 and then Object.Owner = Self_Id);
765 -- Remove ownership of the protected object
767 Object.Owner := Null_Task;
769 Self_Id.Common.Protected_Action_Nesting :=
770 Self_Id.Common.Protected_Action_Nesting - 1;
771 end;
772 end if;
774 STPO.Unlock (Object.L'Access);
775 end Unlock_Entry;
777 end System.Tasking.Protected_Objects.Single_Entry;