critical-section
Cross-platform critical section
1.2.0
83M downloads/mo
#900 most downloaded on crates.io
rust-embedded/critical-section
What this package is like to depend on
Last release 2 months ago
09 Jun 2026
Release timing varies
gaps range from 2 weeks to 1.6 years
Nearly every release is documented
notes for 1 of 1 stable releases
18 versions withdrawn
withdrawn after publishing
5 years old
19 releases · first in 2021
1 release in the last 12 months
see the full history below
Release timeline
19 releases · May 2021 to Jun 2026Releases
latest 19-
1.3.009 Jun 2026 withdrawnRelease notes
Open source → -
1.2.016 Oct 2024 -
1.1.321 Aug 2024 withdrawn -
1.1.209 Aug 2023 withdrawnRelease notes
Open source →- Clarified that
acquire()must provide ordering guarantees - Updated atomic-polyfill reference to point to portable-atomic instead
- Improved documentation for
Mutexexample - Added list of some known implementations
- Clarified that
-
1.1.113 Sep 2022 withdrawnRelease notes
Open source →27: Release v1.1.1 r=eldruin a=Dirbaio
Co-authored-by: Dario Nieuwenhuis [email protected]
Release notes
Open source →- On the
stdimplementation, panicking inside thecritical_section::with()closure no longer accidentally leaves the critical section locked (#26).
- On the
-
1.1.017 Aug 2022 withdrawnRelease notes
Open source →23: Release v1.1 r=eldruin a=Dirbaio
Co-authored-by: Dario Nieuwenhuis [email protected]
Release notes
Open source →- Added built-in critical section implementation using
std::sync::Mutex, enabled by thestdCargo feature. - MSRV changed to
1.54whenstdfeature is disabled,1.63when enabled.
- Added built-in critical section implementation using
-
1.0.011 Aug 2022 withdrawnRelease notes
Open source →21: Rename doctest from GH_6 and make it cfg(doctest) r=Dirbaio a=jannic
Co-authored-by: Jan Niehusmann [email protected]
-
1.0.0-alpha.228 Jul 2022 pre-release withdrawn -
1.0.0-alpha.128 Jul 2022 pre-release withdrawnRelease notes
Open source →Breaking changes:
- Removed all builtin impls. These are going to be provided by platform-support crates now.
- Renamed
custom_impl!toset_impl!. - RestoreState is now an opaque struct for the user, and a transparent
RawRestoreStatetype alias for impl writers. - RestoreState type is now configurable with Cargo features. Default is
(). (previously it was fixed tou8.) - Added own
CriticalSectionandMutextypes, instead of reexporting them frombare_metal.
-
0.2.829 Nov 2022 withdrawnRelease notes
Open source →- Implemented critical-section by forwarding to version 1.1.1
Breaking changes:
acquireandreleaseare only implemented if the restore-state used by version 1.1.1 is an u8 or smaller.- No default critical-section implementation is provided.
Those breaking changes are necessary because versions <= 0.2.7 were unsound, and that was impossible to fix without a breaking change.
This version is meant to minimize that breaking change. However, all users are encouraged to upgrade to critical-section 1.1.
If you're seeing a linker error like
undefined symbol: _critical_section_1_0_acquire, you're affected. To fix it:-
If your target supports
std: Add thecritical-sectiondependency toCargo.tomlenabling thestdfeature.[dependencies] critical-section = { version = "1.1", features = ["std"]} -
For single-core Cortex-M targets in privileged mode:
[dependencies] cortex-m = { version = "0.7.6", features = ["critical-section-single-core"]} -
For single-hart RISC-V targets in privileged mode:
[dependencies] riscv = { version = "0.10", features = ["critical-section-single-hart"]} -
For other targets: check if your HAL or architecture-support crate has a
critical-section 1.0implementation available. Otherwise, provide your own.
-
0.2.708 Apr 2022 withdrawn -
0.2.602 Apr 2022 withdrawn -
0.2.502 Nov 2021 withdrawnRelease notes
Open source →- Fix
stdimplementation to allow reentrant (nested) critical sections. This would previously deadlock.
- Fix
-
0.2.424 Sep 2021 withdrawn -
0.2.313 Sep 2021 withdrawn -
0.2.213 Sep 2021 withdrawn -
0.2.112 May 2021 withdrawn -
0.2.010 May 2021 withdrawnRelease notes
Open source →- Breaking change: use
CriticalSection<'_>instead of&CriticalSection<'_>
- Breaking change: use
-
0.1.009 May 2021 withdrawn