InterProcess Communication, allows processes to communicate and synchronize actions

Shared memory vs message massing

Shared memory synchronization #

Race conditions: when two or more processes are reading/writing shared data and the final result depends on who runs precisely when (infamously hard to debug) Critical region: the part of the program where the shared memory is accessed is called.

Mutual exclusion: a method where only one process can access a shared variable/file (other processes are excluded).

Busy waiting: continuously testing a variable until it changes. A spin lock is a lock that uses busy waiting.

Atomic Hardware instructions: TSL Instruction : (Test and Set Lock) XCHG Instructions : exchanges contents of to locations atomically (on Intel x86 CPUs)

Mutex lock: critical sections protected by acquire and release operations which are atomic. Only one processes can access the critical region at the same time and the others block.

Semaphore: an integer variable used for synchronization which uses the following two atomic operations:

  • wait (Proberen): blocks while <= 0 until it can atomically decrease the variable by one
  • signal (Verhogen): atomically increases the value to signal that it can be used A binary semaphore is the same as a mutex lock

Monitors: abstract data type making synchronization possible. Has contition variables which are queues, which can be waited or signals.

Message passing #

  • Uses operating system functions like pipes or Unix sockets.
  • Uses send and receive operations
  • Distributed systems introduce problems like message loss and authentication.