Synchronization (computer science)

过程同步、数据同步。

In computer sciencesynchronization refers to one of two distinct but related concepts: synchronization of processes, and synchronization of dataProcess 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:

These problems are used to test nearly every newly proposed synchronization scheme or primitive.

Synchronization in Linux[edit]

Linux provides:

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:

https://en.wikipedia.org/wiki/Synchronization_(computer_science)

原文地址:https://www.cnblogs.com/feng9exe/p/8352668.html