5 Interprocess communication

 

In this chapter:

  • You learn how to achieve effective task communication
  • You learn how to choose a communication type for your applications
  • You learn a popular programming pattern for creating concurrent applications: a thread pool

We can’t always guarantee that concurrent tasks running on a computer are independent. Often, communication between tasks is necessary for efficient execution. For example, if one task depends on the result of another, the application has to know when to pause its work while it waits for the other task to finish.

Communication is therefore at the heart of any concurrent system. If we cannot ensure proper communication between tasks, the performance gains from concurrency are meaningless. In this chapter, you learn about the concepts provided by the OS to allow processes and threads to communicate and coordinate their work. We start by looking at the different types of communication you’re likely to encounter in a concurrent system.

Types of communication

The OS provides mechanisms allowing processes and threads to communicate with each other. These mechanisms are called interprocess communication (IPC). Once you decide that your application will benefit from IPC, you must decide which of the available IPC methods to use on your system.

Shared-memory IPC

Message-passing IPC

Thread pool pattern

Cracking passwords, revisited

Recap