source: rtems-docs/c-user/ada_support.rst @ 464d541

5
Last change on this file since 464d541 was 3384994, checked in by Chris Johns <chrisj@…>, on 11/13/17 at 02:25:18

Clean up sphinx warnings.

  • Fix minor formatting issues.
  • Fix reference the gloassary TLS using ':term:'.
  • Make sure nothing is between an anchor and the heading where ':ref:' references the anchor. This meant moving all the recently added '.. index::' entries.

Update #3232.
Update #3229.

  • Property mode set to 100644
File size: 4.4 KB
Line 
1.. comment SPDX-License-Identifier: CC-BY-SA-4.0
2
3.. COMMENT: COPYRIGHT (c) 1989-2017.
4.. COMMENT: On-Line Applications Research Corporation (OAR).
5.. COMMENT: All rights reserved.
6
7.. index:: Ada
8.. _ada_support:
9
10Ada Support
11************
12
13Introduction
14============
15RTEMS has long had support for the Ada programming language
16by supporting the GNU Ada Compiler (GNAT). There are two primary
17components to this support:
18
19- Ada Programming Language Support
20
21- Classic API Ada Bindings
22
23Ada Programming Language Support
24================================
25
26The Ada programming natively supports multi-threaded programming
27with its own tasking and concurrency model. Native Ada multi-threaded
28applications should work using GNAT/RTEMS with no changes.
29
30The application developer will have to account for the specific
31requirements of the GNAT Run-Time when configuring RTEMS. There
32are example Ada programs with RTEMS configuration and startup sequences.
33
34Classic API Ada Bindings
35========================
36
37An Ada language binding exists for a subset of the RTEMS Classic
38API. In the early 1990's, there were C and Ada implementations of
39RTEMS which were functionally equivalent. The source structure was as
40similar as possible. In fact, the top level ``c/`` directory at one point
41had a sibling ``ada/``. The current Ada language bindings and test code was
42derived from that Ada implementation.
43
44The Ada binding specifically excludes some methods which are either not
45safe or not intended for use from Ada programs. However, methods are
46generally only added to this binding when a user makes a requests. Thus
47some methods that could be supported are not. If in doubt, ask about a
48methods and contribute bindings.
49
50The bindings are located in the ``c/src/ada`` directory of the RTEMS source
51tree. The tests are in ``c/src/ada-tests``.  The bindings following a simple
52pattern to map the C Classic API calls into Ada subprograms. The following
53rules are used:
54
55- All RTEMS interfaces are in the RTEMS Ada package.  The rtems\_ and
56  RTEMS\_ prefixes in the C version of the Classic API thus correspond to
57  "RTEMS." in Ada symbol nomenclature. For example, ``rtems_task_create()``
58  in C is ``RTEMS.Task_Create()`` in Ada.
59
60- Classic API directives tend to return an ``rtems_status_code``. Some
61  directives also have an output parameter such as an object id on a create
62  operation. Ada subprograms are either pure functions with only a single
63  return value or subprograms. For consistency, the returned status code
64  is always the last parameter of the Ada calling sequence.
65
66Caution should be exercised when writing programs which mix Ada tasks,
67Classic API tasks, and POSIX API threads. Ada tasks use a priority
68numbering scheme defined by the Ada programming language. Each Ada task
69is implemented in GNAT/RTEMS as a single POSIX thread. Thus Ada task
70priorities must be mapped onto POSIX thread priorities. Complicating
71matters, Classic API tasks and POSIX API threads use different numbering
72schemes for priority. Low numbers are high priority in the Classic
73API while indicating low priority in the POSIX threads API. Experience
74writing mixed threading model programs teaches that creating a table
75of the priorities used in the application with the value in all tasking
76models used is helpful.
77
78The GNAT run-time uses a priority ceiling mutex to protect its data
79structures. The priority ceiling value is one priority more important
80than the most important Ada task priority (in POSIX API terms). Do not
81invoke any services implemented in Ada from a thread or task which is
82of greater priority. This will result in a priority ceiling violation
83error and lead to a failure in the Ada run-time.
84
85Exercise extreme caution when considering writing code in Ada which
86will execute in the context of an interrupt handler. Hardware interrupts are
87processed outside the context of any thread in RTEMS and this can lead
88to violating assumptions in the GNAT run-time. Specifically a priority
89ceiling mutex should never be used from an ISR and it is difficult to
90predict when the Ada compiler or run-time will use a mutex.
91
92RTEMS has two capabilities which can assist in avoiding this problem. The
93Classic API Timer Manager allows the creation of Timer Service Routines
94which execute in the context of a task rather than the clock tick
95Interrupt Service Routine. Similarly, there is support for Interrupt Tasks
96which is a mechanism to defer the processing of the event from the
97hardware interrupt level to a thread.
Note: See TracBrowser for help on using the repository browser.