过程同步、数据同步。
In computer science, synchronization refers to one of two distinct but related concepts: synchronization of processes, and synchronization of data. Process synchronization refers to the idea that multiple processes are to join up or handshake at a certain point, in order to reach an agreement or commit to a certain sequence of action. Data synchronization refers to the idea of keeping multiple copies of a dataset in coherence with one another, or to maintain data integrity. Process synchronization primitives are commonly used to implement data synchronization.
The need for synchronization does not arise merely in multi-processor systems but for any kind of concurrent processes; even in single processor systems. Mentioned below are some of the main needs for synchronization:
Forks and Joins: When a job arrives at a fork point, it is split into N sub-jobs which are then serviced by n tasks. After being serviced, each sub-job waits until all other sub-jobs are done processing. Then, they are joined again and leave the system. Thus, in parallel programming, we require synchronization as all the parallel processes wait for several other processes to occur.
Producer-Consumer: In a producer-consumer relationship, the consumer process is dependent on the producer process till the necessary data has been produced.
Exclusive use resources: When multiple processes are dependent on a resource and they need to access it at the same time the operating system needs to ensure that only one processor accesses it at a given point in time.This reduces concurrency.
Classic problems of synchronization[edit]
The following are some classic problems of synchronization:
- The Producer–Consumer Problem (also called The Bounded Buffer Problem);
- The Readers–Writers Problem;
- The Dining Philosophers Problem.
These problems are used to test nearly every newly proposed synchronization scheme or primitive.
Synchronization in Linux[edit]
Linux provides:
- semaphores;
- spinlock;
- barriers
- mutex
- readers–writer locks, for the longer section of codes which are accessed very frequently but don't change very often.
- Read-copy-update (RCU) [12]
Enabling and disabling of kernel preemption replaced spinlocks on uniprocessor systems. Prior to kernel version 2.6, Linux disabled interrupt to implement short critical sections. Since version 2.6 and later, Linux is fully preemptive.
Synchronization in Solaris[edit]
Solaris provides:
- semaphores;
- condition variables;
- adaptive mutexes, binary semaphores that are implemented differently depending upon the conditions;
- readers–writer locks:
- turnstiles, queue of threads which are waiting on acquired lock.[13]
https://en.wikipedia.org/wiki/Synchronization_(computer_science)