1 Star 0 Fork 3

xc13AK/rhino

forked from AliOS Things/rhino 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
k_dyn_mem_proc.c 1.44 KB
一键复制 编辑 原始数据 按行查看 历史
skylarCai 提交于 2021-05-10 17:09 . init version
/*
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
*/
#include "k_api.h"
#if (RHINO_CONFIG_KOBJ_DYN_ALLOC > 0)
#if (RHINO_CONFIG_USER_SPACE > 0)
void krhino_utask_free_res(ktask_t *task);
#endif
void dyn_mem_proc_task(void *arg)
{
CPSR_ALLOC();
size_t i;
kstat_t ret;
res_free_t *res_free;
res_free_t tmp;
(void)arg;
while (1) {
ret = krhino_sem_take(&g_res_sem, RHINO_WAIT_FOREVER);
if (ret != RHINO_SUCCESS) {
k_err_proc(RHINO_DYN_MEM_PROC_ERR);
}
while (1) {
RHINO_CRITICAL_ENTER();
if (!is_klist_empty(&g_res_list)) {
res_free = krhino_list_entry(g_res_list.next, res_free_t, res_list);
klist_rm(&res_free->res_list);
RHINO_CRITICAL_EXIT();
#if (RHINO_CONFIG_USER_SPACE > 0)
krhino_utask_free_res((ktask_t *)(res_free->res[1]));
#endif
memcpy(&tmp, res_free, sizeof(res_free_t));
for (i = 0; i < tmp.cnt; i++) {
krhino_mm_free(tmp.res[i]);
}
} else {
RHINO_CRITICAL_EXIT();
break;
}
}
}
}
__attribute__((weak)) void dyn_mem_proc_task_start(void)
{
krhino_task_create(&g_dyn_task, "dyn_mem_proc_task", 0, RHINO_CONFIG_K_DYN_MEM_TASK_PRI,
0, g_dyn_task_stack, RHINO_CONFIG_K_DYN_TASK_STACK, dyn_mem_proc_task, 1);
}
#endif
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/xc13AK/rhino.git
git@gitee.com:xc13AK/rhino.git
xc13AK
rhino
rhino
master

搜索帮助