Improve spinlock implementation
authorMarco Costalba <mcostalba@gmail.com>
Mon, 23 Feb 2015 18:22:37 +0000 (19:22 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Mon, 23 Feb 2015 18:48:46 +0000 (19:48 +0100)
commitd3d26a94b3e501459a610b8d730394125c9afd45
treed0576bfd0f2c841811e2fdd027ddd3ee9f8ea5ab
parent38112060dc2da351c6dde8f12d0ee5cfaeac5084
Improve spinlock implementation

Calling lock.test_and_set() in a tight loop creates expensive
memory synchronizations among processors and penalize other
running threads. So syncronize only only once at the beginning
with fetch_sub() and then loop on a simple load() that puts much
less pressure on the system.

Reported about 2-3% speed up on various systems.

Patch by Ronald de Man.

No functional change.
src/thread.h