nasa / osal

The Core Flight System (cFS) Operating System Abstraction Layer (OSAL)
Apache License 2.0
546 stars 213 forks source link

Add abstraction for condition variables #1252

Closed jphickey closed 2 years ago

jphickey commented 2 years ago

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:

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 commented 2 years ago

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.