[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 339
  • Last Modified:

cond timewai

int cond_timedwait(cond_t *cond, mutex_t *mutex, timestruc_t *abstime);

cond_timedwait automatically releases the mutex, and waits on the condition variable cond. When the condition is signaled or the time expires, cond_timedwait reacquires the mutex and returns to the caller.

What if after time expires, the mutex is locked by some other process?  in that case cond_timedwait  will not be able to re-acquire the mutex?
0
learningunix
Asked:
learningunix
  • 3
  • 2
1 Solution
 
Infinity08Commented:
If the timeout expires, cond_timedwait will re-acquire the mutex, and return ETIME.

This information should be listed in the man page for cond_timedwait.
0
 
learningunixAuthor Commented:
I understand but what if that mutex is already acuired by some other thread while this was waiting.
The time expires now if it tries to acquire the lock shouldn't that fail? how do we can confirm that?
0
 
learningunixAuthor Commented:
or will it just wait until the other thread releases the lock and this can re-acquire?
0
 
Infinity08Commented:
>> or will it just wait until the other thread releases the lock and this can re-acquire?

Correct.
0
 
learningunixAuthor Commented:
got it
0

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now