Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
编码熊(Coding-Bear)
rt-thread
提交
0ea687e0
R
rt-thread
项目概览
编码熊(Coding-Bear)
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
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 搜索 >>
提交
0ea687e0
编写于
12月 19, 2022
作者:
B
Bernard Xiong
提交者:
guo
2月 21, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[lwP] fix _m_lock in posix mutex
上级
c377c4be
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
41 addition
and
1 deletion
+41
-1
components/lwp/lwp_pmutex.c
components/lwp/lwp_pmutex.c
+41
-1
未找到文件。
components/lwp/lwp_pmutex.c
浏览文件 @
0ea687e0
...
...
@@ -6,6 +6,7 @@
* Change Logs:
* Date Author Notes
* 2021/01/02 bernard the first version
* 2022/12/18 bernard fix the _m_lock to tid in user land.
*/
#include <rtthread.h>
...
...
@@ -32,6 +33,25 @@ struct rt_pmutex
rt_uint8_t
type
;
/* pmutex type */
};
/*
* userspace mutex definitions in musl
*/
struct
rt_umutex
{
union
{
int
__i
[
6
];
volatile
int
__vi
[
6
];
volatile
void
*
volatile
__p
[
6
];
}
__u
;
};
#define _m_type __u.__i[0]
#define _m_lock __u.__vi[1]
#define _m_waiters __u.__vi[2]
#define _m_prev __u.__p[3]
#define _m_next __u.__p[4]
#define _m_count __u.__i[5]
static
struct
rt_mutex
_pmutex_lock
;
static
int
pmutex_system_init
(
void
)
...
...
@@ -218,10 +238,17 @@ static int _pthread_mutex_lock_timeout(void *umutex, struct timespec *timeout)
{
struct
rt_lwp
*
lwp
=
RT_NULL
;
struct
rt_pmutex
*
pmutex
=
RT_NULL
;
struct
rt_umutex
*
umutex_p
=
(
struct
rt_umutex
*
)
umutex
;
rt_err_t
lock_ret
=
0
;
rt_int32_t
time
=
RT_WAITING_FOREVER
;
register
rt_base_t
temp
;
if
(
!
lwp_user_accessable
((
void
*
)
umutex
,
sizeof
(
struct
rt_umutex
)))
{
rt_set_errno
(
EINVAL
);
return
-
EINVAL
;
}
if
(
timeout
)
{
if
(
!
lwp_user_accessable
((
void
*
)
timeout
,
sizeof
(
struct
timespec
)))
...
...
@@ -257,6 +284,10 @@ static int _pthread_mutex_lock_timeout(void *umutex, struct timespec *timeout)
break
;
case
PMUTEX_RECURSIVE
:
lock_ret
=
rt_mutex_take_interruptible
(
pmutex
->
lock
.
kmutex
,
time
);
if
(
lock_ret
==
RT_EOK
)
{
umutex_p
->
_m_lock
=
rt_thread_self
()
->
tid
;
}
break
;
case
PMUTEX_ERRORCHECK
:
temp
=
rt_hw_interrupt_disable
();
...
...
@@ -267,6 +298,10 @@ static int _pthread_mutex_lock_timeout(void *umutex, struct timespec *timeout)
return
-
EDEADLK
;
}
lock_ret
=
rt_mutex_take_interruptible
(
pmutex
->
lock
.
kmutex
,
time
);
if
(
lock_ret
==
RT_EOK
)
{
umutex_p
->
_m_lock
=
rt_thread_self
()
->
tid
;
}
rt_hw_interrupt_enable
(
temp
);
break
;
default:
/* unknown type */
...
...
@@ -299,9 +334,10 @@ static int _pthread_mutex_lock_timeout(void *umutex, struct timespec *timeout)
static
int
_pthread_mutex_unlock
(
void
*
umutex
)
{
rt_err_t
lock_ret
=
0
;
struct
rt_lwp
*
lwp
=
RT_NULL
;
struct
rt_pmutex
*
pmutex
=
RT_NULL
;
rt_err_t
lock_ret
=
0
;
struct
rt_umutex
*
umutex_p
=
(
struct
rt_umutex
*
)
umutex
;
lock_ret
=
rt_mutex_take_interruptible
(
&
_pmutex_lock
,
RT_WAITING_FOREVER
);
if
(
lock_ret
!=
RT_EOK
)
...
...
@@ -337,6 +373,10 @@ static int _pthread_mutex_unlock(void *umutex)
case
PMUTEX_RECURSIVE
:
case
PMUTEX_ERRORCHECK
:
lock_ret
=
rt_mutex_release
(
pmutex
->
lock
.
kmutex
);
if
((
lock_ret
==
RT_EOK
)
&&
pmutex
->
lock
.
kmutex
->
owner
==
NULL
)
{
umutex_p
->
_m_lock
=
0
;
}
break
;
default:
/* unknown type */
return
-
EINVAL
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录