title: Adding a semaphore retry login in my code
body: <h2>Current scenario</h2>
  
  <p>I am having a binary semaphore and I am doing some operations on a variable before doing that I am acquiring semaphore lock(its non blocking semaphore) and if some other process or say thread wants to acquire it, it will fail saying semaphore timed out. </p>
  
  <h2>Want to implement</h2>
  
  <p>A retry mechanism wherein if semaphore lock fails because of time out it will call my retry mechanism where I am planning to retry if lock has failed with 1 second delay and 5 retries.</p>
  
  <p>My question is what does semaphore lock returns and below is my approach </p>
  
  <pre><code>errorhandl semretry(){
      int count =5;
      errorhandl err = NULL;
      do{
          err = semaphore.lock(); // &lt;&lt;&lt; to me it looks that err will always be NULL
          if(semaphore.timeout()) {
              sleep (1);
              count --;
          }
      }while(count &gt; 0);
  }
  </code></pre>
  
  <p>Any suggestion on this approach. I want to do more on this on the basis of lock is acquired or not. Please suggest what else can be done.</p>