Explain a sample example of concurrency issue ?

 Concurrency (or synchronization) issue which may appears when we are failed to use the synchronization mechanism properly in our code to prevent the race condition's between two or more threads of execution for one or more commonly shared resource's.
 For example, below type of potential problem will appears when we miss to release locks (which are already held in certain code) after usage, that will result the deadlock situation
 
Consider the following example to understand more:
spin_lock(&mylock); /* Acquire lock */
/* ... Critical Section ... */
if (error) { /* This error condition occurs rarely */
 return -EIO; /* Forgot to release the lock! */
}
spin_unlock(&mylock); /* Release lock */
 
 After the error condition occurrence, any thread trying to acquire mylock leads to deadlock situation and kernel might freeze.


Previous Post Next Post

Contact Form