Solved

cond timewai

Posted on 2011-03-04
5
308 Views
Last Modified: 2012-05-11
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
Comment
Question by:learningunix
  • 3
  • 2
5 Comments
 
LVL 53

Expert Comment

by:Infinity08
ID: 35039379
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
 

Author Comment

by:learningunix
ID: 35039520
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
 

Author Comment

by:learningunix
ID: 35039530
or will it just wait until the other thread releases the lock and this can re-acquire?
0
 
LVL 53

Accepted Solution

by:
Infinity08 earned 250 total points
ID: 35039632
>> or will it just wait until the other thread releases the lock and this can re-acquire?

Correct.
0
 

Author Closing Comment

by:learningunix
ID: 35046544
got it
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now