Boost C++ Libraries: Ticket #6058: semaphore_timed_wait() behaviour inconsistent with glibc sem_timedwait() https://svn.boost.org/trac10/ticket/6058 <p> What should boost::interprocess::interprocess_semaphore::timed_wait(abs_time) return when the absolute time it is given, is in the past, but the semaphore is available? </p> <p> The boost documentation in interprocess_semaphore.hpp is not very clear, but it does suggest that it should return true. </p> <p> The implementation in semaphore_wrapper.hpp does the following: </p> <p> If BOOST_INTERPROCESS_POSIX_TIMEOUTS is defined, sem_timedwait() is called from semaphore.h. If the macro is not defined, it will use its own implementation, which first looks at the time, and will thus return false in this case. This is in contradiction with the documentation. </p> <p> sem_timedwait in semaphore.c, however, will first try to acquire the lock, and if it could not get a lock, look at the time. Thus the end result will be true, which is inconsistent with the boost version. </p> <p> Please note that the POSIX documentation is unclear on this topic too, so the semaphore.c implementation might vary from system to system. I am talking about the GNU version. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6058 Trac 1.4.3 kees-jan.dijkzeul@… Thu, 27 Oct 2011 13:38:24 GMT cc set https://svn.boost.org/trac10/ticket/6058#comment:1 https://svn.boost.org/trac10/ticket/6058#comment:1 <ul> <li><strong>cc</strong> <span class="trac-author">kees-jan.dijkzeul@…</span> added </li> </ul> Ticket Ion Gaztañaga Fri, 23 Dec 2011 13:07:38 GMT <link>https://svn.boost.org/trac10/ticket/6058#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6058#comment:2</guid> <description> <p> I think your questions means a bug in Interprocess. According to </p> <p> <a class="ext-link" href="http://pubs.opengroup.org/onlinepubs/000095399/functions/sem_timedwait.html"><span class="icon">​</span>http://pubs.opengroup.org/onlinepubs/000095399/functions/sem_timedwait.html</a> </p> <p> "Under no circumstance shall the function fail with a timeout if the semaphore can be locked immediately. The validity of the abs_timeout need not be checked if the semaphore can be locked immediately" </p> <p> The implementation should not check the timeout before trying to lock the semaphore </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ion Gaztañaga</dc:creator> <pubDate>Wed, 18 Jan 2012 20:50:02 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/6058#comment:3 https://svn.boost.org/trac10/ticket/6058#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Implementation changed in Trunk and Release branches, so that a lock try is performed before checking the timeout. </p> Ticket