![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Linux Kernel 进程管理
星空探索
linux
展开
-
clone实现
#ifdef __ARCH_WANT_SYS_CLONE #ifdef CONFIG_CLONE_BACKWARDS SYSCALL_DEFINE5(clone, unsigned long, clone_flags, unsigned long, newsp, int __user *, parent_tidptr, unsigned long, tls, int _原创 2017-03-14 08:00:06 · 345 阅读 · 0 评论 -
二进制文件格式装载支持
/* * This structure defines the functions that are used to load the binary formats that * linux accepts. */ struct linux_binfmt { struct list_head lh; struct module *module; int (*load_bi原创 2017-03-14 08:06:50 · 314 阅读 · 0 评论 -
进程描述符创建
static struct task_struct *dup_task_struct(struct task_struct *orig, int node) { struct task_struct *tsk; unsigned long *stack; struct vm_struct *stack_vm_area; int err; if (node == NUMA_NO_N原创 2017-03-14 08:07:03 · 337 阅读 · 0 评论 -
进程创建时文件处理
static int copy_files(unsigned long clone_flags, struct task_struct *tsk) { struct files_struct *oldf, *newf; int error = 0; /* * A background process may not have any files ... */ oldf =原创 2017-03-14 08:07:31 · 365 阅读 · 0 评论 -
进程创建时信号处理函数处理
static int copy_sighand(unsigned long clone_flags, struct task_struct *tsk) { struct sighand_struct *sig; if (clone_flags & CLONE_SIGHAND) { atomic_inc(¤t->sighand->count); return 0;原创 2017-03-14 08:06:26 · 365 阅读 · 0 评论 -
进程创建时信号处理
static int copy_signal(unsigned long clone_flags, struct task_struct *tsk) { struct signal_struct *sig; if (clone_flags & CLONE_THREAD) return 0; sig = kmem_cache_zalloc(signal_cachep, GFP_KERNE原创 2017-03-14 08:06:14 · 242 阅读 · 0 评论 -
进程创建时内存描述符处理
static int copy_mm(unsigned long clone_flags, struct task_struct *tsk) { struct mm_struct *mm, *oldmm; int retval; tsk->min_flt = tsk->maj_flt = 0; tsk->nvcsw = tsk->nivcsw = 0; #ifdef CONFIG_原创 2017-03-14 08:08:29 · 445 阅读 · 0 评论 -
进程创建时文件系统处理
static int copy_fs(unsigned long clone_flags, struct task_struct *tsk) { struct fs_struct *fs = current->fs; if (clone_flags & CLONE_FS) { /* tsk->fs is already what we want */ spin_lock(&f原创 2017-03-14 08:09:02 · 311 阅读 · 0 评论 -
进程创建时sched_fork
/* * fork()/clone()-time setup: */ int sched_fork(unsigned long clone_flags, struct task_struct *p) { unsigned long flags; int cpu = get_cpu(); __sched_fork(clone_flags, p); /* * We mar原创 2017-03-14 08:09:19 · 975 阅读 · 0 评论 -
进程fork处理
进程或者线程创建do_fork /* For compatibility with architectures that call do_fork directly rather than * using the syscall entry points below. */ long do_fork(unsigned long clone_flags, unsigne原创 2017-03-15 08:16:20 · 438 阅读 · 0 评论 -
进程创建时命名空间处理
/* * called from clone. This now handles copy for nsproxy and all * namespaces therein. */ int copy_namespaces(unsigned long flags, struct task_struct *tsk) { struct nsproxy *old_ns = tsk->原创 2017-03-14 08:05:59 · 365 阅读 · 0 评论 -
进程创建时IO处理
static int copy_io(unsigned long clone_flags, struct task_struct *tsk) { #ifdef CONFIG_BLOCK struct io_context *ioc = current->io_context; struct io_context *new_ioc; if (!ioc) return 0; /*原创 2017-03-14 08:05:43 · 392 阅读 · 0 评论 -
fork实现
#ifdef __ARCH_WANT_SYS_FORK SYSCALL_DEFINE0(fork) { #ifdef CONFIG_MMU return _do_fork(SIGCHLD, 0, 0, NULL, NULL, 0); #else /* can not support in nommu mode */ return -EINVAL; #endif } #en原创 2017-03-14 08:00:44 · 264 阅读 · 0 评论 -
vfork实现
#ifdef __ARCH_WANT_SYS_VFORK SYSCALL_DEFINE0(vfork) { return _do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, 0, 0, NULL, NULL, 0); } #endif原创 2017-03-14 08:01:39 · 285 阅读 · 0 评论 -
内核线程创建
/* * 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原创 2017-03-14 08:02:34 · 237 阅读 · 0 评论 -
idle进程创建
/** * idle_threads_init - Initialize idle threads for all cpus */ void __init idle_threads_init(void) { unsigned int cpu, boot_cpu; boot_cpu = smp_processor_id(); for_each_possible_cpu(cpu) {原创 2017-03-14 08:03:05 · 576 阅读 · 0 评论 -
进程创建时共享内存处理
shm_init_task() copy_semundo()原创 2017-03-14 08:03:44 · 340 阅读 · 0 评论 -
进程创建时cgroup处理
void cgroup_fork(struct task_struct *child) { RCU_INIT_POINTER(child->cgroups, &init_css_set); INIT_LIST_HEAD(&child->cg_list); } cgroup_can_fork: /** * cgroup_can_fork - called on a new原创 2017-03-14 08:04:15 · 950 阅读 · 0 评论 -
进程创建时安全计算处理
static void copy_seccomp(struct task_struct *p) { #ifdef CONFIG_SECCOMP /* * Must be called with sighand->lock held, which is common to * all threads in the group. Holding cred_guard_mutex i原创 2017-03-14 08:04:37 · 269 阅读 · 0 评论 -
进程创建时pid分配
struct pid *alloc_pid(struct pid_namespace *ns) { struct pid *pid; enum pid_type type; int i, nr; struct pid_namespace *tmp; struct upid *upid; int retval = -ENOMEM; pid = kmem_cache_allo原创 2017-03-14 08:04:51 · 859 阅读 · 0 评论 -
进程创建时线程栈处理
这个函数是跟体系结构相关的。 asmlinkage void ret_from_fork(void) asm("ret_from_fork");int copy_thread(unsigned long clone_flags, unsigned long stack_start, unsigned long stk_sz, struct task_struct *p) { st原创 2017-03-14 08:05:28 · 443 阅读 · 0 评论 -
exec函数实现
SYSCALL_DEFINE3(execve, const char __user *, filename, const char __user *const __user *, argv, const char __user *const __user *, envp) { return do_execve(getname(filename), argv, envp);原创 2017-03-15 08:16:47 · 758 阅读 · 0 评论