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: Ivan Godard Newsgroups: comp.compilers Subject: Question about inter-thread stack references Date: Thu, 15 Jan 2015 23:54:57 -0800 Organization: A noiseless patient Spider Lines: 26 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <15-01-015@comp.compilers> NNTP-Posting-Host: news.iecc.com Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: miucha.iecc.com 1421421612 70589 2001:470:1f07:1126:0:676f:7373:6970 (16 Jan 2015 15:20:12 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Fri, 16 Jan 2015 15:20:12 +0000 (UTC) Keywords: parallel, question Posted-Date: 16 Jan 2015 10:20:12 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:1472 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? In the usual way that paging hardware works both stacks can be made visible to both threads, but interstack visibility could also be prevented (assuming that stacks occupied whole pages). However, if a stack object can be referenced by a concurrent thread running in another core then it becomes impossible to optimize and move stack objects into registers because they might be referenced at any time. Even if the program were required to declare such data volatile there would still be locking needed. I vaguely (so vague that I can't find citations) remember that on some, possibly legacy, hardware it was physically impossible to do inter-thread stack accesses; stacks were strictly per-thread and private. I also vaguely recall that some languages (or thread packages) banned the practice even if it were physically possible. Is anyone aware of language/thread package/hardware rules about required semantics for such usage? Is it explicitly permitted, explicitly banned, stated to be implementation defined, stated to be undefined, or simply not mentioned? Thanks for your help. Ivan