Is it possible to create a thread without sharing memory space?
Clash Royale CLAN TAG#URR8PPP
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
add a comment |
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
Isn't that a distinguishing factor between a thread and a process? Shared process resources? If you want a unique memory space thenfork()
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 theclone(2)
syscall, which can be used to create new "processes" which share various resources. egclone()
withCLONE_VM
will share memory space; without it each process has a unique memory space. SimilarlyCLONE_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
add a comment |
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
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
linux thread clone
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 thenfork()
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 theclone(2)
syscall, which can be used to create new "processes" which share various resources. egclone()
withCLONE_VM
will share memory space; without it each process has a unique memory space. SimilarlyCLONE_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
add a comment |
Isn't that a distinguishing factor between a thread and a process? Shared process resources? If you want a unique memory space thenfork()
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 theclone(2)
syscall, which can be used to create new "processes" which share various resources. egclone()
withCLONE_VM
will share memory space; without it each process has a unique memory space. SimilarlyCLONE_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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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. egclone()
withCLONE_VM
will share memory space; without it each process has a unique memory space. SimilarlyCLONE_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