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:
  1. 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).
  2. Some operating systems make it difficult or inefficient to share time between tasks. This is called ``time slicing''. Because of this, 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 a "preemptive time-slicing multitasking" system, where tasks of equal priority are forced to share the CPU. 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 time-slicing or cooperative behavior. Again, most of today's Ada compilers provide the (more general) time-slicing multitasking behavior.

There's much more about tasking that this version of Lovelace doesn't cover. For example:

If you're already familiar with tasking, please feel free to volunteer to extend this lesson!


There is no quiz question for this section.

You may go to the next section.


You may also:

PREVIOUS Go back to the previous section

OUTLINE  Go up to the outline of lesson 13

David A. Wheeler (wheeler@ida.org)