Barrier is a type of a synchronization method which is used for synchronizing multiple processes. Many applications are divided to phases and they require that all processes should reach a particular phase at the same time. Individual processes should not pass the phase until all the processes have reached to that particular phase. To achieve this, a barrier is placed at the phase. This barrier stops processes from entering the next phase unless all the processes are ready. After a process reaches a phase, the barrier is executed by calling a library procedure and the process is blocked. Then, one by one each process executes the barrier and is blocked. When they have all executed the barrier routine, they are released to pass along the next phase.
In the below given figure, Process 3 has finished the execution and is blocked by the barrier. It has to wait until Process 1 and Process 2 will finish executing and blocked. Once all the three processes are blocked, they will be released simultaneously.