title: How to use clone system call in assembler to start Linux threads?
body: <p>First of all a small intro: I am developing a TCP server in Assembler x64 with NASM, all good until there, implement the fork system call so that each client that connects is not on the waiting list, in short, that it works and I have it quite clear. Now, I wanted to implement threads, in the same way that it is done in C with pthread but pum in the list of system calls neither pthread_create, nor pthread_join nor anything similar to what is in C exist, but if it exists in C, somehow it is done in Assembler.</p>
  <p>Reading a little, apparently a thread would be created by the <code>sys_clone</code> system call, now my problem is that I have no idea what its arguments refer to and I can't find examples anywhere of its implementation, if you know of any website that explains each argument of the system calls in Linux I would appreciate it because it asks me something like this <code>int __user * parent_tidptr</code> and makes him realize that they are speaking to me in Russian.</p>
  <pre><code>mov rdi, ???    ; unsigned long clone_flags
  mov rsi, ???    ; unsigned long newsp
  mov rdx, ???    ; int __user * parent_tidptr
  mov r10, ???    ; int __user * child_tidptr
  mov r8,  ???    ; int tls_val
  mov rax, 56
  syscall
  </code></pre>
  <p>The list of system calls with their respective arguments I get them from this site: <a href="https://filippo.io/linux-syscall-table/" rel="nofollow noreferrer">link</a></p>
  <p>In Linux Programmer's Manual I try to guide myself with this: <a href="https://man7.org/linux/man-pages/man2/clone.2.html" rel="nofollow noreferrer">link</a>, but I am in the same, I do not understand the arguments, the first argument I suppose is like in pthread_create that you pass a function but the truth I do not know.</p>
  <p>Without more to say I thank you in advance, and sorry if some things seem obvious, but I have been doing this for at most 2 weeks, which I love but we must admit that finding Assembler information is not as simple as looking for C things, C++, Javascript haha, among others. Bye if you read this I love you!</p>