mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-30 00:23:24 +00:00
Introduce the semantics of the atomic-mode guard
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use crate::sync::GuardTransfer;
|
||||
use crate::{sync::GuardTransfer, task::atomic_mode::InAtomicMode};
|
||||
|
||||
/// A guard for disable preempt.
|
||||
#[clippy::has_significant_drop]
|
||||
@ -13,6 +13,10 @@ pub struct DisabledPreemptGuard {
|
||||
|
||||
impl !Send for DisabledPreemptGuard {}
|
||||
|
||||
// SAFETY: The guard disables preemptions, which meets the second
|
||||
// sufficient condition for atomic mode.
|
||||
unsafe impl InAtomicMode for DisabledPreemptGuard {}
|
||||
|
||||
impl DisabledPreemptGuard {
|
||||
fn new() -> Self {
|
||||
super::cpu_local::inc_guard_count();
|
||||
|
Reference in New Issue
Block a user