F_SETLK/F_SETLKW unsuitable for multithreaded programs ?
- From: Xavier Roche <xroche@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 05 Jul 2012 09:48:20 +0200
Hi folks!
Is fcntl(F_SETLK/F_SETLKW) supposed to be suitable for multithreaded applications ?
As nicely explained by Nelson Bolyard, many implementations (confirmed on Linux and Solaris 10 for example) are prone to false deadlock detection (https://bugzilla.mozilla.org/show_bug.cgi?id=62457)
To summarize the issue, if two programs are working on two separate files in their "main" thread, and then have an additional thread attempting to lock the peer's file (hence, having the two secondary threads blocked in both process until the primary threads have finished), the locking functions will return a spurious EDEADLK errno.
It is unclear whether this behavior is an implementation bug^Wchoice or a standard glitch.
http://pubs.opengroup.org/onlinepubs/7908799/xsh/fcntl.html
Note that alternate solutions are not very useful either:
* flock() is thread-unsafe (and even unavailable on Solaris)
* lockf() has no "shared" mode
.
- Follow-Ups:
- Re: F_SETLK/F_SETLKW unsuitable for multithreaded programs ?
- From: Rainer Weikusat
- Re: F_SETLK/F_SETLKW unsuitable for multithreaded programs ?
- Next by Date: F_SETLK/F_SETLKW unsuitable for multithreaded programs ?
- Next by thread: Re: F_SETLK/F_SETLKW unsuitable for multithreaded programs ?
- Index(es):
Relevant Pages
|