In Chapter 3, applications running inside mobile devices were considered reactive. This, however, can be generalized to hold at the device level as well, since it is the device that is assumed to provide responses, not the applications only. Moreover, it is not solely applications that receive and respond to events, but it is a joint effort of several components of the device. These components can include hardware, low-level software directly associated with it, or some other piece of software.
As the result of the above, the software run inside a mobile device can in general be taken as an event handler, which simply responds to the events received from the outside world. Because the outside world behaves nondeterministically from the viewpoint of the device, the device must be enabled to react to several incoming requests at the same time. This calls for an implementation that respects this requirement, and allows concurrent response to several simultaneous incoming events.
The implementation mechanisms for concurrent programming are more or less standardized. As already discussed, threads and processes give boundaries for managing executions and resources. In addition, some mechanisms are available to ensure that several threads do not modify the same variables at the same time. In the following, we will address such issues in more detail.
When programming a system where some input is generated by the ...