Changeset 13108f24 in mainline


Ignore:
Timestamp:
2010-04-29T19:23:09Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bcb6f27
Parents:
c050399
Message:

Split spinlock_unlock() into a debug and non-debug version.

The non-debug version, spinlock_unlock_nondebug(), will likely get inlined just
as its counterpart spinlock_lock_arch(). It will not do any sanity checking.

The debug version, spinlock_unlock_debug(), will, on the other hand, not be
inlined, aiding thus the readibility of the generated assembly code. It will be
easier to spot the corresponding spinlock_lock_debug() and
spinlock_unlock_debug() pairs. It is meant to perform thorough sanity checking.

Location:
kernel/generic
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/synch/spinlock.h

    rc050399 r13108f24  
    7777        }
    7878
    79 #define spinlock_lock(lock)  spinlock_lock_debug(lock)
     79#define spinlock_lock(lock)     spinlock_lock_debug((lock))
     80#define spinlock_unlock(lock)   spinlock_unlock_debug((lock))
    8081
    8182#else
     
    9192        }
    9293
    93 #define spinlock_lock(lock)  atomic_lock_arch(&(lock)->val)
     94#define spinlock_lock(lock)     atomic_lock_arch(&(lock)->val)
     95#define spinlock_unlock(lock)   spinlock_unlock_nondebug((lock))
    9496
    9597#endif
     
    104106extern int spinlock_trylock(spinlock_t *lock);
    105107extern void spinlock_lock_debug(spinlock_t *lock);
     108extern void spinlock_unlock_debug(spinlock_t *lock);
    106109
    107110/** Unlock spinlock
    108111 *
    109  * Unlock spinlock.
     112 * Unlock spinlock for non-debug kernels.
    110113 *
    111114 * @param sl Pointer to spinlock_t structure.
    112115 */
    113 static inline void spinlock_unlock(spinlock_t *lock)
     116static inline void spinlock_unlock_nondebug(spinlock_t *lock)
    114117{
    115         ASSERT(atomic_get(&lock->val) != 0);
    116        
    117118        /*
    118119         * Prevent critical section code from bleeding out this way down.
  • kernel/generic/src/synch/spinlock.c

    rc050399 r13108f24  
    120120}
    121121
     122/** Unlock spinlock
     123 *
     124 * Unlock spinlock.
     125 *
     126 * @param sl Pointer to spinlock_t structure.
     127 */
     128void spinlock_unlock_debug(spinlock_t *lock)
     129{
     130        ASSERT(atomic_get(&lock->val) != 0);
     131       
     132        /*
     133         * Prevent critical section code from bleeding out this way down.
     134         */
     135        CS_LEAVE_BARRIER();
     136       
     137        atomic_set(&lock->val, 0);
     138        preemption_enable();
     139}
     140
    122141#endif
    123142
Note: See TracChangeset for help on using the changeset viewer.