【发布时间】:2012-02-18 11:47:40
【问题描述】:
我正在内核中搜索“getpid”函数,但是我找不到实际的函数。
应该是这样的:
asmlinkage long sys_getpid(void)
{
return current-> tgetid;
}
我能找到的只是系统调用表,而不是这个系统调用的实际实现。
内核版本为:3.0.20
提前致谢。
【问题讨论】:
标签: operating-system linux-kernel kernel
我正在内核中搜索“getpid”函数,但是我找不到实际的函数。
应该是这样的:
asmlinkage long sys_getpid(void)
{
return current-> tgetid;
}
我能找到的只是系统调用表,而不是这个系统调用的实际实现。
内核版本为:3.0.20
提前致谢。
【问题讨论】:
标签: operating-system linux-kernel kernel
实际定义在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_vnr 是include/linux/sched.h 中的静态内联。
【讨论】:
kernel_source_dir/kernel/timer.c,如上所述。