Solved

cond timewai

Posted on 2011-03-04
5
315 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
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.

813 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

11 Experts available now in Live!

Get 1:1 Help Now