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 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 preemptive multitasking. 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. For example:


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 (dwheeler@dwheeler.com)

The master copy of this file is at "http://www.adahome.com/Tutorials/Lovelace/s13sf.htm".