Re: problem with pthread_mutex_timedlock



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.

.



Relevant Pages

  • problem with pthread_mutex_timedlock
    ... 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 ...
    (comp.os.linux.development.apps)
  • Re: New "timeout" api, to replace callout
    ... Timer expires on active session but source of timer was just ... time has expired and it is ready to run, once its lock gets freed. ... disable or cleanup the timeout. ...
    (freebsd-arch)
  • Re: Resolving race conditions with callbacks and cancellation?
    ... callback could be called after cancel call completes. ... The callback must be to the state-machine inside the lock. ... The state is 'Eidle' and so this event causes an action routine to be called that changes the object SM state to 'EreadWithTimeout', stores N inside the object, queues the object to the timeout thread, unlocks the SM and makes the read call, where the thread driving the object gets blocked. ...
    (comp.programming.threads)
  • Re: New "timeout" api, to replace callout
    ... only ever grab the specified lock when it calls the timeout function. ... My plan is to use non-blocking grabs of the timeouts lock to get ... When a timeouts timer expires, the thread that services the timeouts ...
    (freebsd-arch)
  • runqueue locks in schedule()
    ... timers as the interface to allow timeout-based event set multiplexing. ... timeout measures virtual ... to reinstall the timer. ... On all architectures, but IA-64, it seems thet the runqueue lock is ...
    (Linux-Kernel)