From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4f1f6efa7df4b008 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-09-27 03:58:03 PST Newsgroups: comp.lang.ada Path: bga.com!news.sprintlink.net!howland.reston.ans.net!noc.near.net!inmet!dsd!stt From: stt@dsd.camb.inmet.com (Tucker Taft) Subject: Re: Ada & UNIX Message-ID: Sender: news@inmet.camb.inmet.com Organization: Intermetrics, Inc. References: Date: Tue, 27 Sep 1994 10:44:50 GMT Date: 1994-09-27T10:44:50+00:00 List-Id: In article , Scott Catterill wrote: > ... >I have a some concerns regarding Ada programming under UNIX. >I would appreciate any feedback from any of you gurus out there. As a general comment, these questions are almost all implementation-specific, since the definition of the language does not force a particular mapping to a given set of O/S features. However, there is enough commonality among implementations to give at least partial answers. > >1. How do Ada tasks and Unix processes co-exist? In most implementations, the execution of an Ada "program" results in a single Unix process, with all tasks "inside" that single process. In some implementations, multiple Unix processes are used, essentially like "logical processors." In these cases, when one of the Unix processes becomes idle, it selects the next task from the ready queue to execute. Many implementations are now moving toward using "threads" to support Ada tasking, when the Unix O/S supports them. Threads are a very close match to Ada tasks, in that they share the same address space and other process resources, just like Ada tasks, but when one thread does a system call, only that thread is suspended. >2. How do Ada tasks behave when interacting with Unix utilities? > For example, do serial inputs suspend an Ada task or a Unix process? This also depends on the implementation. In implementations that use multiple processes, or multiple threads, then only the process or thread that is executing the task is suspended inside a system call. On single-process/single-thread implementations, asynchronous forms of system calls are sometimes used to avoid suspending the whole process. If the asynchronous forms are not available or not used, then the whole process suspends on a system call in single-process/single-thread implementations. >3. How can mutual exclusion over data be implemented between Ada tasks and > Unix processes? You can use Unix/Posix mutexes if you want. There is no particular magic here. Perhaps you have something more specific in mind... >4. How do Ada subprograms interface with Unix processes? For example, Unix > pipes and streams are often used in C programs. How are these accessed > from Ada? Should they be? Pipes and streams can certainly be used with Ada, particularly since they generally just appear as I/O. There is an Ada binding available to essentially all Unix system calls, called "Posix/Ada." If it is not available from your vendor, you can write your own bindings for the systems calls of interest, using pragma Interface. >5. How do Ada task priorities and Unix process priorities interact? There is generally no connection. Ada task priorities are within-process priorities. Unix process priorities are between-process priorities. In some environments where Unix processes support multiple threads, it is possible to have a closer interaction. For example, the Ada task priority might become the Unix thread priority, and if that priority is in the "real-time thread" range, it has some between-process significance. >6. What can make Ada tasks and Unix processes behave non-deterministically in > space or time? Almost all multithreaded systems are nondeterministic, because the relative rate of progress of the various threads is not fully determined by priority. You can increase the level of determinism by using a strict run-until-blocked scheduler, with each thread having its own priority level. A few "real-time" Unix systems provide some "real-time" priority levels that have such nearly-deterministic scheduling. The default scheduling model in Ada is strictly priority-based, so if you make sure each task has its own priority level, then scheduling within process will be nearly deterministic. But of course if a task performs I/O, or delays for a period of time that depends on external factors, then you introduce nondeterminism due to the nondeterminism of the external environment. >7. What are the effects of virtual memory? Nothing special for Ada. However, if you are worried about real-time, then this is an O/S question. You will probably want a "real-time" Unix process to be locked into memory. >8. How is memory organized and allocated? Can memory be shared between > processes and tasks? Tasks are part of processes, in general. A Unix process represents a virtual address space. Tasks within a given Ada program share access to that space. Task stacks are allocated out of that space. >9. How are peripheral devices controlled and accessed from Ada tasks and Unix > processes? In the usual Unix way -- via system calls and sometimes signals. >Any responses are appreciated, including pointers to sites or other available >references.. Many thanks. You should probably get your hands on a Posix/Ada description. > ------Scott Catterill: aa355@freenet.carleton.ca------ > -----Sysop: Heart of Gold BBS: (613) 831-1973 ----- S. Tucker Taft stt@inmet.com Intermetrics, Inc. Cambridge, MA 02138