Has anyone implemented a mutex with a timeout?
Has anyone implemented a mutex locking function on top of Solaris or POSIX threads with a timeout? The problem I’m trying to solve is if a thread is unable to obtain a mutex after a certain timeframe (say 30 seconds), then I want the thread to terminate and return an error. The Solaris and POSIX API’s only allow the user to check if a mutex can be obtained. Of course! Check out the code for pthread_np_timed_mutex_t at http://www.lambdacs.com/jan-97/examples.html =================================TOP=============================== Q66: I think I need a FIFO mutex for my program… >There are VERY few cases where “lock ordering” is truly necessary. In >general, when it may seem to be necessary, using a work queue to distribute >the work across a pool of threads will be easier and more efficient. If >you’re convinced that you need lock ordering, rather than POSIX wakeup >ordering, you have to code it yourself — using, essentially, a work queue >model where threads wishing to lock your “qu