Related articles |
---|
[5 earlier articles] |
Re: Question about inter-thread stack references monnier@iro.umontreal.ca (Stefan Monnier) (2015-01-18) |
Re: Question about inter-thread stack references kaz@kylheku.com (Kaz Kylheku) (2015-01-18) |
Re: Question about inter-thread stack references ivan@ootbcomp.com (Ivan Godard) (2015-01-18) |
Re: Question about inter-thread stack references gah@ugcs.caltech.edu (glen herrmannsfeldt) (2015-01-18) |
Re: Question about inter-thread stack references gah@ugcs.caltech.edu (glen herrmannsfeldt) (2015-01-18) |
Re: Question about inter-thread stack references jgk@panix.com (2015-01-25) |
Re: Question about inter-thread stack references kaz@kylheku.com (Kaz Kylheku) (2015-01-25) |
Re: Question about inter-thread stack references jgk@panix.com (2015-01-27) |
From: | Kaz Kylheku <kaz@kylheku.com> |
Newsgroups: | comp.compilers |
Date: | Sun, 25 Jan 2015 18:46:11 +0000 (UTC) |
Organization: | Aioe.org NNTP Server |
References: | 15-01-015 15-01-042 |
Keywords: | parallel, comment |
Posted-Date: | 25 Jan 2015 15:52:19 EST |
On 2015-01-25, Joe keane <jgk@panix.com> wrote:
>
> In article 15-01-015, Ivan Godard <ivan@ootbcomp.com> wrote:
>>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?
>
> It should be illegal, if you ask me.
>
> [Even if they have some way to lock and synchronize? Imagine that one
> thread is acting as a server for others that put requests into a queue,
> and the queue entries point to structures in the requesting thread's
> stack. -John]
Concretely:
message_t request, reply;
init_request(&request, ... args);
if (send_request(other_thread, &request, &reply) == SEND_OK) {
/* reply object contains reply */
}
This scenario benefits from inter-thread stack access. While our thread is
blocked in send_request, pointers to the request and reply objects can be
directly enqueued somewhere, and the other thread can read from the request and
update the reply directly.
The inter-thread stack access could be avoided, but only if the API provides
alternative buffers and performs copying back and forth.
Anyway, it's done in the direct, efficient way in real life, whether anyone
likes it or not. Unix-like kernels do it, POSIX threads programs do it, Windows
threads programs do it, ...
[yes, and educated fleas do it.
This is a long way from compilers, unless someone's has a suggestion about how
one might handle these things directly in source code. -John]
Return to the
comp.compilers page.
Search the
comp.compilers archives again.