Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news.iecc.com!.POSTED!nerds-end From: Seima Rao Newsgroups: comp.compilers Subject: Re: Question about inter-thread stack references Date: Fri, 16 Jan 2015 21:23:14 +0530 Organization: Compilers Central Lines: 39 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <15-01-019@comp.compilers> NNTP-Posting-Host: news.iecc.com Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: miucha.iecc.com 1421478538 95939 2001:470:1f07:1126:0:676f:7373:6970 (17 Jan 2015 07:08:58 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Sat, 17 Jan 2015 07:08:58 +0000 (UTC) Keywords: architecture, parallel, comment Posted-Date: 17 Jan 2015 02:08:58 EST X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Xref: csiph.com comp.compilers:1476 > If a process has two or more threads running in it, what are the rules > regarding one thread referencing memory in a different thread's stack? There are no rules in the hardware. It is possible for a thread to reference another thread's stack in a flat memory. And then there are thread implementations which are even loose, they are not strictly OS recognized thread. These threads all run in application domain. The simplest solution is to attack the problem at the language level. At the language level, all your parallelism optimizations are possible wrt stacks as per C & C++. Once "decided" that the stack is unaliasable across threads at the language level, the next step would be to decide about security be it at the language lever, hardware level or both. Normally, without security, the hw need not care about aliasing as the compiler wont. With security, all the following layers(there are more layers if one looks at them) can cooperate to enforce some discipline: Language Compiler Hardware [Operating system enforced security remains the greatest leveller of them all but it doesnt belong in this forum. However, if you care , then you can ship a DLL/Shared Library as one of your layers in security] Sincerely, Seima Rao. [Some hardware has a fully shared address space, some doesn't. The question is basically what doesn't. I'm fairly sure I've seen something where threads can't see each other's stacks, but I don't remember what it is. On most current architectures, it'd require messing with virtual memory tables which would make switching threads a lot slower, basically the same as process switches. -John]