Content deleted Content added
m Dating maintenance tags: {{Cn}} |
Maybe change (here; and at target) to read–copy–update with ndashes (since correct English for AND). Not done; for now, in ASCII contexts (e.g. in actual code?) hyphens would be used. |
||
Line 4:
In [[computer science]], '''synchronization''' refers to one of two distinct but related concepts: synchronization of [[Process (computer science)|processes]], and synchronization of [[Dataset|data]]. ''Process synchronization'' refers to the idea that multiple processes are to join up or [[Handshaking|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:
''[[
''[[Producer–consumer problem|Producer-Consumer:]]'' In a producer-consumer relationship, the consumer process is dependent on the producer process till the necessary data has been produced.
Line 82:
The [[.NET Framework]] has synchronization primitives. "Synchronization is designed to be cooperative, demanding that every thread or process follow the synchronization mechanism before accessing protected resources (critical section) for consistent results." In .NET, locking, signaling, lightweight synchronization types, spinwait and interlocked operations are some of mechanisms related to synchronization.<ref>{{cite web|title=Synchronization Primitives in .NET framework|url=http://msdn.microsoft.com/en-us/library/ms228964%28v=vs.110%29.aspx|website=MSDN, The Microsoft Developer Network|publisher=Microsoft|access-date=23 November 2014}}</ref>
===
====
{{Main article|Spinlock}}
Another effective way of implementing synchronization is by using spinlocks. Before accessing any shared resource or piece of code, every processor checks a flag. If the flag is reset, then the processor sets the flag and continues executing the thread. But, if the flag is set (locked), the threads would keep spinning in a loop and keep checking if the flag is set or not. But, spinlocks are effective only if the flag is reset for lower cycles otherwise it can lead to performance issues as it wastes many processor cycles waiting.<ref>{{Cite book|title=Embedded Software Development with ECos|last=Massa|first=Anthony|publisher=Pearson Education Inc|year=2003|isbn=0-13-035473-2}}</ref>
====
{{Main article|Barrier (computer science)}}
Barriers are simple to implement and provide good responsiveness. They are based on the concept of implementing wait cycles to provide synchronization. Consider three threads running simultaneously, starting from barrier 1. After time t, thread1 reaches barrier 2 but it still has to wait for thread 2 and 3 to reach barrier2 as it does not have the correct data. Once all the threads reach barrier 2 they all start again. After time t, thread 1 reaches barrier3 but it will have to wait for threads 2 and 3 and the correct data again.
Line 102:
Experiments show that 34% of the total execution time is spent in waiting for other slower threads.<ref name=":0" />
====
{{Main article|Semaphore (programming)}}
Semaphores are signalling mechanisms which can allow one or more threads/processors to access a section. A Semaphore has a flag which has a certain fixed value associated with it and each time a thread wishes to access the section, it decrements the flag. Similarly, when the thread leaves the section, the flag is incremented. If the flag is zero, the thread cannot access the section and gets blocked if it chooses to wait.
Line 108:
Some semaphores would allow only one thread or process in the code section. Such Semaphores are called binary semaphore and are very similar to Mutex. Here, if the value of semaphore is 1, the thread is allowed to access and if the value is 0, the access is denied.<ref>{{Cite book|title=Real-Time Concepts for Embedded Systems|last=Li, Yao|first=Qing, Carolyn|publisher=CMP Books|year=2003|isbn=978-1578201242}}</ref>
===
Synchronization was originally a process-based concept whereby a lock could be obtained on an object. Its primary usage was in databases. There are two types of (file) [[File locking|lock]]; read-only and read–write. Read-only locks may be obtained by many processes or threads. Readers–writer locks are exclusive, as they may only be used by a single process/thread at a time.
Line 122:
====Synchronization in Windows====
[[Windows]] provides:
* [[
* [[spinlock]]s, which prevent, in multiprocessor systems, spinlocking-thread from being preempted;
* [[dynamic dispatch]]ers{{cn|date=June 2022}}, which act like [[mutual exclusion|mutex]]es, [[Semaphore (programming)|semaphores]], [[Event (computing)|event]]s, and [[timer]]s.
Line 128:
====Synchronization in Linux====
[[Linux]] provides:
* [[
* [[spinlock]];
* [[barrier (computer science)|barrier]]s;
* [[mutual exclusion|mutex]];
* [[readers–writer lock]]s, for the longer section of codes which are accessed very frequently but don't change very often
* [[
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.
Line 153:
* [[barrier (computer science)|barrier]]s.
==Data synchronization
{{
[[File:Data Synchronization.png|thumb|'''Figure 3: '''Changes from both server and client(s) are synchronized.]]
Line 175:
* performance.
====
Data formats tend to grow more complex with time as the organization grows and evolves. This results not only in building simple interfaces between the two applications (source and target), but also in a need to transform the data while passing them to the target application. [[Extract, transform, load|ETL]] (extraction transformation loading) tools can be helpful at this stage for managing data format complexities.
Line 187:
Data quality is another serious constraint. For better management and to maintain good quality of data, the common practice is to store the data at one ___location and share with different people and different systems and/or applications from different locations. It helps in preventing inconsistencies in the data.
====Performance====
There are five different phases involved in the data synchronization process:
* [[data extraction]] from the source (or master, or main) system;
|