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=0.7 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,4fe1e6b66c35dfe2,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: mockturtle Newsgroups: comp.lang.ada Subject: About task-safeness Date: Wed, 2 Feb 2011 12:51:04 -0800 (PST) Organization: http://groups.google.com Message-ID: <06ecb5ab-a9e5-4a5d-9370-6bbe137d3693@glegroupsg2000goo.googlegroups.com> Reply-To: comp.lang.ada@googlegroups.com NNTP-Posting-Host: 109.54.174.82 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1296679865 14203 127.0.0.1 (2 Feb 2011 20:51:05 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 2 Feb 2011 20:51:05 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=109.54.174.82; posting-account=9fwclgkAAAD6oQ5usUYhee1l39geVY99 User-Agent: G2/1.0 Xref: g2news2.google.com comp.lang.ada:17795 Date: 2011-02-02T12:51:04-08:00 List-Id: Dear all, I have a question (better, two questions) about packages and concurrence. = =20 We have a software, a fairly complex one, that makes use of tasks. (Just to= give you the context, it is a network communication software that can have= several connections open at once and every connection is handled by a task= .) Data structure that are designed to be shared among different tasks ar= e implemented as protected objects, but it came to my mind that an innocen= t-looking package (that maybe provides some general-purpose functions) coul= d have some "internal state" represented by some variable global to the pac= kage. (For example, a package defining some type of object could keep the = number of allocated objects, so it can give to each object a unique ID.) I= f such a package was used by two different tasks, and the counter was not= protected, obscure bugs can arise. This type of structure maybe is not ve= ry recommended, but it happens... :-( =20 Of course, one could do a review of all the packages to check for this type= of problems, but since an Ada compiler has the good habit of protecting yo= u from yourself, I searched for a way to have the compiler to check the tas= k-safety of the packages used by tasks. =20 My first tentative was to ask that all the packages with-ed by a package th= at defines a task should be Pure (a Pure package cannot have any global var= iables). Unfortunately, I soon discovered that asking for Pure-ity is = too strong a requirement: all the ancestors must be Pure and no un-Pure pac= kage can be used. Although such constraints make perfectly sense, they pre= vent you from using several standard (and useful) packages such as Unbounde= d_Strings, all (?) the Containers hierarchy and GNAT.Sockets (which turns o= ut handy in a networking program...:-). (To be honest, my action of Pure-fi= cation was not useless; while making my packages Pure, I caught a global co= unter in a package...) So, my first question is:=20 * Can you suggest a way to have the compiler to check for some task-safe= ty of packages? Even a technique for a non-totally exhaustive check could= be useful. The thoughts above triggered in me another question. Consider, for example= , the Ordered_Maps package. That package is not Pure (it cannot be, since = it would prevent the use of named access types), so how can I be granted th= at the package does not have some "hidden" and unprotected state? Please n= ote that I am *not* asking for an *object* of type Ordered_Map to be task-s= afe, if I need I can wrap it in a protected object; I am asking for the *pa= ckage* to be task-safe. Note that if, say, Ordered_Maps has some hidden st= atus, two task can modify the status at the same time by accessing to two M= aps, even if the Maps have been wrapped inside two different protected obj= ects. So, my second question is * Am I granted (maybe by some obscure paragraph of our beloved RM ;-) tha= t the standard packages are task-safe? (I would be surprised if they weren'= t, but it is nice to be sure...) Sorry for the quite long message and thank you for any help.