The answer is that under certain conditions tasks can communicate through global data, and furthermore, in some situations, this technique is preferable. The techniques outlined here apply to threads only, since processes cannot share global data. For more information on threads and processes see the related article . Consider taskA and taskB. taskA reads analog data, scales it, and stores the scaled value in a global variable. The example above assumes that preemption cannot occur.
Preemption can occur when tasks run at different priorities or time-slicing is enabled.
If preemption is allowed, then communicating though global data can cause problems. Assume that the example above is running on an 8 bit microprocessor, on which 16 bit integers are composed of two bytes. Consider what happens when taskB is running at a higher priority and the 500 ms timer expires just after taskA writes out the first byte of GlobalData . Continuing with the scenario, taskB now preempts taskA and displays an invalid value. There are various ways to avoid the preemption problem for the example above.