From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "J-P. Rosen" Newsgroups: comp.lang.ada Subject: Re: Timeouts in Ada Date: Thu, 17 Jul 2014 09:38:40 +0200 Organization: A noiseless patient Spider Message-ID: References: <50bdb713-7ce1-411b-810b-9bdee1d26b7a@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Injection-Date: Thu, 17 Jul 2014 07:38:39 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="23dab0694e4174fdc880833ec67fa650"; logging-data="32088"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18dMmr8SVC/PalXoOYPEUFM" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: <50bdb713-7ce1-411b-810b-9bdee1d26b7a@googlegroups.com> Cancel-Lock: sha1:YyiWrmRETBoZRejcQegnoqKDBRw= X-Enigmail-Version: 1.6 Xref: news.eternal-september.org comp.lang.ada:20989 Date: 2014-07-17T09:38:40+02:00 List-Id: 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