MCPcopy Create free account
hub / github.com/Simple-XX/SimpleKernel / UnLock

Method UnLock

src/include/spinlock.hpp:66–82  ·  view source on GitHub ↗

* @brief 释放锁 * @return Expected 成功返回空值,失败返回错误 */

Source from the content-addressed store, hash-verified

64 * @return Expected<void> 成功返回空值,失败返回错误
65 */
66 [[nodiscard]] __always_inline auto UnLock() -> Expected<void> {
67 if (!IsLockedByCurrentCore()) {
68 // klog::Err("spinlock {}: {} unlock by non-owner detected.",
69 // cpu_io::GetCurrentCoreId(), name);
70 return std::unexpected(Error{ErrorCode::kSpinLockNotOwned});
71 }
72
73 // 先重置 core_id_,再释放锁
74 core_id_.store(std::numeric_limits<size_t>::max(),
75 std::memory_order_release);
76 locked_.clear(std::memory_order_release);
77
78 if (saved_intr_enable_) {
79 cpu_io::EnableInterrupt();
80 }
81 return {};
82 }
83
84 /// @name 构造/析构函数
85 /// @{

Callers 2

spinlock.hppFile · 0.45
~LockGuardMethod · 0.45

Calls 1

EnableInterruptFunction · 0.85

Tested by

no test coverage detected