ck_backoff: Replace ck_backoff_eb with ck_backoff_gb.

The distinction between additive/exponential implementation
and geometric implementation does little but confuse users.
The terminology used in ck_backoff now reflects terminology
used in literature.

ck_backoff_gb has been removed.
ck_pring
Samy Al Bahra 12 years ago
parent d55e588ee4
commit 0631e396e0

@ -38,7 +38,7 @@
typedef volatile unsigned int ck_backoff_t;
/*
* This is an exponential back-off implementation.
* This is a exponential back-off implementation.
*/
CK_CC_INLINE static void
ck_backoff_eb(volatile unsigned int *c)
@ -50,27 +50,6 @@ ck_backoff_eb(volatile unsigned int *c)
for (i = 0; i < ceiling; i++);
ceiling *= ceiling;
ceiling &= CK_BACKOFF_CEILING;
ceiling += CK_BACKOFF_INITIALIZER;
*c = ceiling;
return;
}
/*
* This is a geometric back-off implementation.
*/
CK_CC_INLINE static void
ck_backoff_gb(volatile unsigned int *c)
{
volatile unsigned int i;
unsigned int ceiling;
ceiling = *c;
for (i = 0; i < ceiling; i++);
*c = ceiling <<= ceiling < CK_BACKOFF_CEILING;
return;
}

@ -41,8 +41,9 @@ main(void)
for (;;) {
ck_backoff_t previous = backoff;
ck_backoff_gb(&backoff);
ck_backoff_eb(&backoff);
printf("EB %u\n", backoff);
if (previous == ceiling) {
if (backoff != ceiling)
ck_error("[C] GB: expected %u, got %u\n", ceiling, backoff);
@ -54,19 +55,6 @@ main(void)
}
}
backoff = CK_BACKOFF_INITIALIZER;
for (;;) {
ck_backoff_t previous = backoff;
ck_backoff_eb(&backoff);
if (backoff = previous) {
if (i++ >= 3)
break;
} else if (previous * previous >= backoff) {
ck_error("[N] EB: expected %u (%u), got %u\n", previous * previous, previous, backoff);
}
}
return 0;
}

@ -316,7 +316,7 @@ ck_hp_purge(struct ck_hp_record *thread)
while (thread->n_pending > 0) {
ck_hp_reclaim(thread);
if (thread->n_pending > 0)
ck_backoff_gb(&backoff);
ck_backoff_eb(&backoff);
}
return;

Loading…
Cancel
Save