In programming , process synchronization (or simply synchronization for short ) means the coordination of the timing of several concurrent processes or threads . It does not matter whether it is threads in a program, programs on a computer or processes in a distributed system that communicate over a network .
The purpose of coordination is usually one of the following:
- Shared access to data . It must be prevented that inconsistencies in the data arise through simultaneous access . This is implemented using mutex processes for mutual exclusion.
- Sharing limited resources such as peripheral devices . Mutex methods can also be used here, but more complex methods of scheduling are often required.
- Transfer of data or messages from one process to another, i.e. interprocess communication .
- Control of sub-processes through signals , especially aborting processes or waiting for them to terminate.
The synchronization of the processes now consists in the fact that, in general, one process has to wait for an event that is triggered by another. It is the job of the scheduler to implement the resulting causal dependencies in such a way that a process only gets computing time if all the necessary conditions are met. Specifically, this is usually solved by the classic control mechanisms such as locks , semaphores and monitors .
The dependencies between the processes can be modeled formally using a Petri net , for example . A typical problem in this context is that processes can get jammed if circular dependencies are formed - this becomes clear , for example, with the problem of the dining philosophers . Another prototypical problem is the control of a producer / consumer system .
- James H. Anderson, Yong-Jik Kim, Ted Herman: Shared-memory mutual exclusion: major research trends since 1986 . In: Distrib. Comput. tape 16 , no. 2-3 . Springer-Verlag, September 2003, ISSN 0178-2770 , p. 75-110 , doi : 10.1007 / s00446-003-0088-6 .
- M. Raynal, D. Beeson: Algorithms for mutual exclusion . MIT Press, Cambridge MA 1986, ISBN 0-262-18119-3 .