comp.lang.ada
 help / color / mirror / Atom feed
From: "SteveD" <nospam_steved94@attbi.com>
Subject: Re: time-slicing
Date: Fri, 19 Jul 2002 03:17:11 GMT
Date: 2002-07-19T03:17:11+00:00	[thread overview]
Message-ID: <XwLZ8.54739$Wt3.36254@rwcrnsc53> (raw)
In-Reply-To: pan.2002.07.15.10.24.43.431977.7868@gmx.net

"Jan Prazak" <janp9@gmx.net> 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
>





  parent reply	other threads:[~2002-07-19  3:17 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-15 11:25 gnat: time-slicing Jan Prazak
2002-07-15  8:44 ` Dale Stanbrough
2002-07-15 19:10   ` Jan Prazak
2002-07-15 17:16     ` David C. Hoos
2002-07-15 23:30       ` Jan Prazak
2002-07-16  0:54         ` Jan Prazak
2002-07-16 10:46         ` Lutz Donnerhacke
2002-07-16 11:57           ` Aaro Koskinen
2002-07-16 12:57           ` SteveD
2002-07-16 15:18           ` Florian Weimer
2002-07-16 13:29     ` Marin David Condic
2002-07-17 19:29       ` Jan Prazak
2002-07-15 13:07 ` time-slicing David C. Hoos
2002-07-15 14:56   ` time-slicing Ian Broster
2002-07-15 19:10   ` time-slicing Jan Prazak
2002-07-15 19:10   ` time-slicing Jan Prazak
2002-07-15 19:05     ` time-slicing Anders Gidenstam
2002-07-15 23:30       ` time-slicing Jan Prazak
2002-07-15 20:33         ` time-slicing Darren New
2002-07-16 16:30         ` time-slicing Pascal Obry
2002-07-16 23:05           ` time-slicing Jan Prazak
2002-07-16 21:33     ` time-slicing Robert Dewar
2002-07-15 21:03 ` gnat: time-slicing tmoran
2002-07-16 13:04   ` Jan Prazak
2002-07-16 21:29 ` Robert Dewar
2002-07-17 19:29   ` Jan Prazak
2002-07-17 16:44     ` Pascal Obry
2002-07-17 21:38       ` Jan Prazak
2002-07-17 19:21         ` Randy Brukardt
2002-07-17 22:44           ` Jan Prazak
2002-07-17 19:57             ` Marin David Condic
2002-07-18 18:38               ` Larry Kilgallen
2002-07-20 11:52                 ` Robert Dewar
2002-07-17 19:43         ` Pascal Obry
2002-07-18 18:55           ` Jan Prazak
2002-07-18 17:01             ` Pascal Obry
2002-07-18 17:03             ` Pascal Obry
2002-07-18 22:38         ` chris.danx
2002-07-18  2:50     ` R. Tim Coslet
2002-07-18 12:54       ` SteveD
2002-07-20 11:56       ` Robert Dewar
2002-07-18 12:02     ` Frank J. Lhota
2002-07-19  2:33 ` Robert A Duff
2002-07-19 13:32   ` Jan Prazak
2002-07-19 23:46   ` Keith Thompson
2002-07-20  0:36     ` Robert A Duff
2002-07-20  4:25       ` Darren New
2002-07-20 11:47     ` Robert Dewar
2002-07-21 10:58       ` Keith Thompson
2002-07-31 22:28       ` Robert A Duff
2002-08-01 19:28   ` Erroneous execution? (was Re: gnat: time-slicing) Ben Brosgol
2002-08-01 22:03     ` Robert A Duff
2002-08-02  3:59       ` Ben Brosgol
2002-08-13 22:30         ` Robert A Duff
2002-08-02  4:17       ` Robert Dewar
2002-07-19  3:17 ` SteveD [this message]
2002-07-19 13:32   ` time-slicing Jan Prazak
2002-07-19 12:41     ` time-slicing SteveD
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox