Le 04/01/2017 à 19:39, Alex Bennée a écrit :
> 
> Laurent Vivier <laur...@vivier.eu> writes:
> 
>> We always need real atomics, as we can have shared memory between
>> processes.
>>
>> A good test case is the example from futex(2), futex_demo.c:
>>
>> the use case is
>>
>>     mmap(...);
>>     fork();
>>
>>     Parent and Child:
>>
>>     while(...)
>>         __sync_bool_compare_and_swap(...)
>>         ...
>>         futex(...)
>>
>> In this case we need real atomics in __sync_bool_compare_and_swap(),
>> but as parallel_cpus is set to 0, we don't have.
>>
>> We also revert "b67cb68 linux-user: enable parallel code generation on clone"
>> as parallel_cpus in unconditionally set now.
>>
>> Of course, this doesn't fix atomics that are emulated using
>> cpu_loop_exit_atomic() as we can't stop virtual CPUs from another
>> processes.
> 
> This seems a bit of a hit for something that might never get called.
> Could we not move b67cb68 out of the thread fork leg and do it for any
> fork? After all the tb_flush will ensure that all code by both parent
> and child will be using full atomics at that point?

Yes, but we can have also two processes that are neither parents nor
children trying to communicate through shared memory. We can't know...

Laurent


Reply via email to