Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
RT-Thread
rt-thread
提交
a2fae26d
R
rt-thread
项目概览
RT-Thread
/
rt-thread
9 个月 前同步成功
通知
752
Star
8909
Fork
4735
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
a2fae26d
编写于
7月 24, 2023
作者:
困在新手村
提交者:
mysterywolf
8月 03, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[kernel][mutex] 去除mutex中的递归
上级
2aa1056f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
31 addition
and
25 deletion
+31
-25
src/ipc.c
src/ipc.c
+31
-25
未找到文件。
src/ipc.c
浏览文件 @
a2fae26d
...
...
@@ -791,52 +791,58 @@ rt_inline rt_uint8_t _thread_get_mutex_priority(struct rt_thread* thread)
/* update priority of target thread and the thread suspended it if any */
rt_inline
void
_thread_update_priority
(
struct
rt_thread
*
thread
,
rt_uint8_t
priority
,
int
suspend_flag
)
{
rt_err_t
ret
;
rt_err_t
ret
=
-
RT_ERROR
;
struct
rt_object
*
pending_obj
=
RT_NULL
;
LOG_D
(
"thread:%s priority -> %d"
,
thread
->
parent
.
name
,
priority
);
/* change priority of the thread */
rt_thread_control
(
thread
,
RT_THREAD_CTRL_CHANGE_PRIORITY
,
&
priority
);
ret
=
rt_thread_control
(
thread
,
RT_THREAD_CTRL_CHANGE_PRIORITY
,
&
priority
);
if
((
thread
->
stat
&
RT_THREAD_SUSPEND_MASK
)
==
RT_THREAD_SUSPEND_MASK
)
while
((
ret
==
RT_EOK
)
&&
((
thread
->
stat
&
RT_THREAD_SUSPEND_MASK
)
==
RT_THREAD_SUSPEND_MASK
)
)
{
/* whether change the priority of taken mutex */
struct
rt_object
*
pending_obj
=
thread
->
pending_object
;
pending_obj
=
thread
->
pending_object
;
if
(
pending_obj
&&
rt_object_get_type
(
pending_obj
)
==
RT_Object_Class_Mutex
)
{
rt_uint8_t
mutex_priority
;
rt_uint8_t
mutex_priority
=
0xff
;
struct
rt_mutex
*
pending_mutex
=
(
struct
rt_mutex
*
)
pending_obj
;
/* re-insert thread to suspended thread list */
rt_list_remove
(
&
(
thread
->
tlist
));
ret
=
_ipc_list_suspend
(
&
(
pending_mutex
->
parent
.
suspend_thread
),
thread
,
pending_mutex
->
parent
.
parent
.
flag
,
suspend_flag
);
if
(
ret
!
=
RT_EOK
)
thread
,
pending_mutex
->
parent
.
parent
.
flag
,
suspend_flag
);
if
(
ret
=
=
RT_EOK
)
{
/* TODO */
return
;
}
/* update priority */
_mutex_update_priority
(
pending_mutex
);
/* change the priority of mutex owner thread */
LOG_D
(
"mutex: %s priority -> %d"
,
pending_mutex
->
parent
.
parent
.
name
,
pending_mutex
->
priority
);
/* update priority */
_mutex_update_priority
(
pending_mutex
);
/* change the priority of mutex owner thread */
LOG_D
(
"mutex: %s priority -> %d"
,
pending_mutex
->
parent
.
parent
.
name
,
pending_mutex
->
priority
);
mutex_priority
=
_thread_get_mutex_priority
(
pending_mutex
->
owner
);
if
(
mutex_priority
!=
pending_mutex
->
owner
->
current_priority
)
{
thread
=
pending_mutex
->
owner
;
mutex_priority
=
_thread_get_mutex_priority
(
pending_mutex
->
owner
);
if
(
mutex_priority
!=
pending_mutex
->
owner
->
current_priority
)
{
_thread_update_priority
(
pending_mutex
->
owner
,
mutex_priority
,
suspend_flag
);
ret
=
rt_thread_control
(
thread
,
RT_THREAD_CTRL_CHANGE_PRIORITY
,
&
mutex_priority
);
}
else
{
ret
=
-
RT_ERROR
;
}
}
}
else
{
ret
=
-
RT_ERROR
;
}
}
}
/**
* @addtogroup mutex
* @{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录