summaryrefslogtreecommitdiffstats
path: root/sys/powerpc/include/mutex.h
Commit message (Collapse)AuthorAgeFilesLines
* Change and clean the mutex lock interface.bmilekic2001-02-091-31/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mtx_enter(lock, type) becomes: mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks) mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized) similarily, for releasing a lock, we now have: mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN. We change the caller interface for the two different types of locks because the semantics are entirely different for each case, and this makes it explicitly clear and, at the same time, it rids us of the extra `type' argument. The enter->lock and exit->unlock change has been made with the idea that we're "locking data" and not "entering locked code" in mind. Further, remove all additional "flags" previously passed to the lock acquire/release routines with the exception of two: MTX_QUIET and MTX_NOSWITCH The functionality of these flags is preserved and they can be passed to the lock/unlock routines by calling the corresponding wrappers: mtx_{lock, unlock}_flags(lock, flag(s)) and mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN locks, respectively. Re-inline some lock acq/rel code; in the sleep lock case, we only inline the _obtain_lock()s in order to ensure that the inlined code fits into a cache line. In the spin lock case, we inline recursion and actually only perform a function call if we need to spin. This change has been made with the idea that we generally tend to avoid spin locks and that also the spin locks that we do have and are heavily used (i.e. sched_lock) do recurse, and therefore in an effort to reduce function call overhead for some architectures (such as alpha), we inline recursion for this case. Create a new malloc type for the witness code and retire from using the M_DEV type. The new type is called M_WITNESS and is only declared if WITNESS is enabled. Begin cleaning up some machdep/mutex.h code - specifically updated the "optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently need those. Finally, caught up to the interface changes in all sys code. Contributors: jake, jhb, jasone (in no particular order)
* Move most of sys/mutex.h into kern/kern_mutex.c, thereby making the mutexjasone2001-01-211-0/+6
| | | | | | | | | | | inline functions non-inlined. Hide parts of the mutex implementation that should not be exposed. Make sure that WITNESS code is not executed during boot until the mutexes are fully initialized by SI_SUB_MUTEX (the original motivation for this commit). Submitted by: peter
* Fix all the interrupt enabled/disabled assertions which were backwards.jhb2000-11-151-6/+6
|
* Define the mtx_legal2block() macro used in the witness code that managedjhb2000-10-201-0/+3
| | | | | | to get lost during the MI mutex conversion. Reported by: Steve Kargl <sgk@troutmask.apl.washington.edu>
* Fix a braino in the ASS_SIEN() macro in the MUTEX_DEBUG case by usingjhb2000-10-201-1/+2
| | | | mtx_saveintr instead of saveintr.
* Catch up to some of the changes to _getlock_spin_block. Specifically,jhb2000-10-201-4/+4
| | | | use _obtain_lock() instead of a manual atomic_cmpset_ptr.
* - Make the mutex code almost completely machine independent. This greatlyjhb2000-10-201-468/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | reducues the maintenance load for the mutex code. The only MD portions of the mutex code are in machine/mutex.h now, which include the assembly macros for handling mutexes as well as optionally overriding the mutex micro-operations. For example, we use optimized micro-ops on the x86 platform #ifndef I386_CPU. - Change the behavior of the SMP_DEBUG kernel option. In the new code, mtx_assert() only depends on INVARIANTS, allowing other kernel developers to have working mutex assertiions without having to include all of the mutex debugging code. The SMP_DEBUG kernel option has been renamed to MUTEX_DEBUG and now just controls extra mutex debugging code. - Abolish the ugly mtx_f hack. Instead, we dynamically allocate seperate mtx_debug structures on the fly in mtx_init, except for mutexes that are initiated very early in the boot process. These mutexes are declared using a special MUTEX_DECLARE() macro, and use a new flag MTX_COLD when calling mtx_init. This is still somewhat hackish, but it is less evil than the mtx_f filler struct, and the mtx struct is now the same size with and without mutex debugging code. - Add some micro-micro-operation macros for doing the actual atomic operations on the mutex mtx_lock field to make it easier for other archs to override/optimize mutex ops if needed. These new tiny ops also clean up the code in some places by replacing long atomic operation function calls that spanned 2-3 lines with a short 1-line macro call. - Don't call mi_switch() from mtx_enter_hard() when we block while trying to obtain a sleep mutex. Calling mi_switch() would bogusly release Giant before switching to the next process. Instead, inline most of the code from mi_switch() in the mtx_enter_hard() function. Note that when we finally kill Giant we can back this out and go back to calling mi_switch().
* Reduce userland namespace polution.jasone2000-10-041-1/+4
|
* #include <sys/proc.h> in order to get curproc. This seems to be the lesserjasone2000-09-231-2/+1
| | | | | of two evils; the greater evil is requiring sys/proc.h to be included before including machine/mutex.h.
* Remove the mtx_t, witness_t, and witness_blessed_t types. Instead, justjhb2000-09-141-25/+23
| | | | | | use struct mtx, struct witness, and struct witness_blessed. Requested by: bde
* - Fix spinlock exiting to handle recursion properly and only enablejhb2000-09-131-5/+7
| | | | | | interrupts at the proper time. - Remove an uneeded test and just always set the MTX_RECURSE bit when recursing on a sleep lock.
* Really disable interrupts for spin mutexes instead of just pretending.dfr2000-09-121-8/+6
|
* The alpha doesn't have a eflags register, so don't refer to it here.jhb2000-09-111-2/+0
|
* Style cleanups. No functional changes.jasone2000-09-091-71/+63
|
* Add file and line arguments to WITNESS_ENTER() and WITNESS_EXIT, sincejasone2000-09-091-16/+16
| | | | | | __FILE__ and __LINE__ don't get expanded usefully in inline functions. Add const to all witness*() arguments that are filenames.
* Add missing \'s to multline macros used for assertions.jhb2000-09-091-2/+2
|
* Use inline functions instead of macros for mtx_enter(), mtx_try_enter(),jasone2000-09-081-146/+160
| | | | | | | | | | | and mtx_exit(). This change tracks the i386 version. Rename mtx_enter(), mtx_try_enter(), and mtx_exit() and wrap them with cpp macros that expand to pass filename and line number information. This is necessary since we're using inline functions instead of macros now. Add const to the filename pointers passed througout the mtx and witness code.
* Major update to the way synchronization is done in the kernel. Highlightsjasone2000-09-071-0/+563
include: * Mutual exclusion is used instead of spl*(). See mutex(9). (Note: The alpha port is still in transition and currently uses both.) * Per-CPU idle processes. * Interrupts are run in their own separate kernel threads and can be preempted (i386 only). Partially contributed by: BSDi (BSD/OS) Submissions by (at least): cp, dfr, dillon, grog, jake, jhb, sheldonh
OpenPOWER on IntegriCloud