Reindent of server/core/spinlock.c

This commit is contained in:
Johan Wikman
2015-11-30 20:12:58 +02:00
parent 15df33a93f
commit a95be21266
2 changed files with 55 additions and 48 deletions

View File

@ -82,8 +82,10 @@ int spins = 0;
{
lock->contended++;
if (lock->maxspins < spins)
{
lock->maxspins = spins;
}
}
lock->acquired++;
lock->owner = THREAD_SHELF();
atomic_add(&(lock->waiting), -1);
@ -125,7 +127,9 @@ spinlock_release(SPINLOCK *lock)
{
#if SPINLOCK_PROFILE
if (lock->waiting > lock->max_waiting)
{
lock->max_waiting = lock->waiting;
}
#endif
#ifdef __GNUC__
__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)",
lock->spins / lock->acquired);
if (lock->contended)
{
reporter(hdl, "Average no. of spins (when contended)",
lock->spins / lock->contended);
}
reporter(hdl, "Maximum no. of spins", lock->maxspins);
reporter(hdl, "Maximim no. of blocked threads",
lock->max_waiting);

View File

@ -43,7 +43,8 @@
* 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.
*/
typedef struct spinlock {
typedef struct spinlock
{
int lock; /*< Is the lock held? */
#if SPINLOCK_PROFILE
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 int spinlock_acquire_nowait(SPINLOCK *lock);
extern void spinlock_release(SPINLOCK *lock);
extern void spinlock_stats(SPINLOCK *lock,
void (*reporter)(void *, char *, int), void *hdl);
extern void spinlock_stats(SPINLOCK *lock, void (*reporter)(void *, char *, int), void *hdl);
#endif