comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Ada.Execution_Time
Date: Wed, 29 Dec 2010 22:32:30 +0200
Date: 2010-12-29T22:32:30+02:00	[thread overview]
Message-ID: <8o1k6vFbd7U1@mid.individual.net> (raw)
In-Reply-To: <aooml6t0ezs4.4srxtfm9z00r.dlg@40tude.net>

Dmitry A. Kazakov wrote:
> On Wed, 29 Dec 2010 14:48:20 +0200, Niklas Holsti wrote:
> 
>> Dmitry has agreed with some of my statements on this point, for example:
>>
>> - A task cannot accumulate execution time at a higher rate than real 
>> time. For example, in one real-time second the CPU_Time of a task cannot 
>> increase by more than one second.
> 
> Hold on, that is only true if a certain model of CPU_Time measurement used.

In my view, it is true within the accuracy of the execution-time 
measurement method.

> There are many potential models. The one we discussed was the model A:
> 
> Model A. Get an RTC reading upon activation. Each time CPU_Time is
> requested by Clock get another RTC reading, build the difference, add the
> accumulator to the result. Upon task deactivation, get the difference and
> update the accumulator.

OK. This is, I think, the most natural model, perhaps with some 
processor performance counter or CPU-clock-cycle counter replacing the RTC.

> This is a very strong model. Weaker models:
> 
> Model A.1. Get RTC upon activation and deactivation. Update the accumulator
> upon deactivation. When the task is active CPU_Time does not change.

That model is not permitted, because the value of 
Ada.Execution_Time.Clock must change at every "CPU tick". The duration 
of a CPU tick is Ada.Execution_Time.CPU_Tick, which is at most one 
millisecond (RM D.14(20/2)).

It is true that CPU_Tick is only the "average length" of the 
constant-Clock intervals, but the implementation is also required to 
document an upper bound, which also forbids your model A.1.

(I think that this "average" definition caters for implementations where 
the execution time counter is incremented by an RTC interrrupt handler 
that may suffer some timing jitter.)

> Model B. Use a time source different from RTC. This what Windows actually
> doest.

I don't think that this is a different "model". No time source provides 
ideal, exact real time. If the time source for Ada.Execution_Time.Clock 
differs much from real time, the accuracy of the implementation is poor 
to that extent. It does not surprise me that this happens on Windows.

I admit that the RM does not specify any required accuracy for 
Ada.Execution_Time.Clock. The accuracy required for 
execution-time-dependent scheduling algorithms is generally low, I believe.

Analogously, there are no accuracy requirements on Ada.Real_Time.Clock.

> Model B.1. Like A.1, CPU_Time freezes when the task is active.

Forbidden like A.1 above.

> Model C. Asynchronous task monitoring process

That sounds weird. Please clarify.

> Note that in either model the counter readings are rounded. Windows rounds
> toward zero, which why you never get more load than 100%. But it is
> thinkable and expectable that some systems would round away from zero or to
> the nearest bound. So the statement holds only if you have A (maybe C) + a
> corresponding rounding.

So it holds within the accuracy of the measurement method, which often 
involves some sampling or rounding error. In my view.

>> - If only one task is executing on a processor, the execution time of 
>> that task increases (or "could increase") at the same rate as real time.
> 
> This also may be wrong if a B model is used. In particular, task switching
> may be (and I think is) driven by the programmable timer interrupts. The
> real-time clock may be driven by the TSC. Since these two are physically
> different, unsynchronized time sources, the effect can be any. It is to
> expect a systematic error accumulated with the time.

Again, it holds within the accuracy of the measurement method and the 
time source, which is all that one can expect.

The points I made were meant to show how CPU_Time is related, in 
principle, to real time. I entirely accept that in practice the 
relationships will be affected by measurement inaccuracies.

For the task scheduling methods that depend on actual execution times, I 
believe that long-term drifts or accumulations of errors in CPU_Time are 
unimportant. The execution time (span) measurements need to be 
reasonably accurate only over time spans similar to the period of the 
longest-period task. The overhead (execution time not charged to tasks) 
will probably be much larger, both in mean value and in variability, 
than the time-source errors.

As discussed earlier, the time source for Ada.Real_Time.Clock that 
determines when time-driven tasks are activated may need higher fidelity 
to real time.

>> The question is how much meaning should be read into ordinary words like 
>> "time" when used in the RM without a formal definition.
> 
> Time as physical concept is not absolute. There is no *the* real time, but
> many real times and even more unreal ones.

When RM D.14(11/2) defines "the execution time of a given task" as "the 
time spent by the system executing that task", the only reasonable 
reading of the second "time" is as the common-sense physical time, as 
measured by your wrist-watch or by some more precise clock.

Let's not go into relativity and quantum mechanics for this.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .



  parent reply	other threads:[~2010-12-29 20:32 UTC|newest]

