1

The http://www.man7.org/linux/man-pages/man2/clone.2.html write

Since Linux 2.5.35, flags must also include CLONE_SIGHAND if CLONE_THREAD is specified (and note that, since Linux 2.6.0-test6, CLONE_SIGHAND also requires CLONE_VM to be included).

So it seems that on modern Linux, threads are forced to share signal handlers and memory space, is it true? Is there any way to create a new thread(the same tgid as the calling thread) without sharing memory space, maybe like by not using the clone()?

I also want to know, enforced by kernel, what are shared between threads in one process.

  • Isn't that a distinguishing factor between a thread and a process? Shared process resources? If you want a unique memory space then fork() to create a new process... – Stephen Harris Feb 10 at 23:50
  • @Stephen I'm just talking about Linux kernel, for kernel, it's only about tid and tgid. And I remember some old document said two threads can unshare the memory space from the kernel view, it now seems to be too old now. – 炸鱼薯条德里克 Feb 11 at 0:09
  • You're talking about the clone(2) syscall, which can be used to create new "processes" which share various resources. eg clone() with CLONE_VM will share memory space; without it each process has a unique memory space. Similarly CLONE_SIGHAND will share signal handlers. These are all ways that user level threads can be handled. If you want to share handlers then you need to share memory. If you don't want to share handlers then you don't need to share memory. – Stephen Harris Feb 11 at 0:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.