Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The underlying system call to create threads is <a href="http://man7.org/linux/man-pages/man2/clone.2.html" rel="nofollow noreferrer">clone(2)</a> (it is Linux specific). BTW, the list of Linux system calls is on <a href="http://man7.org/linux/man-pages/man2/syscalls.2.html" rel="nofollow noreferrer">syscalls(2)</a>, and you could use the <a href="http://man7.org/linux/man-pages/man1/strace.1.html" rel="nofollow noreferrer">strace(1)</a> command to understand the syscalls done by some process or command. Processes are usually created with <a href="http://man7.org/linux/man-pages/man2/fork.2.html" rel="nofollow noreferrer">fork(2)</a> (or <a href="http://man7.org/linux/man-pages/man2/vfork.2.html" rel="nofollow noreferrer">vfork(2)</a>, which is not much useful these days). However, you could (and some C standard libraries might do that) create them with some particular form of <code>clone</code>. I guess that the kernel is sharing some code to implement <code>clone</code>, <code>fork</code> etc... (since some functionalities, e.g. management of the <a href="https://en.wikipedia.org/wiki/Virtual_address_space" rel="nofollow noreferrer">virtual address space</a>, are common).</p> <p>Indeed, process creation (and also thread creation) is generally quite fast on most Unix systems (because they use <a href="http://en.wikipedia.org/wiki/Copy-on-write" rel="nofollow noreferrer">copy-on-write</a> machinery for the <a href="http://en.wikipedia.org/wiki/Virtual_memory" rel="nofollow noreferrer">virtual memory</a>), typically a small fraction of a millisecond. But you could have pathological cases (e.g. <a href="https://en.wikipedia.org/wiki/Thrashing_(computer_science)" rel="nofollow noreferrer">thrashing</a>) which makes that much longer.</p> <p>Since most <a href="https://en.wikipedia.org/wiki/C_standard_library" rel="nofollow noreferrer">C standard library</a> implementations are <a href="https://en.wikipedia.org/wiki/Free_software" rel="nofollow noreferrer">free software</a> on Linux, you could study the source code of the one on your system (often <a href="https://www.gnu.org/software/libc/" rel="nofollow noreferrer">GNU glibc</a>, but sometimes <a href="http://musl-libc.org/" rel="nofollow noreferrer">musl-libc</a> or something else).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload