Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update API to support process shared condvar use cases #23

Merged
merged 2 commits into from
Jan 30, 2020

Conversation

gratian
Copy link
Collaborator

@gratian gratian commented Jan 22, 2020

As described in issue #22 the current API breaks down for for process shared condvar use cases. Fix this by changing the API to pass in the associated mutex where it is needed instead of at init time.

The current librtpi conditional variable API has the user pass a
pointer to the associated mutex at pi_cond_init() time and it is
stored in the condvar private data for later use when waiting or
signaling.

As described in issue dvhart#22[1] this breaks down for process shared use
cases. In those cases the associated mutex is mapped at different
addresses in different processes so the pointer passed by one process
to pi_cond_init() will not be valid in the context of another process
doing operations on the shared condvar.

Change the API to pass in the associated mutex where it is needed
instead of at init time:

  * pi_cond_wait(), pi_cond_timedwait() - mutex used in the
    FUTEX_WAIT_REQUEUE_PI futex call. Passing in a pointer to the
    associated mutex as a parameter matches the equivalent
    libpthread/POSIX APIs.

  * pi_cond_signal(), pi_cond_broadcast() - mutex used in the
    FUTEX_CMP_REQUEUE_PI futex call as the requeue target in order to
    avoid "thundering herd" wake-ups.

[1] dvhart#22

Signed-off-by: Gratian Crisan <[email protected]>
Commit 6814992 ("pi_cond: Update API to support process shared
condvar use cases") introduced an API change in order to address issue
"dvhart#22 Current librtpi API breaks down for process shared condvars"[1].

Make the necessary changes to port all tests to the new API:

  - remove the mutex parameter when initializing the condvar:
    DEFINE_PI_COND(), pi_cond_init().

  - pass a pointer to the associated mutex for pi_cond_wait(),
    pi_cond_timedwait(), pi_cond_signal(), and pi_cond_broadcast()
    calls.

[1] dvhart#22

Signed-off-by: Gratian Crisan <[email protected]>
@dvhart
Copy link
Owner

dvhart commented Jan 30, 2020

These all look inline with what we discussed. Thank you for seeing this through Gratian.

@dvhart dvhart merged commit 37a96aa into dvhart:master Jan 30, 2020
@gratian gratian deleted the api-change branch June 17, 2020 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants