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

Rework locks #2197

Merged
merged 9 commits into from
Sep 20, 2024
Merged

Rework locks #2197

merged 9 commits into from
Sep 20, 2024

Conversation

bugadani
Copy link
Contributor

@bugadani bugadani commented Sep 19, 2024

  • Move locks to a new module
  • Deduplicate implementation
  • Reimplement critical_section in terms of Lock
  • Make Lock reentrant by default

This change should prevent multi-core apps spinning in interrupt-free context if the other core is holding the global lock.

It's hardly a stress test, but I've ran the multicore examples on an ESP32 and they worked as expected.

@bugadani bugadani added the skip-changelog No changelog modification needed label Sep 19, 2024
@bugadani bugadani removed the skip-changelog No changelog modification needed label Sep 19, 2024
esp-hal/src/lock.rs Outdated Show resolved Hide resolved
@bugadani
Copy link
Contributor Author

Fun fact: this PR came 2 days before #797 turned one year old :D

@bugadani bugadani marked this pull request as ready for review September 19, 2024 13:37
@MabezDev
Copy link
Member

Fun fact: this PR came 2 days before #797 turned one year old :D

I expect you to mark this occasion in your calendar for next year too :D

Copy link
Contributor

@bjoernQ bjoernQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Copy link
Member

@MabezDev MabezDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I'm glad we're reusing code for both the stand alone lock and CS now.

It would be nice to have a test or two, but we can leave that for now. One final thing to consider before merging, what about naming the lock module sync instead?

@bugadani
Copy link
Contributor Author

One final thing to consider before merging, what about naming the lock module sync instead?

It's private, we can deal with this later, when we're fixing the fallout from this 🤣

@MabezDev MabezDev added this pull request to the merge queue Sep 20, 2024
Merged via the queue into esp-rs:main with commit 5324bce Sep 20, 2024
27 of 28 checks passed
@bugadani bugadani deleted the lock branch September 20, 2024 11:32
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.

4 participants