日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

optee中mutex的实现方式

發布時間:2025/3/21 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 optee中mutex的实现方式 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

快速鏈接:
.
👉👉👉 個人博客筆記導讀目錄(全部) 👈👈👈


相關推薦:
optee中spinlock的實現原理詳解


說明: 在默認的情況下,本文講述的是armv8 aarch64體系,optee 3.12.0代碼

在optee中,mutex的實現方式是依賴REE測的completion完成量的,具體流程圖如下所示:

相關代碼:

static void __mutex_lock(struct mutex *m, const char *fname, int lineno) {assert_have_no_spinlock();assert(thread_get_id_may_fail() != THREAD_ID_INVALID);assert(thread_is_in_normal_mode());mutex_lock_check(m);while (true) {uint32_t old_itr_status;bool can_lock;struct wait_queue_elem wqe;/** If the mutex is locked we need to initialize the wqe* before releasing the spinlock to guarantee that we don't* miss the wakeup from mutex_unlock().** If the mutex is unlocked we don't need to use the wqe at* all.*/old_itr_status = cpu_spin_lock_xsave(&m->spin_lock);can_lock = !m->state;if (!can_lock) {wq_wait_init(&m->wq, &wqe, false /* wait_read */);} else {m->state = -1; /* write locked */}cpu_spin_unlock_xrestore(&m->spin_lock, old_itr_status);if (!can_lock) {/** Someone else is holding the lock, wait in normal* world for the lock to become available.*/wq_wait_final(&m->wq, &wqe, m, fname, lineno);} elsereturn;} } static void __mutex_unlock(struct mutex *m, const char *fname, int lineno) {uint32_t old_itr_status;assert_have_no_spinlock();assert(thread_get_id_may_fail() != THREAD_ID_INVALID);mutex_unlock_check(m);old_itr_status = cpu_spin_lock_xsave(&m->spin_lock);if (!m->state)panic();m->state = 0;cpu_spin_unlock_xrestore(&m->spin_lock, old_itr_status);wq_wake_next(&m->wq, m, fname, lineno); }

總結

以上是生活随笔為你收集整理的optee中mutex的实现方式的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。