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 support for no_std targets #2

Open
remimimimimi opened this issue May 24, 2021 · 3 comments
Open

Add support for no_std targets #2

remimimimimi opened this issue May 24, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@remimimimimi
Copy link

remimimimimi commented May 24, 2021

Support for #[no_std] targets will be pretty convenient in kernel development.
For #[no_std] syncronization primivitves spin crate can be used respectively.

@bertptrs
Copy link
Owner

Interesting. I took a quick look around the code base for things that would not work with no_std as-is, and I came up with the following:

  • The Directed Acyclic Graph implementation heavily leans on HashMap and HashSet for its data structure. This could be replaced with hashbrown, which could be a good idea in general as it's a little faster than the std implementation.
  • Internal locking is currently handled through a normal std::sync::Mutex, but as you mentioned this could be replaced with spin when that is not available.
  • Bookkeeping for the current locks held is done with a thread_local! macro. There is no no_std equivalent for this as far as I'm aware, so that would still require some research.

@remimimimimi
Copy link
Author

remimimimimi commented May 24, 2021

About thread_local! I think, that we can wrap value in atomic and remove macro for now.

@bertptrs
Copy link
Owner

I'm not sure it'll work like that; the thread_local keeps track of the currently held mutexes for each individual execution thread. In no_std there's no such abstraction available.

Of course, you could ignore the execution threads altogether and just use a single global list of currently held mutexes, but that doesn't really make sense unless you have no concurrency. In that case deadlocks aren't really a thing anyway.

Fundamentally I think the kind of concurrency you have in your no_std environment will determine what kind of tracking primitive you need. I don't think there's a general solution to this, and I'm not familiar enough with the no_std scene to know what the major conventions are, here.

@bertptrs bertptrs added the enhancement New feature or request label May 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants