Solved

cond timewai

Posted on 2011-03-04
5
322 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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.

752 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