Reindent of server/core/spinlock.c
This commit is contained in:
@ -82,8 +82,10 @@ int spins = 0;
|
|||||||
{
|
{
|
||||||
lock->contended++;
|
lock->contended++;
|
||||||
if (lock->maxspins < spins)
|
if (lock->maxspins < spins)
|
||||||
|
{
|
||||||
lock->maxspins = spins;
|
lock->maxspins = spins;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
lock->acquired++;
|
lock->acquired++;
|
||||||
lock->owner = THREAD_SHELF();
|
lock->owner = THREAD_SHELF();
|
||||||
atomic_add(&(lock->waiting), -1);
|
atomic_add(&(lock->waiting), -1);
|
||||||
@ -125,7 +127,9 @@ spinlock_release(SPINLOCK *lock)
|
|||||||
{
|
{
|
||||||
#if SPINLOCK_PROFILE
|
#if SPINLOCK_PROFILE
|
||||||
if (lock->waiting > lock->max_waiting)
|
if (lock->waiting > lock->max_waiting)
|
||||||
|
{
|
||||||
lock->max_waiting = lock->waiting;
|
lock->max_waiting = lock->waiting;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
__sync_synchronize(); /* Memory barrier. */
|
__sync_synchronize(); /* Memory barrier. */
|
||||||
@ -159,8 +163,10 @@ spinlock_stats(SPINLOCK *lock, void (*reporter)(void *, char *, int), void *hdl)
|
|||||||
reporter(hdl, "Average no. of spins (overall)",
|
reporter(hdl, "Average no. of spins (overall)",
|
||||||
lock->spins / lock->acquired);
|
lock->spins / lock->acquired);
|
||||||
if (lock->contended)
|
if (lock->contended)
|
||||||
|
{
|
||||||
reporter(hdl, "Average no. of spins (when contended)",
|
reporter(hdl, "Average no. of spins (when contended)",
|
||||||
lock->spins / lock->contended);
|
lock->spins / lock->contended);
|
||||||
|
}
|
||||||
reporter(hdl, "Maximum no. of spins", lock->maxspins);
|
reporter(hdl, "Maximum no. of spins", lock->maxspins);
|
||||||
reporter(hdl, "Maximim no. of blocked threads",
|
reporter(hdl, "Maximim no. of blocked threads",
|
||||||
lock->max_waiting);
|
lock->max_waiting);
|
||||||
|
@ -43,7 +43,8 @@
|
|||||||
* a number of profile related fields that count the number of spins, number
|
* a number of profile related fields that count the number of spins, number
|
||||||
* of waiting threads and the number of times the lock has been acquired.
|
* of waiting threads and the number of times the lock has been acquired.
|
||||||
*/
|
*/
|
||||||
typedef struct spinlock {
|
typedef struct spinlock
|
||||||
|
{
|
||||||
int lock; /*< Is the lock held? */
|
int lock; /*< Is the lock held? */
|
||||||
#if SPINLOCK_PROFILE
|
#if SPINLOCK_PROFILE
|
||||||
int spins; /*< Number of spins on this lock */
|
int spins; /*< Number of spins on this lock */
|
||||||
@ -75,6 +76,6 @@ extern void spinlock_init(SPINLOCK *lock);
|
|||||||
extern void spinlock_acquire(SPINLOCK *lock);
|
extern void spinlock_acquire(SPINLOCK *lock);
|
||||||
extern int spinlock_acquire_nowait(SPINLOCK *lock);
|
extern int spinlock_acquire_nowait(SPINLOCK *lock);
|
||||||
extern void spinlock_release(SPINLOCK *lock);
|
extern void spinlock_release(SPINLOCK *lock);
|
||||||
extern void spinlock_stats(SPINLOCK *lock,
|
extern void spinlock_stats(SPINLOCK *lock, void (*reporter)(void *, char *, int), void *hdl);
|
||||||
void (*reporter)(void *, char *, int), void *hdl);
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user