From: "Robert I. Eachus" <rieachus@comcast.net>
Subject: Re: Improving Ada's Image
Date: Sat, 26 Jun 2004 23:50:13 -0400
Date: 2004-06-26T23:50:13-04:00 [thread overview]
Message-ID: <gpqdne_thuFr3kPdRVn-gQ@comcast.com> (raw)
In-Reply-To: <pan.2004.06.25.23.58.31.317747@email.ro>
David Starner wrote:
> I'm not sure I would take a noticeable speed hit versus Linux for
> improvement of its security or crashes (which I encounter once every two
> weeks or so). It just wouldn't make enough difference for me. If I
> were running something besides a purely personal computer, I might
> analyze things differently of course.
Let me speak as someone who has been there and done that. Stratus VOS
was/is written in PL/I. To support Ada on VOS, I had to put a change in
the kernel to allow PL/I condition handlers and Ada exception handlers
exist together gracefully on any stack.
Rather than take the high road, here is why we need this change, and it
won't impact performance that much, yadda, yadda, yadda, I cheated.
There was an open bug report about a race condition involving multiple
conditions. In effect if you hit the break key often enough, you could
catch the race window and end up in the default error handler.
So I "fixed" the bug and proved that it did indeed eliminate the
possibility of a race condition. I also demonstated a test program that
threw tens of thousands of external conditions per minute at a running
program, without ever ending up in the DEH. So the fix was accepted.
It reduced the OS overhead by 2% in benchmarks. (In other words if the
system time on some benchmark had been 10.0% of total time, it was now
9.8%.) This was considered to be pretty huge, especially for a change
in condition handling. There weren't that many PL/I conditions (Ada
exceptions) handled by the OS during normal operation. So what gives?
I had to make the operation of entering or leaving the scope of a PL/I
condition handler (or an Ada exception handler) atomic. No other way to
fix the race condition. Once I had decided how to do that, (a RMW cycle
on one word in a stack frame) it allowed me to throw away a lot of now
unnecessary code. ;-) It wasn't quite that simple, in Ada, there is a
nesting relationship between exception handlers, but in PL/I you could
exit the scope of one handler while leaving a later handler active.
That did require making a copy of the list of handlers. (If you had Ada
style nested scopes, you could change where you entered an otherwise
constant list of handlers.) Of course, most handlers for Ada or PL/I,
once entered stay active until the scope is left. Popping a stack frame
took its associated handlers with it.
Whenever I have worked on or with Ada operating systems, the customers
have been amazed by the lack of overhead. (You might prefer to call
these bare machine run-times, or real-time OSes, depending on your
viewpoint. We are not talking about a Unix or Windows like system at
all.) Every time we looked, it was like that case at Stratus. The cost
of "doing it right" was to reduce overhead.
I should probably give another example. One of the most time-consuming
parts of a real-time operating system is the scanning of queues to
determine which task must be run next. In one real-time system we had
to turn that around to meet timing requirements. It turned out that
when a task became eligible to run, there were three things that could
happen:
It was higher in priority than the running task. Run it.
The new task is higher in priority than any eligible task other than
the running task. Put its handle in the "Ready_Task" variable. (Two
comparisons now. The priority of the running task, and the priority of
the ready task.)
The new task doesn't meet those criteria, attach it to the end of
the appropriate queue.
The complicated part, and it wasn't too complex, was that if the
currently running task became inelegible for whatever reason. It
started the ready task, and marked the Ready_Task as invalid. The next
task to come along that was lower in priority than the running task
caused the Ready_Task to be recomputed. Otherwise the value was
recomputed when the currently executing task completed. Since low
priority tasks could not become eligible during the highest priority
tasks--Interrupts were disabled of course--we could meet some pretty
hairy timing deadlines. (The idle task never completed of course, so if
it was running, you could put it into Ready_Task, and take over.)
But we also found that the overhead of scheduling was cut more than in
half. By putting counters in the loop that scanned the priority queues,
we found that there was a huge amount of scanning that went away. The
tasks that were most frequently scheduled when the Ready_Task was
invalid were high-priority tasks. They only had to scan at most the
list between the currently executing task's priority and the newly
eligible task's priority. When the clock "ticked" and scheduled a new
bunch of tasks they were scheduled in priority order, so only the first
one might have to do a scan.
I probably went into more detail than necessary. The real advantage was
no kludges to maintain backward compatibility. ;-)
--
Robert I. Eachus
"Reason and experience both forbid us to expect that national morality
can prevail in exclusion of religious principles." -- George Washington
next prev parent reply other threads:[~2004-06-27 3:50 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-24 14:21 Improving Ada's Image Nick Roberts
2004-06-25 0:20 ` Jacob Sparre Andersen
2004-06-25 11:30 ` Marin David Condic
2004-06-25 14:54 ` Larry Kilgallen
2004-06-25 16:12 ` Frank J. Lhota
2004-06-26 20:26 ` Marin David Condic
2004-06-28 13:41 ` Frank J. Lhota
2004-06-28 14:39 ` Dmitry A. Kazakov
2004-06-29 11:39 ` Marin David Condic
2004-06-29 11:48 ` Martin Dowie
2004-06-30 11:46 ` Marin David Condic
2004-06-28 17:00 ` Larry Kilgallen
2004-06-29 11:35 ` Marin David Condic
2004-06-26 0:01 ` David Starner
2004-06-26 10:12 ` Nick Roberts
2004-06-26 11:32 ` Luke A. Guest
2004-06-26 15:20 ` Nick Roberts
2004-06-29 18:44 ` Luke A. Guest
2004-06-29 22:25 ` Nick Roberts
2004-06-27 16:40 ` Pylinius
2004-06-27 19:04 ` Nick Roberts
2004-06-26 11:53 ` David Starner
2004-06-26 15:21 ` Nick Roberts
2004-06-27 3:50 ` Robert I. Eachus [this message]
[not found] <20040604175015.9DE3E4C409B@lovelace.ada-france.org>
2004-06-04 20:38 ` Improving Ada's image Andrew Carroll
2004-06-05 12:49 ` Marin David Condic
2004-06-05 17:07 ` Marius Amado Alves
2004-06-05 20:39 ` Marin David Condic
2004-06-05 22:18 ` Marius Amado Alves
2004-06-05 23:40 ` Marin David Condic
2004-06-06 8:48 ` Marius Amado Alves
2004-06-06 21:34 ` Georg Bauhaus
2004-06-06 22:30 ` Marius Amado Alves
[not found] ` <40C39B01.5060806@netcabo.pt>
2004-06-06 22:50 ` Marius Amado Alves
2004-06-06 2:53 ` Robert C. Leif
2004-06-06 3:25 ` Wes Groleau
2004-06-06 11:54 ` Marius Amado Alves
2004-06-06 18:21 ` Wes Groleau
[not found] ` <40C246A7.4070705@netcabo.pt>
2004-06-06 8:24 ` Marius Amado Alves
2004-06-06 14:25 ` Marin David Condic
2004-06-06 18:14 ` Wes Groleau
2004-06-07 17:04 ` Warren W. Gay VE3WWG
2004-06-07 19:06 ` Björn Persson
-- strict thread matches above, loose matches on Subject: below --
2004-05-30 11:46 Improving Ada's image - Was: 7E7 Flight Controls Electronics Per Dalgas Jakobsen
2004-05-31 20:55 ` Improving Ada's image Björn Persson
2004-06-01 0:41 ` Alexander E. Kopilovich
2004-06-01 11:23 ` Marin David Condic
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox