Re: problem with pthread_mutex_timedlock
- From: Larry Smith <lsmith@xxxxxxxxxx>
- Date: Thu, 23 Nov 2006 01:18:52 GMT
Hans Juergen Gamauf wrote:
Hello,
I want to use this function to lock a resource, but with a timeout
and that is the problem, the function returns immediately after calling,
and if the lock was not free, it returns the error code 110, but I have
no idea what this error code means, I've found nothing in the man-pages
or anywhere else
Can anyone help me?
I'm using 2.6.15 under a special glibc/busybox distribution for an
arm9-core, but I have the same effect under Kubuntu 6.06
here is my code:
-------------------------------------
struct timespec deltatime;
deltatime.tv_sec = 3;
deltatime.tv_nsec = 0;
int err_code = pthread_mutex_timedlock(
&_mutexLogfile, &deltatime );
if (err_code != 0)
{
cout << "Locking returns " << err_code << endl;
THROW_EX("Logfile Mutex locked!");
}
---------------------------------------
Thank you in advance!
Hans
The timeout is an 'absolute time', not a relative time (per
the 'man' page).
So you want the current time + 3 seconds in the timer.
.
- References:
- problem with pthread_mutex_timedlock
- From: Hans Juergen Gamauf
- problem with pthread_mutex_timedlock
- Prev by Date: problem with pthread_mutex_timedlock
- Next by Date: Looking for a extensible shell for debug purpose
- Previous by thread: problem with pthread_mutex_timedlock
- Next by thread: Re: problem with pthread_mutex_timedlock
- Index(es):
Relevant Pages
|