Research on Controlling Concurrency in Real-Time Application (PART V)

Gabrelsoft
3 min readJun 25, 2023

Synchronization Technique PART

Synchronization is vital in a concurrent application that allows the coordination and execution of multiple threads or processes to ensure correct and predictable behavior. It involves controlling access to shared resources, managing the order of execution, and preventing race conditions. The synchronization technique enforces mutual exclusion, establishes communication channels, and maintains data integrity through the application. Effective synchronization techniques are vital to preventing race conditions, ensuring data consistency, and maintaining the correctness of concurrent programs. However, poor synchronization can lead to problems such as deadlocks, livelocks, and poor performance. Therefore, it's advised to be careful when implementing synchronization, a thorough design is necessary to strike a balance between concurrency and data integrity.

  • Mutual Exclusion — Mutual exclusion ensures that only one concurrent entity can access a shared resource at a time. This prevents data corruption or inconsistent results that can occur when multiple entities simultaneously modify shared data. Synchronization mechanisms like locks, mutexes, and semaphores are used to enforce mutual exclusion and ensure exclusive access to shared resources.
  • Critical Sections — Critical sections are portions of code that access shared resources and need to be executed atomically. Synchronization constructs such as locks or mutexes are used to protect critical sections, allowing only one concurrent entity to enter the critical section at a time. This prevents race conditions and maintains data consistency.
  • Thread Synchronization — Thread synchronization involves coordinating the execution of multiple threads to ensure proper order of operations, prevent data races, and establish dependencies between threads. Synchronization primitives like locks, condition variables, and barriers are used to synchronize thread activities, control thread execution, and enable communication and coordination between threads.

Synchronization Problem

Interaction between distributed sites can be thought of as the exchange of messages or execution events. An event goes through a number of stages in its existence, usually something like creation, local execution, transmission, reception, and remote execution. Without concurrency, events are executed locally on the user machine, when they are created. The summary of this is concurrency is a multi-way process, and events can be interleaved — out of order at various sites, which could lead to interference and inconsistencies.

Synchronization Sample

The diagram above shows how two sites lose synchronicity. At Site 1, it creates, executes, and transmits Event A at a time while Site 2 does the same with Event B.

Event A received and executed by Site 2 at t3, and Event B is later received and executed by Site 1 at time t4. At this point, site 1 has executed event A and then B, while the site may result in both sites being inconsistent and out of step. The different ordering of actions may result in both cases being inconsistent and out of step.

Problems will occur when the execution is not commutative, or when various local events are considered part of a local transaction operation that is vulnerable to attacks by other events unless these are treated separately.

Dropbox Synchronization

In locking, problems that arise, depend on the optimism scheme, while others are due to unique properties of serialization. Serialization ensures data integrity, but its leads to some strange interaction behaviors. In applications such as bitmap drawings, the interaction is so small that the individual may not even notice the effects of serialization.

The advantage, here is that document integrity is maintained. The diagram below illustrates this,

Sample Diagram

In Scene 1, both Gabriel and Davies grab the circle but have not yet moved it. In the next scene, Davies and Gabriel both move the circle, but Davies’s move is handled first. The circle moves left to Davies’s cursor location, Gabriel’s move is handled next(Scene 3), and the circle moves right to his cursor location. The place will be at the location of the last person to let go of it. While the overall behavior is serialized, it then leads to an interface tension where users can end up fighting over control of a shared object.

--

--