Skip to content

flag=RT_IPC_FLAG_FIFO的mutex释放时,优先级反转 #4149

@cc-caixf

Description

@cc-caixf

1.初始化mutexflag=RT_IPC_FLAG_FIFO.
2.多个不同优先级线程take这个mutex
3.拥有mutex的线程rt_mutex_release

if (!rt_list_isempty(&mutex->parent.suspend_thread))
        {
            /* get suspended thread */
            thread = rt_list_entry(mutex->parent.suspend_thread.next,
                                   struct rt_thread,
                                   tlist);

            RT_DEBUG_LOG(RT_DEBUG_IPC, ("mutex_release: resume thread: %s\n",
                                        thread->name));

            /* set new owner and priority */
            mutex->owner             = thread;
            mutex->original_priority = thread->current_priority;
            mutex->hold ++;

            /* resume thread */
            rt_ipc_list_resume(&(mutex->parent.suspend_thread));

            need_schedule = RT_TRUE;
        }

这时当前代码会让队列中的第一个thread拥有mutex,符合FIFO,但可能队列中会有更高优先级的thread,当前代码是否需要考虑释放mutex时,使用队列中最高优先级来修改当前thread的优先级?
或者RTTHREAD认为这种情况该使用mutexflag=RT_IPC_FLAG_PRIO?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions