[haiku-gsoc] Re: Implementation Queries

  • From: Vivek Roy <vivekroyandroid@xxxxxxxxx>
  • To: haiku-gsoc@xxxxxxxxxxxxx
  • Date: Wed, 21 Jun 2017 01:23:37 +0530



The problem with atomic_swap_int() has already been pointed out, but I
wonder why you went with these instead of the GCC builtins after all?
Haiku's atomic functions unfortunately don't allow specifying a memory
order, so they use barriers stronger than would be necessary here. For
example, atomic_test_and_set() and atomic_and() use full sequential
consistency, but the two FreeBSD functions that you've used them for here
don't require barriers at all.
On x86/x64 this doesn't make so much of a difference, but on platforms
with weaker memory models, such as ARM and PPC, this can lead to a large
performance loss.

I thought the it would be less code maintanence if we use Haiku's
functions. I will then look into the barrier requirements of the functions
and implement them with GCC builtins.
Thanks

Other related posts: