Is it possible to create a thread without sharing memory space?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












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.










share|improve this question
























  • 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















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.










share|improve this question
























  • 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













1












1








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.










share|improve this question
















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.







linux thread clone






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 11 at 0:18







炸鱼薯条德里克

















asked Feb 10 at 23:30









炸鱼薯条德里克炸鱼薯条德里克

531215




531215












  • 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

















  • 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
















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





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






@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





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










0






active

oldest

votes











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f499835%2fis-it-possible-to-create-a-thread-without-sharing-memory-space%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f499835%2fis-it-possible-to-create-a-thread-without-sharing-memory-space%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown






Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay