[erlang-questions] Re: Shared/Hybrid Heap
Kostis Sagonas
kostis@REDACTED
Thu Oct 14 09:47:21 CEST 2010
Morten Krogh wrote:
> On 10/14/10 3:21 AM, Richard O'Keefe wrote:
>> On 13/10/2010, at 11:24 PM, Morten Krogh wrote:
>>
>>> I don't think it is possible to have the virtual machine solve this
>>> correctly in all cases. Only the programmer knows the future use of
>>> the data, except for very small programs, maybe.
>>>
>>> So this leads to the following proposal.
>>>
>>> Erlang processes should have internal threads.
>>>
>>> The programmer decides between spawning a process or a thread.
>>> Processes share almost nothing, threads almost everything.
>>>
>>>
>>> I am not saying Erlang should go that way, but it seems to be the
>>> solution to this issue.
>> There is a tacit assumption here that if thread T1 has data structures
>> D1 and D2
>> and it wants to share data structure D1 with thread T2, it wants to
>> share D2 as
>> well. This is not obviously the case.
>>
>>
>
> Not as I see it. T2 doesn't need to even know about D2.
>
> The program goes like
>
> T1 is working with D1 and D2
> ...
> _T2 = spawn_thread(init_function_t2, [D1]),
> ...
>
> now T1 and T2 are executing in parallel. T2 doesn't even know D2.
You are missing the point -- or at least the point which I think Richard
is making. In the scheme you propose, T2's execution will be influenced
by a piece of data that _in principle_ is not shared. For example, T2
needs to be stopped executing or synchronized with T1 by garbage
collection which might take place when process T1 allocates some big D2.
How is that different than the two processes sharing everything?
Kostis
More information about the erlang-questions
mailing list