Operating Systems of Mobile Devices (OSMZ)

Week IV. (1.3.-5.3.2021)

Let's have a look at IPC mechanisms as the use of one of them, a semaphore, occurs in the implementation task assigned last week. This is one of the IPC methods (Inter-Process Communication), which we will deal with in more detail. Interprocess communication is a set of techniques for exchanging data between two or more processes or threads. In our implementation tasks, we focus only on inter-threaded communication, however, these mechanisms are general and applicable equally between processes. In the presentation you will find a list of the most used methods. The table basically copies the one you find with links on Wikipedia

Since you will be using a semaphore in your implementation, let's describe it in more detail. A semaphore is a simple synchronization tool, essentially just a counter for allocating (counting) resources. Therefore, the following things can be done with it: Find out the current semaphore value (availablePermits() on Android). If the internal value of the semaphore is positive, the process / thread can use the resource. It decrements the value of the semaphore by 1 (or another passed value) by calling acquire() method. If the internal value of the semaphore is 0, or would fall below that value using the acquire method with an argument, the thread is blocked until the resources are released and the semaphore becomes positive. Releasing resources is done by the release() method. You can also use the tryAcquire() method to verify that the resource is available in the required number and do not want to invoke a blocking behavior. If successful, it removes the corresponding number of permits, returns true and behaves the same as acquire, but when there is a lack of resources, it does not block as acquire() and only returns a return value false.

The following classic problems are used to demonstrate synchronization problems and solve them through IPC mechanisms (you don't have to know them in detail, just be able to summarize what type of problem it is):

The Android SDK (project demos) includes solutions to most of these problems.



Andrew S. Tanenbaum - Modern operating systems. 4th edition:

  • Chapter 2.3 Inter-Process Communication (pp. 119 - 146)
  • Chapter 2.5 Classic IPC Problems (pp. 167 - 169)
  • Chapter 6.7 Miscellaneous Problems (pp. 458 - 463)


Problem with the scheduler and IPC in the Pathfinder software on Mars. Concurrency problem with the Therac-25 radiology device with several dozen affected patients.


After reading the above texts, you should be able to answer following questions from the topics for the exam, specifically:

  • Explain the concept of interprocess communication (IPC) and give some examples of IPC methods.
  • Explain the term race condition, when it occurs and how it can be prevented.
  • Explain the term semaphore, operation, example of use.