Thread overview: 124+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-12  4:19 Ada.Execution_Time BrianG
2010-12-12  5:27 ` Ada.Execution_Time Jeffrey Carter
2010-12-12 16:56 ` Ada.Execution_Time Jeffrey Carter
2010-12-12 21:59   ` Ada.Execution_Time BrianG
2010-12-12 22:08     ` Ada.Execution_Time BrianG
2010-12-13  9:28     ` Ada.Execution_Time Georg Bauhaus
2010-12-13 22:25       ` Ada.Execution_Time Randy Brukardt
2010-12-13 22:42         ` Ada.Execution_Time J-P. Rosen
2010-12-14  3:31         ` Ada.Execution_Time Jeffrey Carter
2010-12-14 15:42           ` Ada.Execution_Time Robert A Duff
2010-12-14 16:17             ` Ada.Execution_Time Jeffrey Carter
2010-12-14 19:10             ` Ada.Execution_Time Warren
2010-12-14 20:36               ` Ada.Execution_Time Dmitry A. Kazakov
2010-12-14 20:48                 ` Ada.Execution_Time Jeffrey Carter
2010-12-14  8:17         ` Ada.Execution_Time Vinzent Hoefler
2010-12-14 15:51           ` Ada.Execution_Time Adam Beneschan
2010-12-14 15:53           ` Ada.Execution_Time Robert A Duff
2010-12-14 17:17             ` Ada.Execution_Time Dmitry A. Kazakov
2010-12-14 17:45               ` Ada.Execution_Time Robert A Duff
2010-12-14 18:23                 ` Ada.Execution_Time Adam Beneschan
2010-12-14 21:02                   ` Ada.Execution_Time Randy Brukardt
2010-12-15 22:52             ` Ada.Execution_Time Keith Thompson
2010-12-15 23:14               ` Ada.Execution_Time Adam Beneschan
2010-12-17  0:44                 ` Ada.Execution_Time Randy Brukardt
2010-12-17 17:54                   ` Ada.Execution_Time Warren
2010-12-20 21:28                   ` Ada.Execution_Time Keith Thompson
2010-12-21  3:23                     ` Ada.Execution_Time Robert A Duff
2010-12-21  8:04                       ` Ada.Execution_Time Dmitry A. Kazakov
2010-12-21 17:19                         ` Ada.Execution_Time Robert A Duff
2010-12-21 17:43                           ` Ada.Execution_Time Dmitry A. Kazakov
2010-12-14 19:43           ` Ada.Execution_Time anon
2010-12-14 20:09             ` Ada.Execution_Time Adam Beneschan
2010-12-15  0:16       ` Ada.Execution_Time BrianG
2010-12-15 19:17         ` Ada.Execution_Time jpwoodruff
2010-12-15 21:42           ` Ada.Execution_Time Pascal Obry
2010-12-16  3:54             ` Ada.Execution_Time jpwoodruff
2010-12-17  7:11               ` Ada.Execution_Time Stephen Leake
2010-12-15 21:40         ` Ada.Execution_Time Simon Wright
2010-12-15 23:40           ` Ada.Execution_Time BrianG
2010-12-15 22:05         ` Ada.Execution_Time Randy Brukardt
2010-12-16  1:14           ` Ada.Execution_Time BrianG
2010-12-16  5:46             ` Ada.Execution_Time Jeffrey Carter
2010-12-16 16:13               ` Ada.Execution_Time BrianG
2010-12-16 11:37             ` Ada.Execution_Time Simon Wright
2010-12-16 17:24               ` Ada.Execution_Time BrianG
2010-12-16 17:45                 ` Ada.Execution_Time Adam Beneschan
2010-12-16 21:13                   ` Ada.Execution_Time Jeffrey Carter
2010-12-17  0:35               ` New AdaIC site (was: Ada.Execution_Time) Randy Brukardt
2010-12-16 13:08             ` Ada.Execution_Time Peter C. Chapin
2010-12-16 17:32               ` Ada.Execution_Time BrianG
2010-12-16 18:17             ` Ada.Execution_Time Jeffrey Carter
2010-12-16  8:45           ` Ada.Execution_Time Dmitry A. Kazakov
2010-12-16 16:49             ` Ada.Execution_Time BrianG
2010-12-16 17:52               ` Ada.Execution_Time Dmitry A. Kazakov
2010-12-17  8:49                 ` Ada.Execution_Time Niklas Holsti
2010-12-17  9:32                   ` Ada.Execution_Time Dmitry A. Kazakov
2010-12-17 11:50                     ` Ada.Execution_Time Niklas Holsti
2010-12-17 13:10                       ` Ada.Execution_Time Dmitry A. Kazakov
2010-12-18 21:20                         ` Ada.Execution_Time Niklas Holsti
2010-12-19  9:57                           ` Ada.Execution_Time Dmitry A. Kazakov
2010-12-25 11:31                             ` Ada.Execution_Time Niklas Holsti
2010-12-26 10:25                               ` Ada.Execution_Time Dmitry A. Kazakov
2010-12-27 12:44                                 ` Ada.Execution_Time Niklas Holsti
2010-12-27 15:28                                   ` Ada.Execution_Time Dmitry A. Kazakov
2010-12-27 20:11                                     ` Ada.Execution_Time Niklas Holsti
2010-12-27 21:34                                       ` Ada.Execution_Time Simon Wright
2010-12-28 10:01                                         ` Ada.Execution_Time Niklas Holsti
2010-12-28 14:17                                           ` Ada.Execution_Time Simon Wright
2010-12-27 21:53                                       ` Ada.Execution_Time Dmitry A. Kazakov
2010-12-28 14:14                                         ` Ada.Execution_Time Simon Wright
2010-12-28 15:08                                           ` Ada.Execution_Time Dmitry A. Kazakov
2010-12-28 16:18                                             ` Ada.Execution_Time Simon Wright
2010-12-28 16:34                                               ` Ada.Execution_Time Dmitry A. Kazakov
2010-12-31  0:40                                             ` Ada.Execution_Time BrianG
2010-12-31  9:09                                               ` Ada.Execution_Time Dmitry A. Kazakov
2010-12-28 14:46                                         ` Ada.Execution_Time Niklas Holsti
2010-12-28 15:42                                           ` Ada.Execution_Time Dmitry A. Kazakov
2010-12-28 16:27                                             ` Ada.Execution_Time (see below)
2010-12-28 16:55                                               ` Ada.Execution_Time Dmitry A. Kazakov
2010-12-28 19:41                                                 ` Ada.Execution_Time (see below)
2010-12-28 20:03                                                   ` Ada.Execution_Time Dmitry A. Kazakov
2010-12-28 22:39                                                     ` Ada.Execution_Time Simon Wright
2010-12-29  9:07                                                       ` Ada.Execution_Time Dmitry A. Kazakov
2010-12-27 17:24                                 ` Ada.Execution_Time Robert A Duff
2010-12-27 22:02                                   ` Ada.Execution_Time Randy Brukardt
2010-12-27 22:43                                     ` Ada.Execution_Time Robert A Duff
2010-12-27 22:11                               ` Ada.Execution_Time Randy Brukardt
2010-12-29 12:48                                 ` Ada.Execution_Time Niklas Holsti
2010-12-29 14:30                                   ` Ada.Execution_Time Dmitry A. Kazakov
2010-12-29 16:19                                     ` Ada.Execution_Time (see below)
2010-12-29 16:51                                       ` Ada.Execution_Time Dmitry A. Kazakov
2010-12-29 19:57                                         ` Ada.Execution_Time (see below)
2010-12-29 21:20                                           ` Ada.Execution_Time Dmitry A. Kazakov
2010-12-30  5:13                                             ` Ada.Execution_Time Randy Brukardt
2010-12-30 13:37                                             ` Ada.Execution_Time Niklas Holsti
2010-12-29 20:32                                     ` Niklas Holsti [this message]
2010-12-29 21:21                                       ` Ada.Execution_Time Dmitry A. Kazakov
2010-12-30 13:34                                         ` Ada.Execution_Time Niklas Holsti
2010-12-30 19:23                                     ` Ada.Execution_Time Niklas Holsti
2010-12-30  5:06                                   ` Ada.Execution_Time Randy Brukardt
2010-12-30 23:49                                     ` Ada.Execution_Time Niklas Holsti
2010-12-31 23:34                                       ` Ada.Execution_Time Randy Brukardt
2011-01-01 13:52                                         ` Ada.Execution_Time Niklas Holsti
2011-01-01 14:42                                           ` Ada.Execution_Time Simon Wright
2011-01-01 16:01                                             ` Ada.Execution_Time Simon Wright
2011-01-01 19:18                                               ` Ada.Execution_Time Niklas Holsti
2011-01-03 21:27                                           ` Ada.Execution_Time Randy Brukardt
2011-01-06 22:55                                             ` Ada.Execution_Time Niklas Holsti
2011-01-07  6:25                                               ` Ada.Execution_Time Randy Brukardt
2011-01-01 15:54                                         ` Ada.Execution_Time Simon Wright
2011-01-03 21:33                                           ` Ada.Execution_Time Randy Brukardt
2011-01-05 15:55                                             ` Ada.Execution_Time Brad Moore
2010-12-17  8:59         ` Ada.Execution_Time anon
2010-12-19  3:07           ` Ada.Execution_Time BrianG
2010-12-19  4:01             ` Ada.Execution_Time Vinzent Hoefler
2010-12-19 11:00               ` Ada.Execution_Time Niklas Holsti
2010-12-21  0:37                 ` Ada.Execution_Time Randy Brukardt
2010-12-21  1:20                   ` Ada.Execution_Time Jeffrey Carter
2010-12-19 12:27               ` Ada.Execution_Time Dmitry A. Kazakov
2010-12-21  0:32               ` Ada.Execution_Time Randy Brukardt
2010-12-19 22:54             ` Ada.Execution_Time anon
2010-12-20  3:14               ` Ada.Execution_Time BrianG
2010-12-22 14:30                 ` Ada.Execution_Time anon
2010-12-22 20:09                   ` Ada.Execution_Time BrianG
replies disabled

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