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

Add abstraction for condition variables #1252

Closed
jphickey opened this issue May 9, 2022 · 1 comment
Closed

Add abstraction for condition variables #1252

jphickey opened this issue May 9, 2022 · 1 comment
Assignees
Milestone

Comments

@jphickey
Copy link
Contributor

jphickey commented May 9, 2022

Is your feature request related to a problem? Please describe.
POSIX condition variables can be useful for implementing worker thread pools, allowing worker task(s) to pend for work and dispatcher/manager tasks to unblock those workers once a job becomes available.

Describe the solution you'd like
Abstraction of something like POSIX condition variables via OSAL APIs.

Describe alternatives you've considered
Some of the worker pool concepts may be implemented with simple semaphores, but those aren't ideal for some use cases:

  • a counting sem needs a 1:1 relationship between gives and takes, so it is not ideal for cases where work can be "batched" - either where a single input can unblock multiple worker jobs, or multiple inputs can be handled by a single worker job.
  • a binary sem helps the second case by capping the semaphore count at 1, such that multiple "gives" on the dispatch side only cause a single worker run. But it does not allow for a dispatcher to unblock multiple workers, nor can it act on other conditions than a simple boolean.

Note that in the POSIX OSAL the binary semaphore is, in fact, implemented using condition variables underneath - where the condition is just a single boolean value. But only this limited use-case is exposed/available to applications.

As a backward-compatible compromise of sorts - it may be possible to build on the current binary sem concept but allow the application to register its own "condition test" routine beyond the simple boolean.

Additional context
VxWorks support is not fully clear, I think VxWorks 7 has the underlying APIs to implement this, but 6.x might not.

Requester Info
Joseph Hickey, Vantage Systems, Inc.

@jphickey jphickey self-assigned this Aug 10, 2022
@jphickey
Copy link
Contributor Author

Looking into doing this as bplib (for DTN) relies on condition variables for synchronization and it would benefit from having an OSAL API that provides this capability.

jphickey added a commit to jphickey/osal that referenced this issue Aug 10, 2022
This initial commit defines the conceptual condition variable API.
This is not implemented yet for any OS, but should be implementable on
POSIX, RTEMS, and VxWorks 7.x.  Older VxWorks releases may not have the
underlying support to implement this.
jphickey added a commit to jphickey/osal that referenced this issue Aug 10, 2022
This initial commit defines the conceptual condition variable API.
This is not implemented yet for any OS, but should be implementable on
POSIX, RTEMS, and VxWorks 7.x.  Older VxWorks releases may not have the
underlying support to implement this.
jphickey added a commit to jphickey/osal that referenced this issue Aug 23, 2022
Adds a complete implementation of condition variables for POSIX.
Includes coverage and unit tests.

RTEMS and VxWorks will temporarily use a "no-condvar" placeholder
until an implementation for those systems is added.
jphickey added a commit to jphickey/osal that referenced this issue Aug 23, 2022
This initial commit defines the conceptual condition variable API.
This is not implemented yet for any OS, but should be implementable on
POSIX, RTEMS, and VxWorks 7.x.  Older VxWorks releases may not have the
underlying support to implement this.
dzbaker added a commit that referenced this issue Sep 8, 2022
@dzbaker dzbaker closed this as completed in 3cb1cf8 Sep 8, 2022
travis-r-wheatley pushed a commit to travis-r-wheatley/osal that referenced this issue Sep 16, 2022
This initial commit defines the conceptual condition variable API.
This is not implemented yet for any OS, but should be implementable on
POSIX, RTEMS, and VxWorks 7.x.  Older VxWorks releases may not have the
underlying support to implement this.
travis-r-wheatley pushed a commit to travis-r-wheatley/osal that referenced this issue Sep 16, 2022
Adds a complete implementation of condition variables for POSIX.
Includes coverage and unit tests.

RTEMS and VxWorks will temporarily use a "no-condvar" placeholder
until an implementation for those systems is added.
thesamprice pushed a commit to thesamprice/osal that referenced this issue Sep 22, 2022
@chillfig chillfig added this to the Draco milestone Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants