Linux Process and thread clone create Java code www.2cto.com [B] Linux Process and thread creation are achieved through clone. the clone function is powerful and has many parameters. clone allows you to selectively inherit the resources of the parent process. You can share a virtual storage space with the parent process like vfork, this creates a thread, and you can not share it with the parent process. You can even choose to create a parent-child relationship between the Process and the parent process, instead, the sibling relationship [/B] pthread_create is implemented based on clone and is actually created by processes, but these processes share many things with the parent process, shared things do not need to be copied to sub-processes, thus saving a lot of overhead. Therefore, these sub-processes are also called light-weight processes (light-weight process) in linux after the thread is a lightweight process fork, what can be copied by a sub-process is summarized in one sentence, that is, all writeable data will be copied. including: heap, stack, data segment, not beginning Start data segment, open file descriptor, handler installed on the signal, shared library, ipc (shared memory, message queue, semaphore). Note that the pending signal will not be inherited, the new process resets its pending signal chain. The sub-process and the parent process share something in one sentence, that is, all read-only things do not need to be copied, and the parent and child processes share, including: what are the body segments and string constants? The child process will not inherit the process id from the parent process, various locks (memory locks, file locks), timers, and pending signals in the operating system. If a user-level thread corresponds to a system-level thread, the linux multi-core features can be fully utilized. However, in earlier linux versions, multiple threads of linux user-level processes correspond to one system-level process and cannot fully utilize the features of the operating system!