[comp.sys.isis] Isis from Ada

rcbc@cs.cornell.edu (Robert Cooper) (04/30/91)

In article <454@sandia.UUCP>, kristina@sandia (Kristina Buchholtz (9226)) writes:

>When Client_Maintask gets called, I get an Ada Storage_Error (and the
>message: Error in kernel:: exception handler: below bottom of user stack), 
>which I can get rid of if I do a PRAGMA SUPPRESS(Storage_Check); the same 
>thing happens when read_new_table gets called.  Now, on our SUN4's, if I do 
>the pragma suppress, read_new_table gets called and can actually do something.

>I am hoping that if I actually start up Isis from an ada program instead of
>a C program, the right environment will be set up and I'll be able to do
>ada i/o.  Can anyone confirm or deny this?  

First, we at the Isis Project currently don't know anything about Ada
implementations. (That will change in the next few months though!
In fact we'd like to hear recommendations on the various Ada systems
available on Unix)

However, based on our experience with previous language/OS ports there are
a number of problems you are almost certainly running in to:

(1) Ada's multitasking mechanism and Isis are fighting with each other.
On SunOS and Ultrix Isis uses its own tasking mechanism that is built on
top of setjmp/longjmp. However, the Isis tasking mechanism is fairly
portable, and you can redefine a bunch of macros in cl_task.h (and some
stuff in cl_task.c) to use whatever local tasking mechanism you have. E.g.
on lisp we use lisp multiprocessing, on Mach we use CThreads etc. If you
can find Ada runtime equivalents to the Isis task primitives that will 
fix a lot of your problems.

(3) Garbage collection/storage allocation may be a problem. Can your Ada
system co-exist with C libraries that call malloc? Are you using garbage
collection? If so then relocation by the garbage collector 
of objects passed to Isis routines could be a problem. 

(2) I/O is another area where Isis and Ada runtime may fight with each
other. When Ada blocks one of its tasks for I/O it won't notice that
there are Isis tasks that could run. Equally, the default SunOS Isis
I/O implementation won't know about Ada tasks. So you'll get deadlock.
Again, the solution is in some portability stuff we've coded into
the Isis libraries. In cl_isis.c there is support for non-standard select
calls. The idea is that either you have to get your Ada code to call
isis_select (which emulates the Unix select call), or you do it the other
way round and have Isis call something in the Ada runtime library whenever
it would normally do a Unix select.

Summing up: combining Unix libraries that support multithreading and I/O
requires SOME cooperation between the libraries! This is not so much of a
problem on OS's that support operating system threads, e.g. Mach. Let us
know if you decide to undertake some of these changes, and get back to us
for more details on how to do it.

If the Ada runtime system turns out to be too opaque to figure out what its
doing and to modify it, the alternative is to put the Isis clib in a
separate Unix process and communicate between Ada and the Clib task over a
pipe or socket. 

                  -- Robert Cooper