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-07-18 20:17:12 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!paloalto-snf1.gtei.net!news.gtei.net!enews.sgi.com!sdd.hp.com!usc.edu!attla2!ip.att.net!attbi_feed3!attbi.com!rwcrnsc53.POSTED!not-for-mail From: "SteveD" Newsgroups: comp.lang.ada References: Subject: Re: time-slicing X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Message-ID: NNTP-Posting-Host: 12.225.227.101 X-Complaints-To: abuse@attbi.com X-Trace: rwcrnsc53 1027048631 12.225.227.101 (Fri, 19 Jul 2002 03:17:11 GMT) NNTP-Posting-Date: Fri, 19 Jul 2002 03:17:11 GMT Organization: AT&T Broadband Date: Fri, 19 Jul 2002 03:17:11 GMT Xref: archiver1.google.com comp.lang.ada:27244 Date: 2002-07-19T03:17:11+00:00 List-Id: "Jan Prazak" wrote in message news:pan.2002.07.15.10.24.43.431977.7868@gmx.net... [snip] > But I want the output to be: > > ab > > ab > The following program gives the desired result by creating a task-safe version of Put_Line (actually on W2K I get ba ba instead of ab ab). There are no guarantees on how the run time system will behave with multiple tasks sending output to the same file, but it's easy to use have multiple task send the data to one task that exclusively accesses the file. With Ada.Text_IO; Procedure Task_Demo Is Task Safe_Io is Entry Put( ch : Character ); Entry New_Line; end Safe_Io; Task Body Safe_Io is Out_Char : Character; begin loop select Accept Put( ch : Character ) do Out_Char := ch; end; Ada.Text_Io.Put( Out_Char ); or Accept New_Line; Ada.Text_Io.New_Line; or terminate; -- quit when the main program has terminated end select; end loop; end Safe_Io; procedure Put_Line( Item : String ) is begin for index in Item'Range loop Safe_Io.Put( Item( index ) ); Delay 0.0; -- force a context switch end loop; Safe_Io.New_Line; Delay 0.0; end Put_Line; 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 tutorial says that this is the output with enabled time-slicing) > > I have tried to use -gnatT100, and -gnatT1, and pragma > Time_Slice(0.000001) etc., but none of this works. > I have gnat for Linux. > > Jan >