Fair Spinlock via Secondary Contention Variable
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing spinlock mechanisms in multicore systems suffer from unfairness due to cache coherence protocol delays (Delay_CCP) and power-saving optimizations (Delay_PSO), leading to performance degradation and inefficient resource utilization, as one core consistently gains an advantage over others in acquiring the spinlock.
Innovation Solution
The introduction of a secondary variable (WAIT) or contention indication variable, which is set on a separate cache line from the spinlock variable, and updating this variable upon spinlock release to ensure equal invalidation across all cores, mitigates the unfairness by balancing the number of INVALID variables across winner and loser cores, thereby providing fair access to the spinlock.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If a traditional spinlock mechanism is used in a multicore system, then the spinlock acquisition process is simple and direct, but one core consistently gains an unfair advantage over others due to cache coherence protocol delays and power-saving optimizations
Solution Approach 1:
The spinlock variable is divided into two separate variables: a primary spinlock variable and a secondary contention variable. Each variable is stored on a separate cache line, allowing independent management of lock acquisition and contention detection. This segmentation enables the system to track which cores have attempted to acquire the lock, thereby preventing the unfair advantage that occurs when a single core consistently wins due to cache coherence delays.
Solution Approach 2:
A secondary contention variable is introduced as an intermediary mechanism to detect and manage spinlock contention fairly. When a core fails to acquire the primary spinlock, it checks the secondary variable to determine if other cores are also contending. This intermediary structure enables fair arbitration by ensuring all contending cores are aware of each other's presence, preventing any single core from monopolizing the lock due to timing advantages.
2Stability of the object's composition
If cache coherence protocol is implemented to maintain consistency across cores, then data consistency is ensured, but delay is introduced that gives the winner core an unfair advantage in subsequent spinlock acquisitions
Solution Approach 1:
Before attempting to acquire the primary spinlock, cores perform preliminary actions by checking and potentially setting the secondary contention variable. This preliminary action allows contending cores to register their presence in advance, so when the spinlock becomes available, all contending cores have an equal opportunity to acquire it simultaneously, eliminating the timing advantage that would otherwise result from cache coherence delays during the actual lock acquisition.
3Use of energy by moving object
If power-saving optimizations like Wait for Event are used to avoid busy spinning, then energy consumption is reduced, but additional delay is caused that further exacerbates the unfairness to the winner core
Solution Approach 1:
The secondary contention variable serves as a feedback mechanism that provides information to contending cores about the presence of other competitors. When a core enters a power-saving wait state, it can periodically check the secondary variable to determine whether the spinlock has become available or if other cores are still contending. This feedback enables cores to make informed decisions about when to wake from wait states, ensuring fair access while minimizing unnecessary energy consumption from continuous busy spinning.
Data Source
AI summary
Disclosed herein is a method for providing a fair access to a spinlock to one or more cores in a multicore system. The method includes setting, a spinlock variable by the first core of the one or more cores. The setting of the spinlock variable corresponds to changing a cache state of the spinlock variable in a cache of the first core to MODIFIED. Further, the method includes setting a secondary variable by the second core of the one or more cores. The setting of the secondary variable corresponds to changing a cache state of the secondary variable in a cache of the second core to MODIFIED. Furthermore, the method includes releasing, by the first core, the spinlock after performing one or more operations on the critical section of data. Furthermore, the method includes updating, by the first core, the INVALID secondary variable.


