ck_backoff: Remove usage of volatile.

This avoids memory traffic in busy-wait loops.  Been on TODO list for a while,
may as well bite the bullet.  No regressions introduced in recent versions of
GCC, clang and ICC.
ck_pring
Samy Al Bahra 10 years ago
parent 70e59219bc
commit 508e92d2fc

@ -28,6 +28,7 @@
#define _CK_BACKOFF_H
#include <ck_cc.h>
#include <ck_pr.h>
#ifndef CK_BACKOFF_CEILING
#define CK_BACKOFF_CEILING ((1 << 20) - 1)
@ -35,20 +36,19 @@
#define CK_BACKOFF_INITIALIZER (1 << 9)
typedef volatile unsigned int ck_backoff_t;
typedef unsigned int ck_backoff_t;
/*
* This is a exponential back-off implementation.
*/
CK_CC_INLINE static void
ck_backoff_eb(volatile unsigned int *c)
ck_backoff_eb(unsigned int *c)
{
volatile unsigned int i;
unsigned int ceiling;
unsigned int i, ceiling;
ceiling = *c;
for (i = 0; i < ceiling; i++);
for (i = 0; i < ceiling; i++)
ck_pr_barrier();
*c = ceiling <<= ceiling < CK_BACKOFF_CEILING;
return;

Loading…
Cancel
Save