How to add the Idle task to Ada runtime

Jan Sommer soja-misc at aries.uberspace.de
Thu Aug 20 20:30:07 UTC 2015


Am Sonntag, 16. August 2015, 12:23:44 schrieb Jérôme Hugues:
> Hi,
> 
> Le 16 août 2015 à 11:58, Jan Sommer <soja-misc at aries.uberspace.de> a écrit :
> 
> > I checked the *_attr_t-types and as far as I see there is only a minor update to pthread_rwlockattr_t necessary (but the size stayed the same).
> > I also added the missing fields to pthread_attr_t in ada, but I don't know how to declare the cpu_set_t in Ada
> 
> Since the Ada runtime for RTEMS uses POSIX, you may use other implementations as template, see
> 	https://gcc.gnu.org/git/?p=gcc.git;a=blob_plain;f=gcc/ada/s-osinte-linux.ads;hb=876d41ed80ce13e060084ed5a552c37c301e5563
> 
> (Note I used GCC 4.9.3 as baseline, I would recommend you check the version of your RTEMS toolset)
> 
> > Question is how can I reference _NCPUWORDS in the ada file?
> 
> Usual trick is to wrap such macros in a C function, and export it to Ada. This will not work here because it is a type definition. If you review Adacore implementation, they use a default value. I do not know whether this is OK or not
> 

I added a constant with the which has the array length to cpuset.h

extern const size_t LAST_CPUWORD_INDEX;

and to cpusetalloc.c: 

const size_t LAST_CPUWORD_INDEX = _NCPUWORDS - 1;

Then I was able to import the constant into Ada in the s-osinte-rtems.ads-file, use it to declare the array and add it to the record type for pthread_attr_t.
It compiles for me and there is no stack corruption after the call to pthread_attr_init anymore. Would this be an acceptable solution?

The program still stops working somewhere else, but at least the task setup seem to work properly now (I will have to take a look at the teardown then).

> > 
> >> I had another thought which I don't recall if I posted or not. I vaguely 
> >> recall
> >> that the Ada init task is supposed to be the lowest Ada priority and
> >> preemptible. When elaboration creates an Ada task, that new task
> >> should preempt the Ada task. I suspect the Ada init task is running through
> >> the Ada code before the created Ada tasks even get a chance to run and
> >> register their existence with the run-time.
> 
> No, you have to set it to lowest priority, see
> 	https://www2.adacore.com/gap-static/GNAT_Book/html/aarm/AA-D-1.html
> 
> If a pragma Priority does not apply to the main subprogram, the initial base priority of the environment task is System.Default_Priority. 
> 
> It is the designer responsibility to set it to Priority'First
> 
> Regards,
> 
>> Jerome HUGUES
> Enseignant-Chercheur/Associate Professor 
> Ingénierie des Systèmes Embarqués/Embedded Systems Engineering
> 
> ISAE SUPAERO - Institut Supérieur de l'Aéronautique et de l’Espace
> 10 avenue Edouard Belin - BP 54032 - 31055 TOULOUSE CEDEX 4 FRANCE - http://www.isae-supaero.fr 
> Tel (+33) 5 61 33 89 84 - Fax (+33) 5 61 33 83 30
> Plan d'accès/Access map
> 


More information about the users mailing list