linux kernel function do_fork

来源:互联网 发布:计算机能处理的数据 编辑:程序博客网 时间:2024/05/16 19:05
kernel function do_forkkernel thread:/* * Create a kernel thread. */pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags){    return do_fork(flags|CLONE_VM|CLONE_UNTRACED, (unsigned long)fn, (unsigned long)arg, NULL, NULL);}user space process:1. forkSYSCALL_DEFINE0(fork){#ifdef CONFIG_MMU    return do_fork(SIGCHLD, 0, 0, NULL, NULL);2. vforkSYSCALL_DEFINE0(vfork){    return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, 0,             0, NULL, NULL);}3. cloneSYSCALL_DEFINE5(clone, unsigned long, clone_flags, unsigned long, newsp,         int __user *, parent_tidptr,         int, tls_val,         int __user *, child_tidptr)#elif defined(CONFIG_CLONE_BACKWARDS2)SYSCALL_DEFINE5(clone, unsigned long, newsp, unsigned long, clone_flags,         int __user *, parent_tidptr,         int __user *, child_tidptr,         int, tls_val)#elif defined(CONFIG_CLONE_BACKWARDS3)SYSCALL_DEFINE6(clone, unsigned long, clone_flags, unsigned long, newsp,        int, stack_size,        int __user *, parent_tidptr,        int __user *, child_tidptr,        int, tls_val)#elseSYSCALL_DEFINE5(clone, unsigned long, clone_flags, unsigned long, newsp,         int __user *, parent_tidptr,         int __user *, child_tidptr,         int, tls_val)#endif{    return do_fork(clone_flags, newsp, 0, parent_tidptr, child_tidptr);}

无论kernel thread还是user space process,在kernel中的表示都是一样的。

0 0