comp.lang.ada
 help / color / mirror / Atom feed
* Same two tasks in two rendezvous?
@ 2001-07-30 16:55 Adam Beneschan
  2001-07-31 10:02 ` Lutz Donnerhacke
  0 siblings, 1 reply; 2+ messages in thread
From: Adam Beneschan @ 2001-07-30 16:55 UTC (permalink / raw)


Is it possible for two tasks, T1 and T2, to be in two rendezvous with
each other simultaneously?

Suppose task T1, with entries E1 and E2, has the following ACCEPT:

    accept E1 do
	...
	accept E2 do
	    ...
	    ...
        end E2;
        ...
    end E1;

and T2 has the following statement:

    select
	T1.E1;   -- entry call (A)
    then abort
        ...
        T1.E2;   -- entry call (B)
        ...
    end select;

T2 hits the select statement first.  It finds that T1.E1 is not open,
so it starts executing the abortable part, which then waits at Entry
Call B.  Then T1 comes along and accepts E1.  This selects Entry Call
A.  However, as I understand the RM, this does not cause the abortable
part of the SELECT statement to be aborted, since that aborting
doesn't happen until the entry call is completed (i.e. until task T1
hits the "end E1;").  So the rendezvous proceeds, and eventually
reaches the "accept E2" statement, which will then select Entry Call
B, which T2 is waiting on.  So at that point, while the inner
rendezvous is executing, T1 and T2 have two rendezvous going on
simultaneously.

Is this what should actually happen?  Is there anything in the
language that prohibits this from happening?

				-- thanks, Adam



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Same two tasks in two rendezvous?
  2001-07-30 16:55 Same two tasks in two rendezvous? Adam Beneschan
@ 2001-07-31 10:02 ` Lutz Donnerhacke
  0 siblings, 0 replies; 2+ messages in thread
From: Lutz Donnerhacke @ 2001-07-31 10:02 UTC (permalink / raw)


* Adam Beneschan wrote:
>Is it possible for two tasks, T1 and T2, to be in two rendezvous with
>each other simultaneously?

No.

>Is this what should actually happen?

Deadlock.

>Is there anything in the language that prohibits this from happening?

No, because it's possible to open the deadlock by a third task.
\f
with Ada.Text_IO;
use Ada.Text_IO;

procedure t is
   task type rev is
      entry e1;
      entry e2;
   end;
   
   task body rev is
   begin
      Put_Line ("Starting task");
      accept e1 do
         Put_Line ("Entry E1");
         accept e2 do
            Put_Line ("Entry E2");
         end e2;
      end e1;
      Put_Line ("Stopping task");
   end;
   
   e : rev;
   
   task type helper;
   task body helper is
   begin
      Put_Line ("Starting helper task");
      e.e2;
      Put_Line ("Stopping helper task");
   end helper;
   
   h : helper;                      --  comment this out to see what happens
      
begin
   Put_Line ("First Rendevous");
   e.e1;
   Put_Line ("Second Rendevous");   --  comment this out to see what happens
   e.e2;                            --  comment this out to see what happens
   Put_Line ("Stopping Main Task");
end t;



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-07-31 10:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-30 16:55 Same two tasks in two rendezvous? Adam Beneschan
2001-07-31 10:02 ` Lutz Donnerhacke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox