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

Support for Zephyr kernel objects #5

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open

Support for Zephyr kernel objects #5

wants to merge 18 commits into from

Commits on Oct 22, 2024

  1. zephyr: sys::sync: move semaphores into their own module

    In preparation for adding more synchronization primitives, move the
    Semaphore implementation into its own module.  There is enough stuff
    associated with each primitive that it can be confusing if they are not
    in their own modules.
    
    Signed-off-by: David Brown <[email protected]>
    d3zd3z committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    bacd922 View commit details
    Browse the repository at this point in the history
  2. zephyr: kobj_define: Add sys Mutex and sys Condvar

    Add support for declaring static instances and arrays of the sys Mutex
    and sys Condvar.
    
    Signed-off-by: David Brown <[email protected]>
    d3zd3z committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    c0434a2 View commit details
    Browse the repository at this point in the history
  3. zephyr: sys: sync: Mutex: Implement Send/Sync

    Although it is tradition in Rust to have types such as Semaphores and
    Mutexes not implement Sync, these primitives, built as thing wrappers
    become fairly useless.  Sharing them would require `Arc`, which requires
    alloc. Presumably someone wanting to use lower level primitives would
    also not likely be wanting to use allocation.
    
    For the most part, these primtives have as their real purpose to be used
    in the implementation of the higher level synchronization primtives,
    such as sync::Mutex.
    
    unlock is unsafe because it is required to only call unlock on the same
    thread that locked.
    
    Signed-off-by: David Brown <[email protected]>
    d3zd3z committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    4d4ee9b View commit details
    Browse the repository at this point in the history
  4. samples: philosophers: Add sysmutex version

    Add a version of the philosopher's demo that is built around sys::Mutex,
    in it's simplest use case.
    
    Signed-off-by: David Brown <[email protected]>
    d3zd3z committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    2731deb View commit details
    Browse the repository at this point in the history
  5. zephyr: sync: Create Mutex/Condvar

    Create higher-level Mutex and Condvar types that are similar to
    std::sync::Mutex and std::sync::Condvar.
    
    The main difference is that the only current constructor for this
    requires the sys Mutex and sys Condvar from the sys versions that are
    statically allocated.
    
    Signed-off-by: David Brown <[email protected]>
    d3zd3z committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    102478e View commit details
    Browse the repository at this point in the history
  6. samples: philosophers: Add sync using Mutex/Condvar

    Build a syncer that coordinates the forks using a single Mutex/Condvar
    pair, where the Mutex protects the data, and Condvar is used to
    coordinate.  This is a common paradigm for shared synchronization.
    
    Signed-off-by: David Brown <[email protected]>
    d3zd3z committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    2a8a82d View commit details
    Browse the repository at this point in the history
  7. zephyr: sys: Create queue type based on k_queue

    A simple wrapper around Zephyr's k_queue.
    
    Signed-off-by: David Brown <[email protected]>
    d3zd3z committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    1c8d82a View commit details
    Browse the repository at this point in the history
  8. zephyr: sync: channel: Create unbounded channels

    Create an implementation of bounded channels, in the spirit of
    crossbeam-channel.  Currently, only the bounded channels are supported,
    an as we don't yet support recovery from panic, ther is no poisoning.
    
    As the underlying Zephyr queues don't support deallocation, drop is also
    a no-op.
    
    Signed-off-by: David Brown <[email protected]>
    d3zd3z committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    9187024 View commit details
    Browse the repository at this point in the history
  9. samples: philosophers: Add implementation for channels

    Add a synchronizer for forks based on sending messages over channels to
    a worker thread.
    
    Signed-off-by: David Brown <[email protected]>
    d3zd3z committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    1e62073 View commit details
    Browse the repository at this point in the history
  10. samples: philosophers: Add statistics

    Rather than just printing a bunch of information out as the various
    philosopher threads dine, use some data protected within a Mutex to
    collect statistics, and print those out periodically.
    
    Signed-off-by: David Brown <[email protected]>
    d3zd3z committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    099aaa7 View commit details
    Browse the repository at this point in the history
  11. zephyr: Remove 'unsafe' from sys::Mutex::unlock

    Although this function has constraints on how it can be used (the thread
    that calls unlock must also have called lock).  However, according to
    the documentation, it detects this, and returns an error.  As such, the
    wrapper in Rust does not need to be `unsafe` but can merely reflect that
    error code in the `Result` that it returns.
    
    Signed-off-by: David Brown <[email protected]>
    d3zd3z committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    2413a53 View commit details
    Browse the repository at this point in the history
  12. zephyr: sync: Remove unsafe block from unlock

    Now that `sys::Mutex::unlock` has lost its `unsafe`, we don't need an
    unsafe block for it.
    
    Signed-off-by: David Brown <[email protected]>
    d3zd3z committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    2717d8b View commit details
    Browse the repository at this point in the history
  13. zephyr: object: Make StaticKernelObject::new unsafe

    This function returns initialized memory, and is therefore inherently
    unsafe.  Added some commentary about how it is used safely.
    
    Signed-off-by: David Brown <[email protected]>
    d3zd3z committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    93448bf View commit details
    Browse the repository at this point in the history
  14. zephyr: object: Reorder declarations

    Move the Wrapped trait above the StaticKernelObject so that the traits
    are immediately declared after the type the apply to.
    
    Signed-off-by: David Brown <[email protected]>
    d3zd3z committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    058740f View commit details
    Browse the repository at this point in the history
  15. zephyr: sys: sync: Remove Clone from Mutex and Semaphore

    Although these, in their current state, are safe to Clone, having these
    semantics will make it difficult for us to later add these types that
    are allocated from a pool.
    
    Uses that currently expect to clone can generally wrap these in an Arc,
    to allow for the sharing.
    
    Signed-off-by: David Brown <[email protected]>
    d3zd3z committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    43c0c8a View commit details
    Browse the repository at this point in the history

Commits on Oct 24, 2024

  1. zephry: object: Create Fixed concept

    The `Fixed` type encapsulates something that can either be a statically
    allocated object or a dynamically allocated one.  It is conditional on
    `CONFIG_RUST_ALLOC`, and if that is not defined, will just end up
    represented as the underlying static pointer.
    d3zd3z committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    d513613 View commit details
    Browse the repository at this point in the history
  2. zephyr: sys: sync: sempahore: Add dynamic support

    Add support for dynamically allocated Semaphores.  These can be freely
    allocated, but are not usable from userspace.
    d3zd3z committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    d8dc4fe View commit details
    Browse the repository at this point in the history
  3. samples: philosophers: Add dynamic semaphore example

    Add a sample that implements the forks using dynamically allocate
    semaphores.
    
    Signed-off-by: David Brown <[email protected]>
    d3zd3z committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    8be9b79 View commit details
    Browse the repository at this point in the history