设为首页 加入收藏

TOP

优先级反转那些事儿(十)
2023-07-23 13:26:40 】 浏览:703
Tags:那些事
;return res;         }         PTHREAD_TRACE(psynch_mutex_kwqwait, kwq->kw_addr, kwq->kw_inqueue,                         kwq->kw_prepost.count, kwq->kw_intr.count);         if (_kwq_use_turnstile(kwq)) {                 // pthread mutexes and rwlocks both (at least sometimes) know their                                 // owner and can use turnstiles. Otherwise, we pass NULL as the                                 // tstore to the shims so they wait on the global waitq.                                 tstore = &kwq->kw_turnstile;         }         ...... }

再去查看_kwq_use_turnstile的定义,代码还是很诚实的,只有在KSYN_WQTYPE_MTX才会启用turnstile进行优先级反转保护,而读写锁的类型为KSYN_WQTYPE_RWLOCK,这说明读写锁不会使用_kwq_use_turnstile,所以无法避免优先级反转。

#define KSYN_WQTYPE_MTX         0x01
#define KSYN_WQTYPE_CVAR        0x02
#define KSYN_WQTYPE_RWLOCK      0x04
#define KSYN_WQTYPE_SEMA        0x08

static inline bool
_kwq_use_turnstile(ksyn_wait_queue_t kwq)
{
        // If we had writer-owner information from the
        // rwlock then we could use the turnstile to push on it. For now, only
        // plain mutexes use it.
        return (_kwq_type(kwq) == KSYN_WQTYPE_MTX);
}

另外在_pthread_find_owner也可以看到,读写锁的owner0

void
_pthread_find_owner(thread_t thread,
                struct stackshot_thread_waitinfo * waitinfo)
{
    
首页 上一页 7 8 9 10 11 12 13 下一页 尾页 10/15/15
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇从 iOS App 启动速度看如何为基础.. 下一篇uniapp ios原生插件开发 (framewo..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目