comp.lang.ada
 help / color / mirror / Atom feed
From: Jan Prazak <janp9@gmx.net>
Subject: Re: gnat: time-slicing
Date: Mon, 15 Jul 2002 22:30:53 -0100
Date: 2002-07-15T22:30:53-01:00	[thread overview]
Message-ID: <pan.2002.07.15.22.17.12.476881.1909@gmx.net> (raw)
In-Reply-To: mailman.1026753422.20321.comp.lang.ada@ada.eu.org

On Mon, 15 Jul 2002 16:16:17 -0100, David C. Hoos wrote:

> What result did it give?
> 
> When I ran your program on my RedHat 6.2 box with dual 1.0 gHz.
> processors, it gave the result you wanted.
> 
> When I ran it on my Win2K box with one 1.8 gHz. processor, it gave the
> reult a
> a
> b
> b

the result was
a
b
a
b

with Delay 0.01 after *every* Put_Line
and 

a
a
b
b

with no delays.

The tutorial mentions, that

ab

ab

can be produced even on systems with only one CPU, depending on the
compiler.

> When I added the suggested delay statements, it gave the result b a
> b
> a
> 
> which interleaves the actions of the tasks, but with Task_A beginning
> execution before the main program.

Task_A begins after the main program in my case.

> There is no way your program can be deterministic over different OSs,
> and hardware platforms.  Time slicing will not do it either.

Yes, let us close this topic. I have what I want, because the test
program with task "Beep" works as expected (I want to make a similar
program).

>> Think of a timer:
>>
>> task Timer is ...
>> ...
>> loop
>>   Delay 1.0;
>>   Put(current_time);
>> end loop;
>> ...
> This restatement of what you want to do is completely different from
> what you described in your original post.

I don't think so. It's different, but not at all.
Let me discuss my "Beep" program.In my first posting,
there is Put_Line, which lets execute another statements (tasks) only
when it has finished writing the text ('a'), and so I expected "Get(C)"
also to stop all running processes, until the user gives a character and
presses enter. But actually it permits other tasks to run at the same
time, which I haven't expected.

> If I understand what you want is a task that will run once per some time
> interval
> independently of the other task(s).

yes, for instance

> Here is an example of how that can be done:
> 
>    Interval : constant Duration := 1.0;
>    use type Ada.Calendar.Time;
>    Next_Time : Ada.Calendar.Time :=
>        Ada.Calendar.Clock + Interval;
> begin
>     loop
>         Delay until Next_Time;
>         Next_Time := Next_Time + Interval;
>         ......
>    end loop;

This looks like an example from the Ada95 reference manual.

> For example, if you have a compute-intensive task that executes a delay
> 0.0 statement no time will be lost if there is no other task ready to
> run.  But, when your timer task is ready, and is of a higher priority,
> it will run when given the opportunity.

As I could see, "Delay 0.0" is ignored by the compiler (running program).
It has no effects on other tasks. I have tried to add "Delay 0.0" after each
"Put_Line" into the first example program, and the result was
a
a
b
b

(same as with no delays).
Maybe there is something like "if Duration = 0.0 then skip_statement" in the
definition of Delay.

---
Thanks,
Jan




  reply	other threads:[~2002-07-15 23:30 UTC|newest]

Thread overview: 62+ 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 [this message]
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 ` time-slicing SteveD
2002-07-19 13:32   ` time-slicing Jan Prazak
2002-07-19 12:41     ` time-slicing SteveD
  -- strict thread matches above, loose matches on Subject: below --
2002-07-18  4:44 gnat: time-slicing Grein, Christoph
2002-07-18 18:55 ` Jan Prazak
2002-07-18 16:35   ` Sergey Koshcheyev
2002-07-19  1:37   ` Robert A Duff
replies disabled

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