Re: [RFA/Ada] Implement Ada tasking support

Eli Zaretskii
2008-09-23T03:20:13Z

> Date: Mon, 22 Sep 2008 16:32:09 -0700
> From: Joel Brobecker <brobecker@adacore.com>
>
> Following our re-design of the ada-tasks module a while back to be
> submittable, I think it is now time to contribute this code.
>
> Ada is one of these languages that includes tasking constructions
> built in to the language. While in C we use a thread library,
> in Ada, we use what is called "tasks". What this new module provides
> is support for examining these tasks:
>
> 1. Getting the list of tasks and their current state
> 2. Switching from task to task
>
> (1) is achieved by poking into an array in the GNAT Tasking runtime
> named System.Tasking.Debug.Known_Tasks. We rely on the debugging
> information to find how the Ada Task Control Block structure is
> laid out, and get the pieces of info that we are looking at.
> This part requires a little bit of code, particularly since
> we try to accomodate maybe older versions of the GNAT runtime too.
> But the code itself isn't very complicated. Just walking through
> the type structures, and storing the information in a list of our
> own.
>
> (2) is a little more tricky - basically, what we need to do is relate
> the information in each Ada Task Control Block (ATCB) back to
> the associated thread. In practice, there are two fields, the
> "thread" field, and the "LWP" field that we can use, whose content,
> meaning and even availability depends on the target, and transform
> that into the ptid of the corresponding thread. The good news is
> that we know fairly well, for each target, what to use and how,
> in order to get that ptid. So this strongly suggested a target
> method.

I have a few general questions about this:

What is the differences, if any, between threads Ada tasks?

Would it make sense to make the existing threads commands to refer to
Ada tasks, instead of introducing a whole new bunch of commands?

Finally, if we do decide to have these new task commands, are there
any other languages which could, at least in principle, benefit from
the same feature for similar reasons, or is Ada the only one?

Thanks.