zoukankan      html  css  js  c++  java
  • kernel_thread简析

    1.3.100
    static inline pid_t kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
    {
        long retval;

        __asm__ __volatile__(
            "movl %%esp,%%esi "
            "int $0x80 "        /* Linux/i386 system call */
            "cmpl %%esp,%%esi "    /* child or parent? */
            "je 1f "        /* parent - jump */
            "pushl %3 "        /* push argument */
            "call *%4 "        /* call fn */
            "movl %2,%0 "    /* exit */
            "int $0x80 "
            "1: "
            :"=a" (retval)
            :"0" (__NR_clone), "i" (__NR_exit),
             "r" (arg), "r" (fn),
             "b" (flags | CLONE_VM)
            :"si");
        return retval;
    }

    1. 执行系统调用 __NR_clone
    2. 父进程走1f,子进程调fn
    3. fn完成后执行__NR_exit系统调用
    4.注:%eax=__NR_clone, %ebx是参数,flags带上了CLONE_VM

  • 相关阅读:
    rzc generate exited with code -2147450730.
    c#WebService动态调用
    c#BarTender打印,打印微调
    记一次ios下h5页面图片显示问题
    FID
    RSA密钥对生成,并解析公钥指数和模数
    angularjs-6
    angularjs-5
    angularjs-4
    angularjs-4
  • 原文地址:https://www.cnblogs.com/mull/p/7997523.html
Copyright © 2011-2022 走看看