[openssl-dev] [openssl-team] Discussion: design issue: async and -lpthread
Nico Williams
nico at cryptonector.com
Wed Dec 9 04:01:20 UTC 2015
On Wed, Dec 09, 2015 at 09:27:16AM +1000, Paul Dale wrote:
> It will be possible to support atomics in such a way that there is no
> performance penalty for machines without them or for single threaded
> operation. My sketcy design is along the lines of adding a new API
> CRYPTO_add_atomic that takes the same arguments as CRYPTO_add (i.e.
> reference to counter, value to add and lock to use):
>
> CRYPTO_add_atomic(int *addr, int amount, int lock)
> if have-atomics then
> atomic_add(addr, amount)
> else if (lock == have-lock-already)
> *addr += amount
> else
> CRYPTO_add(addr, amount, lock)
"have-atomics" must be known at compile time.
"lock" should not be needed because we should always have atomics, even
when we don't have true atomics: just use a global lock in a stub
implementation of atomic_add() and such. KISS. Besides, this will add
pressure to add true atomics wherever they are truly needed.
Nico
--
More information about the openssl-dev
mailing list