Skip to content

Commit 07efe31

Browse files
committed
benchmarks/lockhammer/tests/cas_lockref.h
add use of __cpu_relax() macro between cas64(). Change-Id: Ic9634a63c4a33af5c67145c023a97ee84cea7793
1 parent ca93f0b commit 07efe31

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

benchmarks/lockhammer/tests/cas_lockref.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
*/
3131

3232
#include "atomics.h"
33+
#include "cpu_relax.h"
3334

3435
static inline unsigned long lock_acquire (uint64_t *lock, unsigned long threadnum) {
3536
unsigned long val, old;
@@ -44,7 +45,11 @@ static inline unsigned long lock_acquire (uint64_t *lock, unsigned long threadnu
4445
}
4546

4647
val = cas64(lock, val, old);
47-
} while (val != old);
48+
if (val == old) {
49+
break;
50+
}
51+
__cpu_relax();
52+
} while (1);
4853

4954
return val >> 32;
5055
}
@@ -62,5 +67,11 @@ static inline void lock_release (uint64_t *lock, unsigned long threadnum) {
6267
}
6368

6469
val = cas64(lock, val, old);
65-
} while (val != old);
70+
if (val == old) {
71+
return;
72+
}
73+
__cpu_relax();
74+
} while (1);
6675
}
76+
77+
/* vim: set tabstop=8 shiftwidth=8 softtabstop=8 noexpandtab: */

0 commit comments

Comments
 (0)