Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Kernel Liteos A
提交
ea45982e
K
Kernel Liteos A
项目概览
OpenHarmony
/
Kernel Liteos A
大约 2 年 前同步成功
通知
475
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看板
提交
ea45982e
编写于
10月 28, 2021
作者:
O
openharmony_ci
提交者:
Gitee
10月 28, 2021
浏览文件
操作
浏览文件
下载
差异文件
!669 feat: 进程rlimit修改为动态分配,减少静态内存占用
Merge pull request !669 from zhushengle/rlimit
上级
91c1737d
cf8446c9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
38 addition
and
6 deletion
+38
-6
compat/posix/src/misc.c
compat/posix/src/misc.c
+32
-5
kernel/base/core/los_process.c
kernel/base/core/los_process.c
+5
-0
kernel/base/include/los_process_pri.h
kernel/base/include/los_process_pri.h
+1
-1
未找到文件。
compat/posix/src/misc.c
浏览文件 @
ea45982e
...
@@ -40,6 +40,7 @@
...
@@ -40,6 +40,7 @@
#include "los_process_pri.h"
#include "los_process_pri.h"
#include "los_hw.h"
#include "los_hw.h"
static
struct
rlimit
g_defaultLimit
=
{
0
};
/*
/*
* Supply some suitable values for constants that may not be present
* Supply some suitable values for constants that may not be present
* in all configurations.
* in all configurations.
...
@@ -154,7 +155,9 @@ pid_t getpid(void)
...
@@ -154,7 +155,9 @@ pid_t getpid(void)
int
getrlimit
(
int
resource
,
struct
rlimit
*
rlim
)
int
getrlimit
(
int
resource
,
struct
rlimit
*
rlim
)
{
{
unsigned
int
intSave
;
LosProcessCB
*
pcb
=
OsCurrProcessGet
();
LosProcessCB
*
pcb
=
OsCurrProcessGet
();
struct
rlimit
*
resourceLimit
=
pcb
->
resourceLimit
;
switch
(
resource
)
{
switch
(
resource
)
{
case
RLIMIT_NOFILE
:
case
RLIMIT_NOFILE
:
...
@@ -163,8 +166,15 @@ int getrlimit(int resource, struct rlimit *rlim)
...
@@ -163,8 +166,15 @@ int getrlimit(int resource, struct rlimit *rlim)
default:
default:
return
-
EINVAL
;
return
-
EINVAL
;
}
}
rlim
->
rlim_cur
=
pcb
->
pl_rlimit
[
resource
].
rlim_cur
;
rlim
->
rlim_max
=
pcb
->
pl_rlimit
[
resource
].
rlim_max
;
if
(
resourceLimit
==
NULL
)
{
resourceLimit
=
&
g_defaultLimit
;
}
SCHEDULER_LOCK
(
intSave
);
rlim
->
rlim_cur
=
resourceLimit
[
resource
].
rlim_cur
;
rlim
->
rlim_max
=
resourceLimit
[
resource
].
rlim_max
;
SCHEDULER_UNLOCK
(
intSave
);
return
0
;
return
0
;
}
}
...
@@ -175,6 +185,8 @@ int getrlimit(int resource, struct rlimit *rlim)
...
@@ -175,6 +185,8 @@ int getrlimit(int resource, struct rlimit *rlim)
#endif
#endif
int
setrlimit
(
int
resource
,
const
struct
rlimit
*
rlim
)
int
setrlimit
(
int
resource
,
const
struct
rlimit
*
rlim
)
{
{
unsigned
int
intSave
;
struct
rlimit
*
resourceLimit
=
NULL
;
LosProcessCB
*
pcb
=
OsCurrProcessGet
();
LosProcessCB
*
pcb
=
OsCurrProcessGet
();
if
(
rlim
->
rlim_cur
>
rlim
->
rlim_max
)
{
if
(
rlim
->
rlim_cur
>
rlim
->
rlim_max
)
{
...
@@ -194,8 +206,23 @@ int setrlimit(int resource, const struct rlimit *rlim)
...
@@ -194,8 +206,23 @@ int setrlimit(int resource, const struct rlimit *rlim)
default:
default:
return
-
EINVAL
;
return
-
EINVAL
;
}
}
pcb
->
pl_rlimit
[
resource
].
rlim_cur
=
rlim
->
rlim_cur
;
pcb
->
pl_rlimit
[
resource
].
rlim_max
=
rlim
->
rlim_max
;
if
(
pcb
->
resourceLimit
==
NULL
)
{
resourceLimit
=
LOS_MemAlloc
((
VOID
*
)
m_aucSysMem0
,
RLIM_NLIMITS
*
sizeof
(
struct
rlimit
));
if
(
resourceLimit
==
NULL
)
{
return
-
EINVAL
;
}
}
SCHEDULER_LOCK
(
intSave
);
if
(
pcb
->
resourceLimit
==
NULL
)
{
pcb
->
resourceLimit
=
resourceLimit
;
resourceLimit
=
NULL
;
}
pcb
->
resourceLimit
[
resource
].
rlim_cur
=
rlim
->
rlim_cur
;
pcb
->
resourceLimit
[
resource
].
rlim_max
=
rlim
->
rlim_max
;
SCHEDULER_UNLOCK
(
intSave
);
(
VOID
)
LOS_MemFree
((
VOID
*
)
m_aucSysMem0
,
resourceLimit
);
return
0
;
return
0
;
}
}
\ No newline at end of file
kernel/base/core/los_process.c
浏览文件 @
ea45982e
...
@@ -378,6 +378,11 @@ LITE_OS_SEC_TEXT VOID OsProcessResourcesToFree(LosProcessCB *processCB)
...
@@ -378,6 +378,11 @@ LITE_OS_SEC_TEXT VOID OsProcessResourcesToFree(LosProcessCB *processCB)
(
VOID
)
memset_s
(
&
(
processCB
->
ipcInfo
),
sizeof
(
ProcIpcInfo
),
0
,
sizeof
(
ProcIpcInfo
));
(
VOID
)
memset_s
(
&
(
processCB
->
ipcInfo
),
sizeof
(
ProcIpcInfo
),
0
,
sizeof
(
ProcIpcInfo
));
}
}
#endif
#endif
if
(
processCB
->
resourceLimit
!=
NULL
)
{
(
VOID
)
LOS_MemFree
((
VOID
*
)
m_aucSysMem0
,
processCB
->
resourceLimit
);
processCB
->
resourceLimit
=
NULL
;
}
}
}
LITE_OS_SEC_TEXT
STATIC
VOID
OsRecycleZombiesProcess
(
LosProcessCB
*
childCB
,
ProcessGroup
**
group
)
LITE_OS_SEC_TEXT
STATIC
VOID
OsRecycleZombiesProcess
(
LosProcessCB
*
childCB
,
ProcessGroup
**
group
)
...
...
kernel/base/include/los_process_pri.h
浏览文件 @
ea45982e
...
@@ -127,7 +127,7 @@ typedef struct ProcessCB {
...
@@ -127,7 +127,7 @@ typedef struct ProcessCB {
#ifdef LOSCFG_KERNEL_CPUP
#ifdef LOSCFG_KERNEL_CPUP
OsCpupBase
processCpup
;
/**< Process cpu usage */
OsCpupBase
processCpup
;
/**< Process cpu usage */
#endif
#endif
struct
rlimit
pl_rlimit
[
RLIM_NLIMITS
]
;
struct
rlimit
*
resourceLimit
;
}
LosProcessCB
;
}
LosProcessCB
;
#define CLONE_VM 0x00000100
#define CLONE_VM 0x00000100
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录