WaitSet Spurious Wakeup

2 posts / 0 new
Last post
Offline
Last seen: 3 years 3 days ago
Joined: 02/06/2020
Posts: 4
WaitSet Spurious Wakeup

While using the traditional C++ API, is the WaitSet vulnerable to spurious wakeups?

The traditional C++ API documentation does not seem to address this, but the modern C++ API however, has an additional class called AsyncWaitSet. A quote from it's documentation:

"This mechanism ensures not only unexpected concurrent dispatch of a dds::core::cond::Condition but also spurious thread activity."

Does this imply that the regular WaitSet (at least the one available in the traditional C++ API) does not have the same guard against spurious wakeups?

Keywords:
asanchez's picture
Offline
Last seen: 4 years 6 months ago
Joined: 11/16/2011
Posts: 50

Hello,

Note that the AsyncWaitSet differs from the WaitSet in that it runs in one or more separate threads. The WaitSet is a synchronous API and it's responsibility of your application to provide the thread that calls wait() on it. In that sense, it's your application's responsibility to manage sprious thread activity. Calling wait() on WaitSet that has active conditions attached will always return immediately. The AsyncWaitSet has implemented a mechanism to deal with this behavior to guarantee a condition being dispatched can remain active yet making sure remaining threads in the AsyncWaitSet's pool don't wake up spuriously. 

- Antonio