Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
鸿蒙内核源码分析
注释鸿蒙内核源码
提交
af76a9f9
注释鸿蒙内核源码
项目概览
鸿蒙内核源码分析
/
注释鸿蒙内核源码
通知
270
Star
29
Fork
11
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
106
Wiki
分析
仓库
DevOps
项目成员
Pages
注释鸿蒙内核源码
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
106
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
af76a9f9
编写于
4月 12, 2021
作者:
鸿蒙内核源码分析
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
进程回收过程注解
百万汉字注解 + 百篇博客分析 => 挖透鸿蒙内核源码
https://my.oschina.net/weharmony
上级
87dc895f
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
330 addition
and
328 deletion
+330
-328
kernel/base/core/los_process.c
kernel/base/core/los_process.c
+74
-72
kernel/base/core/los_task.c
kernel/base/core/los_task.c
+4
-4
kernel/base/include/los_process_pri.h
kernel/base/include/los_process_pri.h
+4
-4
kernel/base/include/los_task_pri.h
kernel/base/include/los_task_pri.h
+2
-2
kernel/include/los_typedef.h
kernel/include/los_typedef.h
+245
-245
zzz/git/push.sh
zzz/git/push.sh
+1
-1
未找到文件。
kernel/base/core/los_process.c
浏览文件 @
af76a9f9
...
...
@@ -260,7 +260,7 @@ STATIC LosProcessCB *OsFindExitChildProcess(const LosProcessCB *processCB, INT32
PRINT_INFO
(
"%s is find the exit child : %d failed in parent : %u
\n
"
,
__FUNCTION__
,
childPid
,
processCB
->
processID
);
return
NULL
;
}
//
等待唤醒任务
//
唤醒等待wakePID结束的任务,
STATIC
INLINE
VOID
OsWaitWakeTask
(
LosTaskCB
*
taskCB
,
UINT32
wakePID
)
{
taskCB
->
waitID
=
wakePID
;
...
...
@@ -269,7 +269,7 @@ STATIC INLINE VOID OsWaitWakeTask(LosTaskCB *taskCB, UINT32 wakePID)
LOS_MpSchedule
(
OS_MP_CPU_ALL
);
#endif
}
//唤醒等待参数进程结束的任务
STATIC
BOOL
OsWaitWakeSpecifiedProcess
(
LOS_DL_LIST
*
head
,
const
LosProcessCB
*
processCB
,
LOS_DL_LIST
**
anyList
)
{
LOS_DL_LIST
*
list
=
head
;
...
...
@@ -277,17 +277,17 @@ STATIC BOOL OsWaitWakeSpecifiedProcess(LOS_DL_LIST *head, const LosProcessCB *pr
UINT32
pid
=
0
;
BOOL
find
=
FALSE
;
while
(
list
->
pstNext
!=
head
)
{
taskCB
=
OS_TCB_FROM_PENDLIST
(
LOS_DL_LIST_FIRST
(
list
));
if
((
taskCB
->
waitFlag
==
OS_PROCESS_WAIT_PRO
)
&&
(
taskCB
->
waitID
==
processCB
->
processID
))
{
while
(
list
->
pstNext
!=
head
)
{
//遍历等待链表 processCB->waitList
taskCB
=
OS_TCB_FROM_PENDLIST
(
LOS_DL_LIST_FIRST
(
list
));
//一个一个来
if
((
taskCB
->
waitFlag
==
OS_PROCESS_WAIT_PRO
)
&&
(
taskCB
->
waitID
==
processCB
->
processID
))
{
//符合OS_PROCESS_WAIT_PRO方式的
if
(
pid
==
0
)
{
pid
=
processCB
->
processID
;
find
=
TRUE
;
}
else
{
pid
=
processCB
->
processID
;
//等待的进程
find
=
TRUE
;
//找到了
}
else
{
// @note_thinking 这个代码有点多余吧,会执行到吗?
pid
=
OS_INVALID_VALUE
;
}
OsWaitWakeTask
(
taskCB
,
pid
);
OsWaitWakeTask
(
taskCB
,
pid
);
//唤醒这个任务,此时会切到 LOS_Wait runTask->waitFlag = 0;处运行
continue
;
}
...
...
@@ -300,38 +300,38 @@ STATIC BOOL OsWaitWakeSpecifiedProcess(LOS_DL_LIST *head, const LosProcessCB *pr
return
find
;
}
//检查父进程的等待任务并唤醒父进程
//检查父进程的等待任务并唤醒父进程
去处理等待任务
STATIC
VOID
OsWaitCheckAndWakeParentProcess
(
LosProcessCB
*
parentCB
,
const
LosProcessCB
*
processCB
)
{
LOS_DL_LIST
*
head
=
&
parentCB
->
waitList
;
//
LOS_DL_LIST
*
head
=
&
parentCB
->
waitList
;
LOS_DL_LIST
*
list
=
NULL
;
LosTaskCB
*
taskCB
=
NULL
;
BOOL
findSpecified
=
FALSE
;
if
(
LOS_ListEmpty
(
&
parentCB
->
waitList
))
{
return
;
if
(
LOS_ListEmpty
(
&
parentCB
->
waitList
))
{
//父进程中是否有在等待子进程退出的任务?
return
;
//没有就退出
}
findSpecified
=
OsWaitWakeSpecifiedProcess
(
head
,
processCB
,
&
list
);
findSpecified
=
OsWaitWakeSpecifiedProcess
(
head
,
processCB
,
&
list
);
//找到指定的任务
if
(
findSpecified
==
TRUE
)
{
/* No thread is waiting for any child process to finish */
if
(
LOS_ListEmpty
(
&
parentCB
->
waitList
))
{
return
;
if
(
LOS_ListEmpty
(
&
parentCB
->
waitList
))
{
//没有线程正在等待任何子进程结束
return
;
//已经处理完了,注意在OsWaitWakeSpecifiedProcess中做了频繁的任务切换
}
else
if
(
!
LOS_ListEmpty
(
&
parentCB
->
childrenList
))
{
/* Other child processes exist, and other threads that are waiting
* for the child to finish continue to wait
*/
*/
//存在其他子进程,正在等待它们的子进程结束而将继续等待
return
;
}
}
/* Waiting threads are waiting for a specified child process to finish */
if
(
list
==
NULL
)
{
if
(
list
==
NULL
)
{
//等待线程正在等待指定的子进程结束
return
;
}
/* No child processes exist and all waiting threads are awakened */
if
(
findSpecified
==
TRUE
)
{
if
(
findSpecified
==
TRUE
)
{
//所有等待的任务都被一一唤醒
while
(
list
->
pstNext
!=
head
)
{
taskCB
=
OS_TCB_FROM_PENDLIST
(
LOS_DL_LIST_FIRST
(
list
));
OsWaitWakeTask
(
taskCB
,
OS_INVALID_VALUE
);
...
...
@@ -339,7 +339,7 @@ STATIC VOID OsWaitCheckAndWakeParentProcess(LosProcessCB *parentCB, const LosPro
return
;
}
while
(
list
->
pstNext
!=
head
)
{
while
(
list
->
pstNext
!=
head
)
{
//处理 OS_PROCESS_WAIT_GID 标签
taskCB
=
OS_TCB_FROM_PENDLIST
(
LOS_DL_LIST_FIRST
(
list
));
if
(
taskCB
->
waitFlag
==
OS_PROCESS_WAIT_GID
)
{
if
(
taskCB
->
waitID
!=
processCB
->
group
->
groupID
)
{
...
...
@@ -491,9 +491,9 @@ STATIC VOID OsProcessNaturalExit(LosTaskCB *runTask, UINT32 status)
LOS_ListDelete
(
&
processCB
->
subordinateGroupList
);
//和志同道合的朋友们永别了,注意家里可不一定是朋友的,所有各有链表.
LOS_ListTailInsert
(
&
processCB
->
group
->
exitProcessList
,
&
processCB
->
subordinateGroupList
);
//挂到进程组消亡链表,朋友中,永别的可不止我一个.
OsWaitCheckAndWakeParentProcess
(
parentCB
,
processCB
);
//检查父进程的等待任务
并唤醒任务,此处将会切换
到其他任务运行.
OsWaitCheckAndWakeParentProcess
(
parentCB
,
processCB
);
//检查父进程的等待任务
链表并唤醒对应的任务,此处将会频繁的切
到其他任务运行.
OsDealAliveChildProcess
(
processCB
);
//
安排孩子进程,上面和长辈,同辈,朋友告别了,接下来跟娃娃们告别.
OsDealAliveChildProcess
(
processCB
);
//
孩子们要怎么处理,移交给(用户态和内核态)根进程
processCB
->
processStatus
|=
OS_PROCESS_STATUS_ZOMBIES
;
//贴上僵死进程的标签
...
...
@@ -1142,16 +1142,18 @@ LITE_OS_SEC_TEXT VOID OsWaitSignalToWakeProcess(LosProcessCB *processCB)
return
;
}
//将任务插入waitList链表
//将任务挂入进程的waitList链表,表示这个任务在等待某个进程的退出
//当被等待进程退出时候会将自己挂到父进程的退出子进程链表和进程组的退出进程链表.
//
STATIC
VOID
OsWaitInsertWaitListInOrder
(
LosTaskCB
*
runTask
,
LosProcessCB
*
processCB
)
{
LOS_DL_LIST
*
head
=
&
processCB
->
waitList
;
LOS_DL_LIST
*
list
=
head
;
LosTaskCB
*
taskCB
=
NULL
;
(
VOID
)
OsTaskWait
(
&
processCB
->
waitList
,
LOS_WAIT_FOREVER
,
FALSE
);
LOS_ListDelete
(
&
runTask
->
pendList
);
if
(
runTask
->
waitFlag
==
OS_PROCESS_WAIT_PRO
)
{
(
VOID
)
OsTaskWait
(
&
processCB
->
waitList
,
LOS_WAIT_FOREVER
,
FALSE
);
//将当前任务挂入waitList链表,FALSE代表不调度.
LOS_ListDelete
(
&
runTask
->
pendList
);
//将当前任务从 pendlist链表上摘除.
if
(
runTask
->
waitFlag
==
OS_PROCESS_WAIT_PRO
)
{
//等待
LOS_ListHeadInsert
(
&
processCB
->
waitList
,
&
runTask
->
pendList
);
return
;
}
else
if
(
runTask
->
waitFlag
==
OS_PROCESS_WAIT_GID
)
{
...
...
@@ -1179,7 +1181,7 @@ STATIC VOID OsWaitInsertWaitListInOrder(LosTaskCB *runTask, LosProcessCB *proces
LOS_ListHeadInsert
(
list
,
&
runTask
->
pendList
);
return
;
}
//
等待设置标签
//
设置等待子进程退出方式方法
STATIC
UINT32
OsWaitSetFlag
(
const
LosProcessCB
*
processCB
,
INT32
pid
,
LosProcessCB
**
child
)
{
LosProcessCB
*
childCB
=
NULL
;
...
...
@@ -1187,49 +1189,49 @@ STATIC UINT32 OsWaitSetFlag(const LosProcessCB *processCB, INT32 pid, LosProcess
LosTaskCB
*
runTask
=
OsCurrTaskGet
();
UINT32
ret
;
if
(
pid
>
0
)
{
//等待进程号为pid的子进程
,回收指定pid的子进程
if
(
pid
>
0
)
{
//等待进程号为pid的子进程
结束
/* Wait for the child process whose process number is pid. */
childCB
=
OsFindExitChildProcess
(
processCB
,
pid
);
if
(
childCB
!=
NULL
)
{
goto
WAIT_BACK
;
childCB
=
OsFindExitChildProcess
(
processCB
,
pid
);
//看能否从退出的孩子链表中找到PID
if
(
childCB
!=
NULL
)
{
//找到了,确实有一个已经退出的PID,注意一个进程退出时会挂到父进程的exitChildList上
goto
WAIT_BACK
;
//直接成功返回
}
ret
=
OsFindChildProcess
(
processCB
,
pid
);
ret
=
OsFindChildProcess
(
processCB
,
pid
);
//看能否从现有的孩子链表中找到PID
if
(
ret
!=
LOS_OK
)
{
return
LOS_ECHILD
;
return
LOS_ECHILD
;
//参数进程并没有这个PID孩子,返回孩子进程失败.
}
runTask
->
waitFlag
=
OS_PROCESS_WAIT_PRO
;
runTask
->
waitID
=
pid
;
runTask
->
waitFlag
=
OS_PROCESS_WAIT_PRO
;
//设置当前任务的等待类型
runTask
->
waitID
=
pid
;
//当前任务要等待进程ID结束
}
else
if
(
pid
==
0
)
{
//等待同一进程组中的任何子进程
/* Wait for any child process in the same process group */
childCB
=
OsFindGroupExitProcess
(
processCB
->
group
,
OS_INVALID_VALUE
);
if
(
childCB
!=
NULL
)
{
goto
WAIT_BACK
;
childCB
=
OsFindGroupExitProcess
(
processCB
->
group
,
OS_INVALID_VALUE
);
//看能否从退出的孩子链表中找到PID
if
(
childCB
!=
NULL
)
{
//找到了,确实有一个已经退出的PID
goto
WAIT_BACK
;
//直接成功返回
}
runTask
->
waitID
=
processCB
->
group
->
groupID
;
runTask
->
waitFlag
=
OS_PROCESS_WAIT_GID
;
}
else
if
(
pid
==
-
1
)
{
//
回收任意子进程(相当于wait)
runTask
->
waitID
=
processCB
->
group
->
groupID
;
//等待进程组的任意一个子进程结束
runTask
->
waitFlag
=
OS_PROCESS_WAIT_GID
;
//设置当前任务的等待类型
}
else
if
(
pid
==
-
1
)
{
//
等待任意子进程
/* Wait for any child process */
childCB
=
OsFindExitChildProcess
(
processCB
,
OS_INVALID_VALUE
);
if
(
childCB
!=
NULL
)
{
childCB
=
OsFindExitChildProcess
(
processCB
,
OS_INVALID_VALUE
);
//看能否从退出的孩子链表中找到PID
if
(
childCB
!=
NULL
)
{
//找到了,确实有一个已经退出的PID
goto
WAIT_BACK
;
}
runTask
->
waitID
=
pid
;
runTask
->
waitFlag
=
OS_PROCESS_WAIT_ANY
;
}
else
{
/* pid < -1 */
//
回收
指定进程组内为|pid|的所有子进程
runTask
->
waitID
=
pid
;
//等待PID,这个PID可以和当前进程没有任何关系
runTask
->
waitFlag
=
OS_PROCESS_WAIT_ANY
;
//设置当前任务的等待类型
}
else
{
/* pid < -1 */
//
等待
指定进程组内为|pid|的所有子进程
/* Wait for any child process whose group number is the pid absolute value. */
group
=
OsFindProcessGroup
(
-
pid
);
group
=
OsFindProcessGroup
(
-
pid
);
//先通过PID找到进程组
if
(
group
==
NULL
)
{
return
LOS_ECHILD
;
}
childCB
=
OsFindGroupExitProcess
(
group
,
OS_INVALID_VALUE
);
childCB
=
OsFindGroupExitProcess
(
group
,
OS_INVALID_VALUE
);
//在进程组里任意一个已经退出的子进程
if
(
childCB
!=
NULL
)
{
goto
WAIT_BACK
;
}
runTask
->
waitID
=
-
pid
;
runTask
->
waitFlag
=
OS_PROCESS_WAIT_GID
;
runTask
->
waitID
=
-
pid
;
//此处用负数是为了和(pid == 0)以示区别,因为二者的waitFlag都一样.
runTask
->
waitFlag
=
OS_PROCESS_WAIT_GID
;
//设置当前任务的等待类型
}
WAIT_BACK:
...
...
@@ -1244,12 +1246,12 @@ STATIC INT32 OsWaitRecycleChildPorcess(const LosProcessCB *childCB, UINT32 intSa
UINT16
mode
=
childCB
->
processMode
;
INT32
exitCode
=
childCB
->
exitCode
;
OsRecycleZombiesProcess
((
LosProcessCB
*
)
childCB
,
&
group
);
OsRecycleZombiesProcess
((
LosProcessCB
*
)
childCB
,
&
group
);
//回收僵尸进程
SCHEDULER_UNLOCK
(
intSave
);
if
(
status
!=
NULL
)
{
if
(
mode
==
OS_USER_MODE
)
{
(
VOID
)
LOS_ArchCopyToUser
((
VOID
*
)
status
,
(
const
VOID
*
)(
&
(
exitCode
)),
sizeof
(
INT32
));
if
(
mode
==
OS_USER_MODE
)
{
//孩子为用户态进程
(
VOID
)
LOS_ArchCopyToUser
((
VOID
*
)
status
,
(
const
VOID
*
)(
&
(
exitCode
)),
sizeof
(
INT32
));
//从内核空间拷贝退出码
}
else
{
*
status
=
exitCode
;
}
...
...
@@ -1260,12 +1262,12 @@ STATIC INT32 OsWaitRecycleChildPorcess(const LosProcessCB *childCB, UINT32 intSa
}
//检查要等待的孩子进程
STATIC
INT32
OsWaitChildProcessCheck
(
LosProcessCB
*
processCB
,
INT32
pid
,
LosProcessCB
**
childCB
)
{
{
//当进程没有孩子且没有退出的孩子进程
if
(
LOS_ListEmpty
(
&
(
processCB
->
childrenList
))
&&
LOS_ListEmpty
(
&
(
processCB
->
exitChildList
)))
{
return
LOS_ECHILD
;
}
return
OsWaitSetFlag
(
processCB
,
pid
,
childCB
);
return
OsWaitSetFlag
(
processCB
,
pid
,
childCB
);
//设置等待子进程退出方式方法
}
STATIC
UINT32
OsWaitOptionsCheck
(
UINT32
options
)
...
...
@@ -1306,38 +1308,38 @@ LITE_OS_SEC_TEXT INT32 LOS_Wait(INT32 pid, USER INT32 *status, UINT32 options, V
processCB
=
OsCurrProcessGet
();
//获取当前进程
runTask
=
OsCurrTaskGet
();
//获取当前任务
ret
=
OsWaitChildProcessCheck
(
processCB
,
pid
,
&
childCB
);
ret
=
OsWaitChildProcessCheck
(
processCB
,
pid
,
&
childCB
);
//先检查下看能不能找到参数要求的退出子进程
if
(
ret
!=
LOS_OK
)
{
pid
=
-
ret
;
goto
ERROR
;
}
if
(
childCB
!=
NULL
)
{
return
OsWaitRecycleChildPorcess
(
childCB
,
intSave
,
status
);
if
(
childCB
!=
NULL
)
{
//找到了进程
return
OsWaitRecycleChildPorcess
(
childCB
,
intSave
,
status
);
//回收进程
}
if
((
options
&
LOS_WAIT_WNOHANG
)
!=
0
)
{
runTask
->
waitFlag
=
0
;
pid
=
0
;
//没有找到,看是否要返回还是去做个登记
if
((
options
&
LOS_WAIT_WNOHANG
)
!=
0
)
{
//不登记的方式,立即返回
runTask
->
waitFlag
=
0
;
//等待标识置0
pid
=
0
;
//这里置0,是为了 return 0
goto
ERROR
;
}
OsWaitInsertWaitListInOrder
(
runTask
,
processCB
);
OsSchedResched
();
//等待孩子进程退出
OsWaitInsertWaitListInOrder
(
runTask
,
processCB
);
//将当前任务挂入进程waitList链表
//发起调度的目的是为了让出CPU,让其他进程/任务运行
OsSchedResched
();
//发起调度
runTask
->
waitFlag
=
0
;
if
(
runTask
->
waitID
==
OS_INVALID_VALUE
)
{
pid
=
-
LOS_ECHILD
;
pid
=
-
LOS_ECHILD
;
//没有此子进程
goto
ERROR
;
}
childCB
=
OS_PCB_FROM_PID
(
runTask
->
waitID
);
if
(
!
(
childCB
->
processStatus
&
OS_PROCESS_STATUS_ZOMBIES
))
{
pid
=
-
LOS_ESRCH
;
childCB
=
OS_PCB_FROM_PID
(
runTask
->
waitID
);
//获取当前任务的等待子进程ID
if
(
!
(
childCB
->
processStatus
&
OS_PROCESS_STATUS_ZOMBIES
))
{
//子进程非僵死进程
pid
=
-
LOS_ESRCH
;
//没有此进程
goto
ERROR
;
}
//回收僵死进程
return
OsWaitRecycleChildPorcess
(
childCB
,
intSave
,
status
);
ERROR:
...
...
kernel/base/core/los_task.c
浏览文件 @
af76a9f9
...
...
@@ -436,16 +436,16 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsIdleTaskCreate(VOID)
UINT32
ret
;
TSK_INIT_PARAM_S
taskInitParam
;
Percpu
*
perCpu
=
OsPercpuGet
();
//获取CPU信息
UINT32
*
idleTaskID
=
&
perCpu
->
idleTaskID
;
//
指定CPU的
空闲任务
UINT32
*
idleTaskID
=
&
perCpu
->
idleTaskID
;
//
每个CPU都有一个
空闲任务
(
VOID
)
memset_s
((
VOID
*
)(
&
taskInitParam
),
sizeof
(
TSK_INIT_PARAM_S
),
0
,
sizeof
(
TSK_INIT_PARAM_S
));
//任务初始参数清0
taskInitParam
.
pfnTaskEntry
=
(
TSK_ENTRY_FUNC
)
OsIdleTask
;
//入口函数
指定idle
taskInitParam
.
uwStackSize
=
LOSCFG_BASE_CORE_TSK_IDLE_STACK_SIZE
;
//任务栈大小
taskInitParam
.
pfnTaskEntry
=
(
TSK_ENTRY_FUNC
)
OsIdleTask
;
//入口函数
taskInitParam
.
uwStackSize
=
LOSCFG_BASE_CORE_TSK_IDLE_STACK_SIZE
;
//任务栈大小
2K
taskInitParam
.
pcName
=
"Idle"
;
//任务名称 叫pcName有点怪怪的,不能换个撒
taskInitParam
.
usTaskPrio
=
OS_TASK_PRIORITY_LOWEST
;
//默认最低优先级 31
taskInitParam
.
uwResved
=
OS_TASK_FLAG_IDLEFLAG
;
//默认idle flag
#if (LOSCFG_KERNEL_SMP == YES)//CPU多核情况
taskInitParam
.
usCpuAffiMask
=
CPUID_TO_AFFI_MASK
(
ArchCurrCpuid
());
//
意思是归于哪个CPU核调度,
taskInitParam
.
usCpuAffiMask
=
CPUID_TO_AFFI_MASK
(
ArchCurrCpuid
());
//
每个idle任务只在单独的cpu上运行
#endif
ret
=
LOS_TaskCreate
(
idleTaskID
,
&
taskInitParam
);
//创建task并申请调度,
OS_TCB_FROM_TID
(
*
idleTaskID
)
->
taskStatus
|=
OS_TASK_FLAG_SYSTEM_TASK
;
//设置task状态为系统任务,系统任务运行在内核态.
...
...
kernel/base/include/los_process_pri.h
浏览文件 @
af76a9f9
...
...
@@ -449,17 +449,17 @@ STATIC INLINE User *OsCurrUserGet(VOID)//获取当前进程的所属用户
/*
* Wait for any child process to finish
*/
#define OS_PROCESS_WAIT_ANY (1 << 0U) //等待任意子进程完成
#define OS_PROCESS_WAIT_ANY (1 << 0U) //等待任意子进程完成
,这个被等待的进程不一定是等待进程的子进程
/*
* Wait for the child process specified by the pid to finish
*/
#define OS_PROCESS_WAIT_PRO (1 << 1U) //等待pid指定的子进程完成
#define OS_PROCESS_WAIT_PRO (1 << 1U) //等待pid指定的子进程完成
,这个被等待的进程一定是等待进程的子进程
/*
* Waits for any child process in the specified process group to finish.
//等待指定进程组中的任何子进程完成
* Waits for any child process in the specified process group to finish.
*/
#define OS_PROCESS_WAIT_GID (1 << 2U)
#define OS_PROCESS_WAIT_GID (1 << 2U)
//等待指定进程组中的任何子进程完成,这个被等待的进程和等待进程在同一个进程组
#define OS_PROCESS_INFO_ALL 1
#define OS_PROCESS_DEFAULT_UMASK 0022
...
...
kernel/base/include/los_task_pri.h
浏览文件 @
af76a9f9
...
...
@@ -341,9 +341,9 @@ typedef struct {
FutexNode
futex
;
//实现快锁功能
LOS_DL_LIST
joinList
;
/**< join list */
//联结链表,允许任务之间相互释放彼此
LOS_DL_LIST
lockList
;
/**< Hold the lock list */
//拿到了哪些锁链表
UINT32
waitID
;
/**< Wait for the PID or GID of the child process */
//
等待孩子的PID或GID进程
UINT32
waitID
;
/**< Wait for the PID or GID of the child process */
//
本任务将负责等待(PID或GID)的孩子进程结束
UINT16
waitFlag
;
/**< The type of child process that is waiting, belonging to a group or parent,
a specific child process, or any child process */
a specific child process, or any child process */
//以什么样的方式等待子进程结束(OS_PROCESS_WAIT_PRO,..)
#if (LOSCFG_KERNEL_LITEIPC == YES)
UINT32
ipcStatus
;
//IPC状态
LOS_DL_LIST
msgListHead
;
//消息队列头结点,上面挂的都是任务要读的消息
...
...
kernel/include/los_typedef.h
浏览文件 @
af76a9f9
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @defgroup los_typedef Type define
* @ingroup kernel
*/
#ifndef _LOS_TYPEDEF_H
#define _LOS_TYPEDEF_H
#include "stddef.h"
#include "stdbool.h"
#include "stdint.h"
#include "los_builddef.h"
#include "los_toolchain.h"
#ifdef __cplusplus
#if __cplusplus
extern
"C"
{
#endif
/* __cplusplus */
#endif
/* __cplusplus */
#define OS_STRING(x) #x
#define X_STRING(x) OS_STRING(x)
/* type definitions */
typedef
unsigned
char
UINT8
;
typedef
unsigned
short
UINT16
;
typedef
unsigned
int
UINT32
;
typedef
signed
char
INT8
;
typedef
signed
short
INT16
;
typedef
signed
int
INT32
;
typedef
float
FLOAT
;
typedef
double
DOUBLE
;
typedef
char
CHAR
;
#ifdef __LP64__
typedef
long
unsigned
int
UINT64
;
typedef
long
signed
int
INT64
;
typedef
unsigned
long
UINTPTR
;
typedef
signed
long
INTPTR
;
#else
typedef
unsigned
long
long
UINT64
;
typedef
signed
long
long
INT64
;
typedef
unsigned
int
UINTPTR
;
typedef
signed
int
INTPTR
;
#endif
#ifdef __LP64__
typedef
__uint128_t
UINT128
;
typedef
INT64
ssize_t
;
typedef
UINT64
size_t
;
#define LOSCFG_AARCH64
#else
typedef
INT32
ssize_t
;
typedef
UINT32
size_t
;
#endif
typedef
UINTPTR
AARCHPTR
;
typedef
size_t
BOOL
;
#define VOID void
#define STATIC static
#ifndef FALSE
#define FALSE 0U
#endif
#ifndef TRUE
#define TRUE 1U
#endif
#ifndef NULL
#define NULL ((VOID *)0)
#endif
#ifdef YES
#undef YES
#endif
#define YES 1
#ifdef NO
#undef NO
#endif
#define NO 0
#define OS_NULL_BYTE ((UINT8)0xFF)
#define OS_NULL_SHORT ((UINT16)0xFFFF)
#define OS_NULL_INT ((UINT32)0xFFFFFFFF)
#ifndef USER
#define USER
#endif
#ifndef LOS_OK
#define LOS_OK 0
#endif
#ifndef LOS_NOK
#define LOS_NOK 1
#endif
#ifndef LOS_EPERM
#define LOS_EPERM 1
#endif
#ifndef LOS_ESRCH
#define LOS_ESRCH 3
#endif
#ifndef LOS_EINTR
#define LOS_EINTR 4
#endif
#ifndef LOS_EBADF
#define LOS_EBADF 9
#endif
#ifndef LOS_ECHILD
#define LOS_ECHILD 10
#endif
#ifndef LOS_EAGAIN
#define LOS_EAGAIN 11
#endif
#ifndef LOS_ENOMEM
#define LOS_ENOMEM 12
#endif
#ifndef LOS_EACCES
#define LOS_EACCES 13
#endif
#ifndef LOS_EBUSY
#define LOS_EBUSY 16
#endif
#ifndef LOS_EINVAL
#define LOS_EINVAL 22
#endif
#ifndef LOS_EDEADLK
#define LOS_EDEADLK 35
#endif
#ifndef LOS_EOPNOTSUPP
#define LOS_EOPNOTSUPP 95
#endif
#ifndef LOS_ETIMEDOUT
#define LOS_ETIMEDOUT 110
#endif
#define OS_FAIL 1
#define OS_ERROR (UINT32)(-1)
#define OS_INVALID (UINT32)(-1)
#define OS_INVALID_VALUE ((UINT32)0xFFFFFFFF)
#define asm __asm
#ifdef typeof
#undef typeof
#endif
#define typeof __typeof__
#ifndef LOS_LABEL_DEFN
#define LOS_LABEL_DEFN(label) label
#endif
#ifndef LOSARC_ALIGNMENT
#define LOSARC_ALIGNMENT 8
#endif
/* And corresponding power of two alignment */
#ifndef LOSARC_P2ALIGNMENT
#ifdef LOSCFG_AARCH64
#define LOSARC_P2ALIGNMENT 3
#else
#define LOSARC_P2ALIGNMENT 2
#endif
#endif
typedef
int
status_t
;
typedef
unsigned
long
vaddr_t
;
typedef
unsigned
long
PADDR_T
;
typedef
unsigned
long
VADDR_T
;
typedef
unsigned
long
paddr_t
;
typedef
unsigned
long
DMA_ADDR_T
;
typedef
unsigned
long
ADDR_T
;
typedef
unsigned
long
VM_OFFSET_T
;
typedef
unsigned
long
PTE_T
;
//Page table entry 页表项
typedef
unsigned
int
ULONG_T
;
typedef
int
STATUS_T
;
/* Give a type or object explicit minimum alignment */
#if !defined(LOSBLD_ATTRIB_ALIGN)
#define LOSBLD_ATTRIB_ALIGN(__align__) __attribute__((aligned(__align__)))
#endif
/* Assign a defined variable to a specific section */
//将定义的变量分配给特定的节
#if !defined(LOSBLD_ATTRIB_SECTION)
#define LOSBLD_ATTRIB_SECTION(__sect__) __attribute__((section(__sect__)))
#endif
/*
* Tell the compiler not to throw away a variable or function. Only known
* available on 3.3.2 or above. Old version's didn't throw them away,
* but using the unused attribute should stop warnings.
*/
#define LOSBLD_ATTRIB_USED __attribute__((used))
#ifdef __cplusplus
#if __cplusplus
}
#endif
/* __cplusplus */
#endif
/* __cplusplus */
#endif
/* _LOS_TYPEDEF_H */
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @defgroup los_typedef Type define
* @ingroup kernel
*/
#ifndef _LOS_TYPEDEF_H
#define _LOS_TYPEDEF_H
#include "stddef.h"
#include "stdbool.h"
#include "stdint.h"
#include "los_builddef.h"
#include "los_toolchain.h"
#ifdef __cplusplus
#if __cplusplus
extern
"C"
{
#endif
/* __cplusplus */
#endif
/* __cplusplus */
#define OS_STRING(x) #x
#define X_STRING(x) OS_STRING(x)
/* type definitions */
typedef
unsigned
char
UINT8
;
typedef
unsigned
short
UINT16
;
typedef
unsigned
int
UINT32
;
typedef
signed
char
INT8
;
typedef
signed
short
INT16
;
typedef
signed
int
INT32
;
typedef
float
FLOAT
;
typedef
double
DOUBLE
;
typedef
char
CHAR
;
#ifdef __LP64__
typedef
long
unsigned
int
UINT64
;
typedef
long
signed
int
INT64
;
typedef
unsigned
long
UINTPTR
;
typedef
signed
long
INTPTR
;
#else
typedef
unsigned
long
long
UINT64
;
typedef
signed
long
long
INT64
;
typedef
unsigned
int
UINTPTR
;
typedef
signed
int
INTPTR
;
#endif
#ifdef __LP64__
typedef
__uint128_t
UINT128
;
typedef
INT64
ssize_t
;
typedef
UINT64
size_t
;
#define LOSCFG_AARCH64
#else
typedef
INT32
ssize_t
;
typedef
UINT32
size_t
;
#endif
typedef
UINTPTR
AARCHPTR
;
typedef
size_t
BOOL
;
#define VOID void
#define STATIC static
#ifndef FALSE
#define FALSE 0U
#endif
#ifndef TRUE
#define TRUE 1U
#endif
#ifndef NULL
#define NULL ((VOID *)0)
#endif
#ifdef YES
#undef YES
#endif
#define YES 1
#ifdef NO
#undef NO
#endif
#define NO 0
#define OS_NULL_BYTE ((UINT8)0xFF)
#define OS_NULL_SHORT ((UINT16)0xFFFF)
#define OS_NULL_INT ((UINT32)0xFFFFFFFF)
#ifndef USER
#define USER
#endif
#ifndef LOS_OK
#define LOS_OK 0
//正常返回
#endif
#ifndef LOS_NOK
#define LOS_NOK 1
//不OK
#endif
#ifndef LOS_EPERM
#define LOS_EPERM 1
//操作不允许
#endif
#ifndef LOS_ESRCH
#define LOS_ESRCH 3
//没有此进程
#endif
#ifndef LOS_EINTR
#define LOS_EINTR 4
//系统调用被禁止
#endif
#ifndef LOS_EBADF
#define LOS_EBADF 9
//文件数目错误
#endif
#ifndef LOS_ECHILD
#define LOS_ECHILD 10
//没有此子进程
#endif
#ifndef LOS_EAGAIN
#define LOS_EAGAIN 11
//再试一遍
#endif
#ifndef LOS_ENOMEM
#define LOS_ENOMEM 12
//内存溢出
#endif
#ifndef LOS_EACCES
#define LOS_EACCES 13
//拒绝访问
#endif
#ifndef LOS_EBUSY
#define LOS_EBUSY 16
//设备或资源忙
#endif
#ifndef LOS_EINVAL
#define LOS_EINVAL 22
//无效的参数
#endif
#ifndef LOS_EDEADLK
#define LOS_EDEADLK 35
//资源发生死锁
#endif
#ifndef LOS_EOPNOTSUPP
#define LOS_EOPNOTSUPP 95
//不支持该操作
#endif
#ifndef LOS_ETIMEDOUT
#define LOS_ETIMEDOUT 110
//超时
#endif
#define OS_FAIL 1
#define OS_ERROR (UINT32)(-1)
#define OS_INVALID (UINT32)(-1)
#define OS_INVALID_VALUE ((UINT32)0xFFFFFFFF)
#define asm __asm
#ifdef typeof
#undef typeof
#endif
#define typeof __typeof__
#ifndef LOS_LABEL_DEFN
#define LOS_LABEL_DEFN(label) label
#endif
#ifndef LOSARC_ALIGNMENT
#define LOSARC_ALIGNMENT 8
#endif
/* And corresponding power of two alignment */
#ifndef LOSARC_P2ALIGNMENT
#ifdef LOSCFG_AARCH64
#define LOSARC_P2ALIGNMENT 3
#else
#define LOSARC_P2ALIGNMENT 2
#endif
#endif
typedef
int
status_t
;
typedef
unsigned
long
vaddr_t
;
typedef
unsigned
long
PADDR_T
;
typedef
unsigned
long
VADDR_T
;
typedef
unsigned
long
paddr_t
;
typedef
unsigned
long
DMA_ADDR_T
;
typedef
unsigned
long
ADDR_T
;
typedef
unsigned
long
VM_OFFSET_T
;
typedef
unsigned
long
PTE_T
;
//Page table entry 页表项
typedef
unsigned
int
ULONG_T
;
typedef
int
STATUS_T
;
/* Give a type or object explicit minimum alignment */
#if !defined(LOSBLD_ATTRIB_ALIGN)
#define LOSBLD_ATTRIB_ALIGN(__align__) __attribute__((aligned(__align__)))
#endif
/* Assign a defined variable to a specific section */
//将定义的变量分配给特定的节
#if !defined(LOSBLD_ATTRIB_SECTION)
#define LOSBLD_ATTRIB_SECTION(__sect__) __attribute__((section(__sect__)))
#endif
/*
* Tell the compiler not to throw away a variable or function. Only known
* available on 3.3.2 or above. Old version's didn't throw them away,
* but using the unused attribute should stop warnings.
*/
#define LOSBLD_ATTRIB_USED __attribute__((used))
#ifdef __cplusplus
#if __cplusplus
}
#endif
/* __cplusplus */
#endif
/* __cplusplus */
#endif
/* _LOS_TYPEDEF_H */
zzz/git/push.sh
浏览文件 @
af76a9f9
git add
-A
git commit
-m
'
V46.xx 鸿蒙内核源码分析(特殊进程篇) | 龙生龙,凤生凤,老鼠生儿会打洞
git commit
-m
'
进程回收过程注解
百万汉字注解 + 百篇博客分析 => 挖透鸿蒙内核源码
https://my.oschina.net/weharmony
'
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录