Section 13.5 - Other Tasking Issues
The underlying operating system does affect tasking,
particularly if the operating system does not provide
certain minimal capabilities (i.e. thread support).
Here are two effects that you need to be aware of:
Some operating systems (such as Microsoft Windows 3.1 and many older
Unixes) do not support threads (lightweight processes), but instead
only support regular processes (sometimes called heavyweight processes).
The difference is that threads can share memory, while processes
generally do not.
On systems which do not support threads,
if any task makes an operating system request
(say, to get input), all the Ada tasks are usually halted until the
operating system completes the request.
This is because most Ada compilers in such environments put all of the
Ada tasks into a single operating system process and then simulate
the tasking inside the process.
The operating system can't distinguish
between the different Ada tasks in the single process,
so all Ada tasks get stopped.
As more operating systems become more capable this is becoming
less of a problem, and this is generally not a problem for
embedded systems (where Ada has complete control over the system
or is running on a real-time operating system).
Some operating systems make it difficult or inefficient to automatically
share time between tasks.
The ability to automatically share time between tasks of equal
priority is called ``pre-emptive multitasking'' or ``time slicing''.
Operating systems that support
pre-emptive multitasking are more convenient for programmers.
Because some operating systems don't support it well,
an Ada compiler is permitted to keep running one
task until that task tries to communicate with another task or waits
(using the delay statement).
This kind of behavior is called "cooperative multitasking", because
tasks of equal priority must cooperate to share the CPU.
Most people prefer Ada implementations that have
If you have to deal with an Ada compiler that only supports cooperative
multitasking, consider inserting "delay 0.0" statements in each task
in various places to give other tasks a chance to run.
Check your compiler documentation; some compilers permit you to choose
between pre-emptive and cooperative behavior.
Again, most of today's Ada compilers provide the (more general)
pre-emptive multitasking behavior.
There's much more about tasking that Lovelace doesn't cover.
You can create tasks that exist for as long as the program runs, by
declaring the task in a package declaration or body (the same
way you can declare a global variable).
Instead of creating a task type and then a task, you can create a task
Entries are queued in first-in-first-out order, and can be re-queued
There is no quiz question for this section.
You may go to the next section.
You may also:
David A. Wheeler (email@example.com)
The master copy of this file is at