comp.lang.ada
 help / color / mirror / Atom feed
From: "J-P. Rosen" <rosen@adalog.fr>
Subject: Re: Timeouts in Ada
Date: Thu, 17 Jul 2014 09:38:40 +0200
Date: 2014-07-17T09:38:40+02:00	[thread overview]
Message-ID: <lq7uhv$vao$1@dont-email.me> (raw)
In-Reply-To: <50bdb713-7ce1-411b-810b-9bdee1d26b7a@googlegroups.com>

Le 17/07/2014 07:18, NiGHTS a écrit :
> I am looking at Ex. 10. 
> 
>   task Password_Server is
>      entry Check (User, Pass : in String; Valid : out Boolean);
>      entry Set (User, Pass : in  String);
>   end Password_Server;
>   ...
>   User_Name, Password : String (1 .. 8);
>   ...
>   Put ("Please give your new password:");
>   Get_Line (Password);
>   select
>      Password_Server.Set (User_Name, Password);
>      Put_Line ("Done");
>   or
>      delay 10.0;
>      Put_Line ("The system is busy now, please try again later.");
>   end select;
> 
> Now as an Ada beginner with a strong background in C/Asm I interpret
> this example in the following way...
> 
> 1. "select" creates a thread which runs the body of "select" or the
> body of "or". Or maybe it creates two threads for each and blocks its
> own thread until one finishes.
> 
[Rest snipped, since based on wrong assertion]

Not at all! In Ada, one task=one thread, there are no hidden threads.

This kind of select is called a timed entry call. It tries to rendezvous
with Password_Server; if the server accepts the rendezvous before 10.0
seconds, the statements after the entry call are executed and the "or"
part is ignored. If the server doesn't accept the rendezvous within 10.0
seconds, the rendezvous request is cancelled and the statements in the
"or" part are executed.

-- 
J-P. Rosen
Adalog
2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00
http://www.adalog.fr


  parent reply	other threads:[~2014-07-17  7:38 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-17  5:18 Timeouts in Ada NiGHTS
2014-07-17  7:08 ` Simon Wright
2014-07-17  8:35   ` NiGHTS
2014-07-21 23:34   ` Randy Brukardt
2014-07-22  1:11     ` Shark8
2014-07-22  7:39       ` J-P. Rosen
2014-07-22  8:31         ` Simon Wright
2014-07-22 21:52       ` Randy Brukardt
2014-07-17  7:38 ` J-P. Rosen [this message]
2014-07-17  8:40   ` NiGHTS
2014-07-17 10:00     ` J-P. Rosen
2014-07-17 19:27   ` Jeffrey Carter
2014-07-17 19:51     ` J-P. Rosen
2014-07-17 20:52       ` Jeffrey Carter
2014-07-17 20:29     ` Adam Beneschan
2014-07-17 20:52       ` J-P. Rosen
2014-07-21 23:44         ` Randy Brukardt
2014-07-17 20:43     ` Jeffrey Carter
2014-07-21 23:37   ` Randy Brukardt
2014-07-17  7:42 ` Dmitry A. Kazakov
2014-07-17  8:59   ` NiGHTS
2014-07-17  9:48     ` Dmitry A. Kazakov
2014-07-17 17:10       ` NiGHTS
2014-07-17 20:45         ` Dmitry A. Kazakov
2014-07-17 16:12 ` Adam Beneschan
2014-07-17 16:46   ` NiGHTS
2014-07-17 17:11     ` Simon Wright
2014-07-17 17:58       ` NiGHTS
2014-07-17 19:02         ` Jeffrey Carter
2014-07-17 18:58       ` Jeffrey Carter
2014-07-17 18:12     ` Adam Beneschan
2014-07-17 19:27       ` Jeffrey Carter
2014-07-17 18:56     ` Jeffrey Carter
2014-07-23 22:37     ` Robert A Duff
2014-07-24  9:23       ` AdaMagica
2014-07-24 15:37         ` Robert A Duff
2014-07-25  5:16           ` Randy Brukardt
2014-07-25  9:11           ` AdaMagica
2014-07-25 16:15             ` Brad Moore
2014-07-25 16:34             ` Dmitry A. Kazakov
2014-07-17 19:27 ` Jeffrey Carter
replies disabled

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