comp.lang.ada
 help / color / mirror / Atom feed
From: "Björn Lundin" <b.f.lundin@gmail.com>
Subject: Re: assigning priority to task
Date: Wed, 24 Sep 2014 16:55:02 +0200
Date: 2014-09-24T16:55:02+02:00	[thread overview]
Message-ID: <lvulus$16j$1@dont-email.me> (raw)
In-Reply-To: <47d6f1fc-1cf1-4542-a6e2-233b758aefec@googlegroups.com>

On 2014-09-24 15:17, Stribor40 wrote:
> how is calling another task at the entry point different from main thread calling another function or procedure and passing parameters to those? sorry if question is dumb but I am just failing to see the difference....
> Is it because of tasks synchronization mechanism that calling tasks waits if another tasks is using things defined after accept statement?
> 

(Not compiled code)

task T is
  entry T1;
  entry T2;
end T


task body T is
begin

  loop
    select
      accept T1 do
        Put_Line ("rendez-vouz start");
        Put_Line ("Do_stuff that holds caller");
        Put_Line ("rendez-vouz stop");
      done
    or
      accept T1 do
        Put_Line ("rendez-vouz start");
        Put_Line ("rendez-vouz stop");
      done
      -- parallel execution from here
      Put_Line ("Do_stuff that DOES NOT hold caller");
      -- to here
    or
      terminate;
    end select;
  end loop;
end T



if main calls T.T1, the difference
compared with calling a procedure
T1 in package T is that the work is
performed in another thread and main waits until complete.
You do not get parallel execution.
You serialize work, but could use a protected object instead

however,

if main calls T.T2, the difference
compared with calling a procedure
T2 in package T is that the work is
performed in another thread and main is released right away,
so the T2 work is carried out while main continues.
You get _parallel_ execution.



--
Björn


      reply	other threads:[~2014-09-24 14:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-24  1:50 assigning priority to task Stribor40
2014-09-24  3:31 ` Jeffrey Carter
2014-09-24  3:36   ` Stribor40
2014-09-24  5:28     ` Jeffrey Carter
2014-09-24 10:09       ` Stribor40
2014-09-24 19:36         ` Simon Wright
2014-09-24  3:39   ` Stribor40
2014-09-24  5:32     ` Jeffrey Carter
2014-09-24 16:01     ` Anh Vo
2014-09-24 11:17 ` AdaMagica
2014-09-24 13:17   ` Stribor40
2014-09-24 14:55     ` Björn Lundin [this message]
replies disabled

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