Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Kernel Liteos A
提交
e5ef0f25
K
Kernel Liteos A
项目概览
OpenHarmony
/
Kernel Liteos A
1 年多 前同步成功
通知
460
Star
414
Fork
55
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
4
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel Liteos A
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
4
Issue
4
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
e5ef0f25
编写于
9月 28, 2020
作者:
O
openharmony_ci
提交者:
Gitee
9月 28, 2020
浏览文件
操作
浏览文件
下载
差异文件
!12 解决用户态锁在高并发场景下的静态问题
Merge pull request !12 from zhushengle/master
上级
aa407d37
c884ada0
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
22 addition
and
29 deletion
+22
-29
kernel/base/ipc/los_futex.c
kernel/base/ipc/los_futex.c
+22
-29
未找到文件。
kernel/base/ipc/los_futex.c
浏览文件 @
e5ef0f25
...
...
@@ -465,41 +465,29 @@ STATIC INT32 OsFindAndInsertToHash(FutexNode *node)
return
ret
;
}
STATIC
INT32
OsFutexWaitPar
maCheck
(
const
UINT32
*
userVaddr
,
UINT32
flags
,
UINT32
val
,
UINT32
absTime
)
STATIC
INT32
OsFutexWaitPar
amCheck
(
const
UINT32
*
userVaddr
,
UINT32
flags
,
UINT32
absTime
)
{
UINTPTR
futexKey
=
(
UINTPTR
)
userVaddr
;
UINT32
lockVal
;
INT32
ret
;
if
(
OS_INT_ACTIVE
)
{
return
LOS_EINTR
;
}
if
(
flags
)
{
PRINT_ERR
(
"Futex wait par
ma
check failed! error flags: 0x%x
\n
"
,
flags
);
PRINT_ERR
(
"Futex wait par
am
check failed! error flags: 0x%x
\n
"
,
flags
);
return
LOS_EINVAL
;
}
if
((
futexKey
%
sizeof
(
INT32
))
||
(
futexKey
<
OS_FUTEX_KEY_BASE
)
||
(
futexKey
>=
OS_FUTEX_KEY_MAX
))
{
PRINT_ERR
(
"Futex wait par
ma
check failed! error futex key: 0x%x
\n
"
,
futexKey
);
PRINT_ERR
(
"Futex wait par
am
check failed! error futex key: 0x%x
\n
"
,
futexKey
);
return
LOS_EINVAL
;
}
if
(
!
absTime
)
{
PRINT_ERR
(
"Futex wait parma check failed! error absTime: %u
\n
"
,
absTime
);
return
LOS_EINVAL
;
}
ret
=
LOS_ArchCopyFromUser
(
&
lockVal
,
userVaddr
,
sizeof
(
UINT32
));
if
(
ret
)
{
PRINT_ERR
(
"Futex wait parma check failed! copy from user failed!
\n
"
);
PRINT_ERR
(
"Futex wait param check failed! error absTime: %u
\n
"
,
absTime
);
return
LOS_EINVAL
;
}
if
(
lockVal
!=
val
)
{
return
LOS_EBADF
;
}
return
LOS_OK
;
}
...
...
@@ -542,10 +530,10 @@ STATIC INT32 OsFutexInserTaskToHash(LosTaskCB **taskCB, FutexNode **node, const
return
LOS_OK
;
}
STATIC
INT32
OsFutexWaitTask
(
const
UINT32
timeOut
,
const
UINT32
*
userVaddr
)
STATIC
INT32
OsFutexWaitTask
(
const
UINT32
timeOut
,
const
UINT32
*
userVaddr
,
UINT32
val
)
{
INT32
futexRet
;
UINT32
intSave
;
UINT32
intSave
,
lockVal
;
LosTaskCB
*
taskCB
=
NULL
;
FutexNode
*
node
=
NULL
;
UINTPTR
futexKey
=
(
UINTPTR
)
userVaddr
;
...
...
@@ -556,7 +544,19 @@ STATIC INT32 OsFutexWaitTask(const UINT32 timeOut, const UINT32 *userVaddr)
return
LOS_EINVAL
;
}
if
(
LOS_ArchCopyFromUser
(
&
lockVal
,
userVaddr
,
sizeof
(
UINT32
)))
{
PRINT_ERR
(
"Futex wait param check failed! copy from user failed!
\n
"
);
futexRet
=
LOS_EINVAL
;
goto
EXIT_ERR
;
}
if
(
lockVal
!=
val
)
{
futexRet
=
LOS_EBADF
;
goto
EXIT_ERR
;
}
if
(
OsFutexInserTaskToHash
(
&
taskCB
,
&
node
,
futexKey
))
{
futexRet
=
LOS_NOK
;
goto
EXIT_ERR
;
}
SCHEDULER_LOCK
(
intSave
);
...
...
@@ -564,10 +564,6 @@ STATIC INT32 OsFutexWaitTask(const UINT32 timeOut, const UINT32 *userVaddr)
OsPercpuGet
()
->
taskLockCnt
++
;
LOS_SpinUnlock
(
&
g_taskSpin
);
#ifdef LOS_FUTEX_DEBUG
OsFutexHashShow
();
#endif
futexRet
=
OsFutexUnlock
(
&
hashNode
->
listLock
);
if
(
futexRet
)
{
OsPercpuGet
()
->
taskLockCnt
--
;
...
...
@@ -594,12 +590,9 @@ STATIC INT32 OsFutexWaitTask(const UINT32 timeOut, const UINT32 *userVaddr)
return
LOS_OK
;
EXIT_ERR:
futexRet
=
OsFutexUnlock
(
&
hashNode
->
listLock
);
(
VOID
)
OsFutexUnlock
(
&
hashNode
->
listLock
);
EXIT_UNLOCK_ERR:
if
(
futexRet
)
{
return
futexRet
;
}
return
LOS_NOK
;
return
futexRet
;
}
INT32
OsFutexWait
(
const
UINT32
*
userVaddr
,
UINT32
flags
,
UINT32
val
,
UINT32
absTime
)
...
...
@@ -607,7 +600,7 @@ INT32 OsFutexWait(const UINT32 *userVaddr, UINT32 flags, UINT32 val, UINT32 absT
INT32
ret
;
UINT32
timeOut
=
LOS_WAIT_FOREVER
;
ret
=
OsFutexWaitPar
maCheck
(
userVaddr
,
flags
,
val
,
absTime
);
ret
=
OsFutexWaitPar
amCheck
(
userVaddr
,
flags
,
absTime
);
if
(
ret
)
{
return
ret
;
}
...
...
@@ -615,7 +608,7 @@ INT32 OsFutexWait(const UINT32 *userVaddr, UINT32 flags, UINT32 val, UINT32 absT
timeOut
=
OsFutexGetTick
(
absTime
);
}
return
OsFutexWaitTask
(
timeOut
,
userVaddr
);
return
OsFutexWaitTask
(
timeOut
,
userVaddr
,
val
);
}
/* Check to see if the task to be awakened has timed out
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录