Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Kernel Liteos A
提交
ed0041ac
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看板
提交
ed0041ac
编写于
6月 18, 2021
作者:
O
openharmony_ci
提交者:
Gitee
6月 18, 2021
浏览文件
操作
浏览文件
下载
差异文件
!327 增强Liteipc的多线程保护
Merge pull request !327 from Caoruihong/master
上级
dca42b9e
7e2aef24
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
31 addition
and
15 deletion
+31
-15
kernel/extended/liteipc/hm_liteipc.c
kernel/extended/liteipc/hm_liteipc.c
+31
-15
未找到文件。
kernel/extended/liteipc/hm_liteipc.c
浏览文件 @
ed0041ac
...
...
@@ -70,11 +70,11 @@ typedef struct {
VOID
*
ptr
;
}
IpcUsedNode
;
LosMux
g_serviceHandleMapMux
;
STATIC
LosMux
g_serviceHandleMapMux
;
#if (USE_TASKID_AS_HANDLE == YES)
HandleInfo
g_cmsTask
;
STATIC
HandleInfo
g_cmsTask
;
#else
HandleInfo
g_serviceHandleMap
[
MAX_SERVICE_NUM
];
STATIC
HandleInfo
g_serviceHandleMap
[
MAX_SERVICE_NUM
];
#endif
STATIC
LOS_DL_LIST
g_ipcPendlist
;
STATIC
LOS_DL_LIST
g_ipcUsedNodelist
[
LOSCFG_BASE_CORE_PROCESS_LIMIT
];
...
...
@@ -408,41 +408,44 @@ LITE_OS_SEC_TEXT STATIC UINT32 GetTid(UINT32 serviceHandle, UINT32 *taskID)
if
(
serviceHandle
>=
MAX_SERVICE_NUM
)
{
return
-
EINVAL
;
}
(
VOID
)
LOS_MuxLock
(
&
g_serviceHandleMapMux
,
LOS_WAIT_FOREVER
);
#if (USE_TASKID_AS_HANDLE == YES)
*
taskID
=
serviceHandle
?
serviceHandle
:
g_cmsTask
.
taskID
;
(
VOID
)
LOS_MuxUnlock
(
&
g_serviceHandleMapMux
);
return
LOS_OK
;
#else
if
(
g_serviceHandleMap
[
serviceHandle
].
status
==
HANDLE_REGISTED
)
{
*
taskID
=
g_serviceHandleMap
[
serviceHandle
].
taskID
;
(
VOID
)
LOS_MuxUnlock
(
&
g_serviceHandleMapMux
);
return
LOS_OK
;
}
(
VOID
)
LOS_MuxUnlock
(
&
g_serviceHandleMapMux
);
return
-
EINVAL
;
#endif
}
LITE_OS_SEC_TEXT
STATIC
UINT32
GenerateServiceHandle
(
UINT32
taskID
,
HandleStatus
status
,
UINT32
*
serviceHandle
)
{
(
VOID
)
LOS_MuxLock
(
&
g_serviceHandleMapMux
,
LOS_WAIT_FOREVER
);
#if (USE_TASKID_AS_HANDLE == YES)
*
serviceHandle
=
taskID
?
taskID
:
LOS_CurTaskIDGet
();
/* if taskID is 0, return curTaskID */
if
(
*
serviceHandle
==
g_cmsTask
.
taskID
)
{
return
-
EINVAL
;
if
(
*
serviceHandle
!=
g_cmsTask
.
taskID
)
{
(
VOID
)
LOS_MuxUnlock
(
&
g_serviceHandleMapMux
);
return
LOS_OK
;
}
return
LOS_OK
;
#else
UINT32
i
;
(
VOID
)
LOS_MuxLock
(
&
g_serviceHandleMapMux
,
LOS_WAIT_FOREVER
);
for
(
i
=
1
;
i
<
MAX_SERVICE_NUM
;
i
++
)
{
for
(
UINT32
i
=
1
;
i
<
MAX_SERVICE_NUM
;
i
++
)
{
if
(
g_serviceHandleMap
[
i
].
status
==
HANDLE_NOT_USED
)
{
g_serviceHandleMap
[
i
].
taskID
=
taskID
;
g_serviceHandleMap
[
i
].
status
=
status
;
*
serviceHandle
=
i
;
(
VOID
)
LOS_MuxUn
L
ock
(
&
g_serviceHandleMapMux
);
(
VOID
)
LOS_MuxUn
l
ock
(
&
g_serviceHandleMapMux
);
return
LOS_OK
;
}
}
#endif
(
VOID
)
LOS_MuxUnlock
(
&
g_serviceHandleMapMux
);
return
-
EINVAL
;
#endif
}
LITE_OS_SEC_TEXT
STATIC
VOID
RefreshServiceHandle
(
UINT32
serviceHandle
,
UINT32
result
)
...
...
@@ -627,21 +630,29 @@ LITE_OS_SEC_TEXT STATIC UINT32 SetCms(UINTPTR maxMsgSize)
LITE_OS_SEC_TEXT
STATIC
BOOL
IsCmsSet
(
VOID
)
{
BOOL
ret
;
(
VOID
)
LOS_MuxLock
(
&
g_serviceHandleMapMux
,
LOS_WAIT_FOREVER
);
#if (USE_TASKID_AS_HANDLE == YES)
ret
urn
g_cmsTask
.
status
==
HANDLE_REGISTED
;
ret
=
g_cmsTask
.
status
==
HANDLE_REGISTED
;
#else
ret
urn
g_serviceHandleMap
[
0
].
status
==
HANDLE_REGISTED
;
ret
=
g_serviceHandleMap
[
0
].
status
==
HANDLE_REGISTED
;
#endif
(
VOID
)
LOS_MuxUnlock
(
&
g_serviceHandleMapMux
);
return
ret
;
}
LITE_OS_SEC_TEXT
STATIC
BOOL
IsCmsTask
(
UINT32
taskID
)
{
BOOL
ret
;
(
VOID
)
LOS_MuxLock
(
&
g_serviceHandleMapMux
,
LOS_WAIT_FOREVER
);
#if (USE_TASKID_AS_HANDLE == YES)
ret
urn
IsCmsSet
()
?
(
OS_TCB_FROM_TID
(
taskID
)
->
processID
==
OS_TCB_FROM_TID
(
g_cmsTask
.
taskID
)
->
processID
)
:
FALSE
;
ret
=
IsCmsSet
()
?
(
OS_TCB_FROM_TID
(
taskID
)
->
processID
==
OS_TCB_FROM_TID
(
g_cmsTask
.
taskID
)
->
processID
)
:
FALSE
;
#else
ret
urn
IsCmsSet
()
?
(
OS_TCB_FROM_TID
(
taskID
)
->
processID
==
ret
=
IsCmsSet
()
?
(
OS_TCB_FROM_TID
(
taskID
)
->
processID
==
OS_TCB_FROM_TID
(
g_serviceHandleMap
[
0
].
taskID
)
->
processID
)
:
FALSE
;
#endif
(
VOID
)
LOS_MuxUnlock
(
&
g_serviceHandleMapMux
);
return
ret
;
}
LITE_OS_SEC_TEXT
STATIC
BOOL
IsTaskAlive
(
UINT32
taskID
)
...
...
@@ -816,9 +827,12 @@ LITE_OS_SEC_TEXT STATIC UINT32 CheckMsgSize(IpcMsg *msg)
totalSize
+=
obj
->
content
.
ptr
.
buffSz
;
}
}
(
VOID
)
LOS_MuxUnlock
(
&
g_serviceHandleMapMux
);
if
(
totalSize
>
g_cmsTask
.
maxMsgSize
)
{
(
VOID
)
LOS_MuxUnlock
(
&
g_serviceHandleMapMux
);
return
-
EINVAL
;
}
(
VOID
)
LOS_MuxUnlock
(
&
g_serviceHandleMapMux
);
return
LOS_OK
;
}
...
...
@@ -1200,7 +1214,9 @@ LITE_OS_SEC_TEXT STATIC UINT32 HandleCmsCmd(CmsCmdContent *content)
if
(
ret
==
LOS_OK
)
{
ret
=
copy_to_user
((
void
*
)
content
,
(
const
void
*
)(
&
localContent
),
sizeof
(
CmsCmdContent
));
}
(
VOID
)
LOS_MuxLock
(
&
g_serviceHandleMapMux
,
LOS_WAIT_FOREVER
);
AddServiceAccess
(
g_cmsTask
.
taskID
,
localContent
.
serviceHandle
);
(
VOID
)
LOS_MuxUnlock
(
&
g_serviceHandleMapMux
);
break
;
case
CMS_REMOVE_HANDLE
:
if
(
localContent
.
serviceHandle
>=
MAX_SERVICE_NUM
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录