PackageTrack
Sign in Get early access

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 2026
2022 2023 2024 2025 2026
Release Pre-release Withdrawn

Releases

latest 19
  1. 1.3.0 09 Jun 2026 withdrawn
    Release notes
    • Add support for loom critical sections (using cfg(loom)) to the std implementation. #58
    Open source →
  2. 1.2.0 16 Oct 2024
    Release notes
    • Soundness fix: ensure the CriticalSection token is not Send or Sync, so that it can only be used in the thread that acquired it. #55
    • Soundness fix: Fix aliasing &mut in the std implementation. #46
    • Fix build with restore-state-usize. #50
    Open source →
  3. 1.1.3 21 Aug 2024 withdrawn
    Release notes
    • Added option to use a usize sized restore state
    Open source →
  4. 1.1.2 09 Aug 2023 withdrawn
    Release notes
    • Clarified that acquire() must provide ordering guarantees
    • Updated atomic-polyfill reference to point to portable-atomic instead
    • Improved documentation for Mutex example
    • Added list of some known implementations
    Open source →
  5. 1.1.1 13 Sep 2022 withdrawn
    Release notes

    27: Release v1.1.1 r=eldruin a=Dirbaio

    Co-authored-by: Dario Nieuwenhuis [email protected]

    Open source →
    Release notes
    • On the std implementation, panicking inside the critical_section::with() closure no longer accidentally leaves the critical section locked (#26).
    Open source →
  6. 1.1.0 17 Aug 2022 withdrawn
    Release notes

    23: Release v1.1 r=eldruin a=Dirbaio

    Co-authored-by: Dario Nieuwenhuis [email protected]

    Open source →
    Release notes
    • Added built-in critical section implementation using std::sync::Mutex, enabled by the std Cargo feature.
    • MSRV changed to 1.54 when std feature is disabled, 1.63 when enabled.
    Open source →
  7. 1.0.0 11 Aug 2022 withdrawn
    Release notes

    21: Rename doctest from GH_6 and make it cfg(doctest) r=Dirbaio a=jannic

    Co-authored-by: Jan Niehusmann [email protected]

    Open source →
    Release notes
    • Improved docs.
    Open source →
  8. 1.0.0-alpha.2 28 Jul 2022 pre-release withdrawn
    Release notes
    • Change name of the extern fns to avoid clash with critical-section 0.2.
    Open source →
  9. 1.0.0-alpha.1 28 Jul 2022 pre-release withdrawn
    Release notes

    Breaking changes:

    • Removed all builtin impls. These are going to be provided by platform-support crates now.
    • Renamed custom_impl! to set_impl!.
    • RestoreState is now an opaque struct for the user, and a transparent RawRestoreState type alias for impl writers.
    • RestoreState type is now configurable with Cargo features. Default is (). (previously it was fixed to u8.)
    • Added own CriticalSection and Mutex types, instead of reexporting them from bare_metal.
    Open source →
  10. 0.2.8 29 Nov 2022 withdrawn
    Release notes
    • Implemented critical-section by forwarding to version 1.1.1

    Breaking changes:

    • acquire and release are 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 the critical-section dependency to Cargo.toml enabling the std feature.

      [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.0 implementation available. Otherwise, provide your own.

    Open source →
  11. 0.2.7 08 Apr 2022 withdrawn
    Release notes
    • Add support for AVR targets.
    Open source →
  12. 0.2.6 02 Apr 2022 withdrawn
    Release notes
    • Improved docs.
    Open source →
  13. 0.2.5 02 Nov 2021 withdrawn
    Release notes
    • Fix std implementation to allow reentrant (nested) critical sections. This would previously deadlock.
    Open source →
  14. 0.2.4 24 Sep 2021 withdrawn
    Release notes
    • Add support for 32bit RISC-V targets.
    Open source →
  15. 0.2.3 13 Sep 2021 withdrawn
    Release notes
    • Use correct #[vcfg] for wasm targets.
    Open source →
  16. 0.2.2 13 Sep 2021 withdrawn
    Release notes
    • Added support for wasm targets.
    Open source →
  17. 0.2.1 12 May 2021 withdrawn
    Release notes
    • Added critical section implementation for std, based on a global Mutex.
    Open source →
  18. 0.2.0 10 May 2021 withdrawn
    Release notes
    • Breaking change: use CriticalSection<'_> instead of &CriticalSection<'_>
    Open source →
  19. 0.1.0 09 May 2021 withdrawn
    Release notes
    • First release
    Open source →

Every package, every release, already written down.

The archive is open and free. Watching your own project is what we are building next.

Browse the archive