gpt4 book ai didi

operating-system - 系统调用函数 “sys_getpid”在linux内核中位于什么位置?

转载 作者:行者123 更新时间:2023-12-04 07:23:12 25 4
gpt4 key购买 nike

我在内核中搜索“ getpid ”函数,但是我找不到实际的函数。

它应该是这样的:

asmlinkage long sys_getpid(void)
{
return current-> tgetid;
}

我能找到的只是系统调用表,而不是这个系统调用的实际实现。

内核版本为: 3.0.20

提前致谢。

最佳答案

实际定义在 kernel/timer.c :

/**
* sys_getpid - return the thread group id of the current process
*
* Note, despite the name, this returns the tgid not the pid. The tgid and
* the pid are identical unless CLONE_THREAD was specified on clone() in
* which case the tgid is the same in all threads of the same group.
*
* This is SMP safe as current->tgid does not change.
*/
SYSCALL_DEFINE0(getpid)
{
return task_tgid_vnr(current);
}
task_tgid_vnrinclude/linux/sched.h 中的静态内联.

关于operating-system - 系统调用函数 “sys_getpid”在linux内核中位于什么位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9340876/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com