Peter Hermann wrote:
> [topic moved from chat to team-ada]
> > >add a delay 0.0 to allow switching ...
> > I don't have an RM handy, but I recall you technically need something
> > like delay duration'small or something to force a task switch.
> I remember I once was very disappointed about the language
> definition not to allow for a zero time break point :-(
I believe it was not required in Ada 83 that a "delay 0.0" provide a
task rescheduling opportunity. My guess is that they didn't realize
it would be an issue. There was not a large body of work on
in-language concurrency to go by, at the time.
END HAZY RECOLLECTION
In Ada 95, IF your implementation is compliant with the real-time
Annex (D), a "delay 0.0" or even "delay -t" would provide one, and in
the default task dispatching policy will cede the processor to another
ready task of the same priority (D.2.2(11)).
If your implementation is NOT compliant with Annex D, you get vendor's
pot luck for scheduling procedures.
> A "delay 0.0" should be a potential break, what else?
> Give me one reason not to do so.
I agree, but there IS a reasonable argument on the other side.
A computed delay often means "wait until something else is ready." If
the computed delay is zero or negative, it means that the other thing
is ready now, and you can go on. If task rescheduling is expensive in
run time, the implementation could reasonably test the delay first,
and if it's zero or less just continue. This is a time optimization,
and many users carp about wanting every picosecond of performance they
can get, so they should be glad to skip a task rescheduling.
This line of reasoning caused problems for a significant chunk of the
user community, who wanted a way to explicitly let the tasks
reschedule. So, the Ada 95 standard made clear what behavior is
preferred, at least for real-time compliant implementations.
(A REALLY savvy compiler writer might reschedule on an explicit "delay
0.0", but not on a computed "delay [expression]" where [expression]
evaluates to 0.0. I don't know if anyone did this. If so, it was
implementation-dependent, and you couldn't count on it.)
Samuel Mize -- [log in to unmask] -- Team Ada
(personal net account)