title: sem_timedwait() for specific time
body: <p>i Want to wait on semaphore for 20 mili-secound as below,but when i am printing values of tv_sec and tv_nsec getting very big values.</p>
  
  <p>Can anybody will help to understand this below code.</p>
  
  <pre><code>if (clock_gettime(CLOCK_REALTIME, &amp;ts) == -1)
      {
          //throw error
      }
  ts.tv_nsec += 20000000;
  ts.tv_sec += ts.tv_nsec / 1000000000;
  ts.tv_nsec %= 1000000000;
  
  sem_timedwait(&amp;semaphore, &amp;ts)
  </code></pre>