projects
/
ghc-hetmet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix warnings
[ghc-hetmet.git]
/
includes
/
rts
/
SpinLock.h
diff --git
a/includes/rts/SpinLock.h
b/includes/rts/SpinLock.h
index
9bfb35b
..
8b337de
100644
(file)
--- a/
includes/rts/SpinLock.h
+++ b/
includes/rts/SpinLock.h
@@
-36,7
+36,6
@@
typedef StgWord SpinLock;
typedef lnat SpinLockCount;
typedef lnat SpinLockCount;
-
#if defined(PROF_SPIN)
// PROF_SPIN enables counting the number of times we spin on a lock
#if defined(PROF_SPIN)
// PROF_SPIN enables counting the number of times we spin on a lock
@@
-45,12
+44,16
@@
typedef lnat SpinLockCount;
INLINE_HEADER void ACQUIRE_SPIN_LOCK(SpinLock * p)
{
StgWord32 r = 0;
INLINE_HEADER void ACQUIRE_SPIN_LOCK(SpinLock * p)
{
StgWord32 r = 0;
-spin:
- r = cas((StgVolatilePtr)&(p->lock), 1, 0);
- if (r == 0) {
- p->spin++;
- goto spin;
- }
+ nat i;
+ do {
+ for (i = 0; i < SPIN_COUNT; i++) {
+ r = cas((StgVolatilePtr)&(p->lock), 1, 0);
+ if (r != 0) return;
+ p->spin++;
+ busy_wait_nop();
+ }
+ yieldThread();
+ } while (1);
}
// release spin lock
}
// release spin lock
@@
-74,9
+77,15
@@
INLINE_HEADER void initSpinLock(SpinLock * p)
INLINE_HEADER void ACQUIRE_SPIN_LOCK(SpinLock * p)
{
StgWord32 r = 0;
INLINE_HEADER void ACQUIRE_SPIN_LOCK(SpinLock * p)
{
StgWord32 r = 0;
+ nat i;
do {
do {
- r = cas((StgVolatilePtr)p, 1, 0);
- } while(r == 0);
+ for (i = 0; i < SPIN_COUNT; i++) {
+ r = cas((StgVolatilePtr)p, 1, 0);
+ if (r != 0) return;
+ busy_wait_nop();
+ }
+ yieldThread();
+ } while (1);
}
// release spin lock
}
// release spin lock