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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c3c4ae45442f569e X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!z14g2000cwz.googlegroups.com!not-for-mail From: "fabio de francesco" Newsgroups: comp.lang.ada Subject: Re: tasks and protected types Date: 29 Apr 2005 03:47:07 -0700 Organization: http://groups.google.com Message-ID: <1114771627.401153.78280@z14g2000cwz.googlegroups.com> References: <1114747457.868019.93210@f14g2000cwb.googlegroups.com> NNTP-Posting-Host: 80.181.52.213 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1114771632 7169 127.0.0.1 (29 Apr 2005 10:47:12 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 29 Apr 2005 10:47:12 +0000 (UTC) In-Reply-To: User-Agent: G2/0.2 Complaints-To: groups-abuse@google.com Injection-Info: z14g2000cwz.googlegroups.com; posting-host=80.181.52.213; posting-account=Lp02jQ0AAABMd3TAghNf0TM2YBZqD_JE Xref: g2news1.google.com comp.lang.ada:10811 Date: 2005-04-29T03:47:07-07:00 List-Id: Jacob Sparre Andersen wrote: > Fabio de Francesco wrote: > > [...] > > > G : Generator; > > Global objects are a _very_ bad idea when doing tasking. Move it into > your task type. Done. > > > task body Door is > > Msg : String := ""; > > Here you make the lenght of the string Msg 0. Auch. > > Val : Positive; > > Times : Positive; > > begin > > accept Start( Str : in String; Tm : in Positive ) do > > Msg := Str; > > And here you try to assign a string of length 6 to a string of length > 0. It will fail with a Constraint_Error, but with tasking you don't > always see the exceptions. > > And then I also prefer to keep the printing to a single protected > object. Why? Could lines come out intermixed? Does it mean that it is always needed to protect every call to library functions and procedures? Do they use global variables? > Here's a modified version of your program using the advice above (and > my pretty-printing style): > > [skip some code] > Why an error in using strings makes the program to behave as it was a deadlock? Thank you. Now the program runs without problems. fabio de francesco