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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,63360011f8addace X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-08-01 12:34:01 PST Newsgroups: comp.lang.ada Path: archiver1.google.com!news2.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!arclight.uoregon.edu!news.tufts.edu!uunet!dca.uu.net!ash.uu.net!world!news From: "Ben Brosgol" Subject: Erroneous execution? (was Re: gnat: time-slicing) X-Mimeole: Produced By Microsoft MimeOLE V5.50.4522.1200 Sender: news@world.std.com (Mr Usenet Himself) Message-ID: X-Priority: 3 Date: Thu, 1 Aug 2002 19:28:12 GMT X-Msmail-Priority: Normal References: NNTP-Posting-Host: ppp0b163.std.com Organization: The World @ Software Tool & Die X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 Xref: archiver1.google.com comp.lang.ada:27585 Date: 2002-08-01T19:28:12+00:00 List-Id: > > with Ada.Text_IO; use Ada.Text_IO; > > > > procedure Task_Demo is > > task A; > > task body A is > > begin > > Put_Line("b"); > > Put_Line("b"); > > end A; > > begin > > Put_Line("a"); > > Put_Line("a"); > > end Task_Demo; > > --------------- > > The above example is erroneous, which means that the output is totally > unpredictable. The reason it's erroneous is that two tasks are messing > with the same shared variable (the standard output file) at the same > time. Bob- Are you sure this is erroneous? The "shared variable" is hidden in the private part or body of a predefined library package and ARM paragraph A(3) says that in such cases it is the responsibility of the implementation to protect the shared variable from getting trashed (*). Now Put_Line is equivalent to looping over Put() and then doing a New_Line so the user may see interspersed output -- e.g., either or both "b"s might not be immediately followed by a newline -- but the implementation would be nonconformant with the ARM if, for example, simultaneous calls on Put caused the machine to reboot (which was the effect one saw in an early version of the old Alsys DOS Ada compiler :-) I'm not recommending that anyone actually write code such as Task_Demo, but I don't think it's an example of erroneous execution. (*) The rule actually says "The implementation shall ensure that each language defined subprogram is reentrant in the sense that concurrent calls on the same subprogram perform as specified, so long as all parameters that could be passed by reference denote nonoverlapping objects." But I believe the intent is as I indicated. -Ben