Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2301_76519099
rt-thread
提交
ae7a33c2
R
rt-thread
项目概览
2301_76519099
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
3
Star
1
Fork
1
代码
文件
提交
分支
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,发现更多精彩内容 >>
未验证
提交
ae7a33c2
编写于
9月 17, 2019
作者:
B
Bernard Xiong
提交者:
GitHub
9月 17, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3077 from jesven/fix_mempool
修正rt_mp_free有可能唤醒一个错误任务指针的问题
上级
bb014b20
770cc2ff
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
13 addition
and
17 deletion
+13
-17
components/finsh/cmd.c
components/finsh/cmd.c
+12
-3
include/rtdef.h
include/rtdef.h
+0
-1
src/mempool.c
src/mempool.c
+1
-13
未找到文件。
components/finsh/cmd.c
浏览文件 @
ae7a33c2
...
...
@@ -675,6 +675,8 @@ long list_mempool(void)
{
struct
rt_object
*
obj
;
struct
rt_mempool
*
mp
;
int
suspend_thread_count
;
rt_list_t
*
node
;
obj
=
rt_list_entry
(
obj_list
[
i
],
struct
rt_object
,
list
);
level
=
rt_hw_interrupt_disable
();
...
...
@@ -687,7 +689,14 @@ long list_mempool(void)
rt_hw_interrupt_enable
(
level
);
mp
=
(
struct
rt_mempool
*
)
obj
;
if
(
mp
->
suspend_thread_count
>
0
)
suspend_thread_count
=
0
;
rt_list_for_each
(
node
,
&
mp
->
suspend_thread
)
{
suspend_thread_count
++
;
}
if
(
suspend_thread_count
>
0
)
{
rt_kprintf
(
"%-*.*s %04d %04d %04d %d:"
,
maxlen
,
RT_NAME_MAX
,
...
...
@@ -695,7 +704,7 @@ long list_mempool(void)
mp
->
block_size
,
mp
->
block_total_count
,
mp
->
block_free_count
,
mp
->
suspend_thread_count
);
suspend_thread_count
);
show_wait_queue
(
&
(
mp
->
suspend_thread
));
rt_kprintf
(
"
\n
"
);
}
...
...
@@ -707,7 +716,7 @@ long list_mempool(void)
mp
->
block_size
,
mp
->
block_total_count
,
mp
->
block_free_count
,
mp
->
suspend_thread_count
);
suspend_thread_count
);
}
}
}
...
...
include/rtdef.h
浏览文件 @
ae7a33c2
...
...
@@ -815,7 +815,6 @@ struct rt_mempool
rt_size_t
block_free_count
;
/**< numbers of free memory block */
rt_list_t
suspend_thread
;
/**< threads pended on this resource */
rt_size_t
suspend_thread_count
;
/**< numbers of thread pended on this resource */
};
typedef
struct
rt_mempool
*
rt_mp_t
;
#endif
...
...
src/mempool.c
浏览文件 @
ae7a33c2
...
...
@@ -106,7 +106,6 @@ rt_err_t rt_mp_init(struct rt_mempool *mp,
/* initialize suspended thread list */
rt_list_init
(
&
(
mp
->
suspend_thread
));
mp
->
suspend_thread_count
=
0
;
/* initialize free block list */
block_ptr
=
(
rt_uint8_t
*
)
mp
->
start_address
;
...
...
@@ -160,9 +159,6 @@ rt_err_t rt_mp_detach(struct rt_mempool *mp)
*/
rt_thread_resume
(
thread
);
/* decrease suspended thread count */
mp
->
suspend_thread_count
--
;
/* enable interrupt */
rt_hw_interrupt_enable
(
temp
);
}
...
...
@@ -226,7 +222,6 @@ rt_mp_t rt_mp_create(const char *name,
/* initialize suspended thread list */
rt_list_init
(
&
(
mp
->
suspend_thread
));
mp
->
suspend_thread_count
=
0
;
/* initialize free block list */
block_ptr
=
(
rt_uint8_t
*
)
mp
->
start_address
;
...
...
@@ -282,9 +277,6 @@ rt_err_t rt_mp_delete(rt_mp_t mp)
*/
rt_thread_resume
(
thread
);
/* decrease suspended thread count */
mp
->
suspend_thread_count
--
;
/* enable interrupt */
rt_hw_interrupt_enable
(
temp
);
}
...
...
@@ -344,7 +336,6 @@ void *rt_mp_alloc(rt_mp_t mp, rt_int32_t time)
/* need suspend thread */
rt_thread_suspend
(
thread
);
rt_list_insert_after
(
&
(
mp
->
suspend_thread
),
&
(
thread
->
tlist
));
mp
->
suspend_thread_count
++
;
if
(
time
>
0
)
{
...
...
@@ -431,7 +422,7 @@ void rt_mp_free(void *block)
*
block_ptr
=
mp
->
block_list
;
mp
->
block_list
=
(
rt_uint8_t
*
)
block_ptr
;
if
(
mp
->
suspend_thread_count
>
0
)
if
(
!
rt_list_isempty
(
&
(
mp
->
suspend_thread
))
)
{
/* get the suspended thread */
thread
=
rt_list_entry
(
mp
->
suspend_thread
.
next
,
...
...
@@ -444,9 +435,6 @@ void rt_mp_free(void *block)
/* resume thread */
rt_thread_resume
(
thread
);
/* decrease suspended thread count */
mp
->
suspend_thread_count
--
;
/* enable interrupt */
rt_hw_interrupt_enable
(
level
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录