]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/kern/locks.h
xnu-4903.241.1.tar.gz
[apple/xnu.git] / osfmk / kern / locks.h
index 5a29c2e14ede81961d75552dae635b087eb4432d..4db3c40f51de3609b7a04d3eed98d7d771be3984 100644 (file)
@@ -59,8 +59,9 @@ typedef       unsigned int            lck_sleep_action_t;
 #define        LCK_SLEEP_EXCLUSIVE     0x04    /* Reclaim the lock in exclusive mode (RW only) */
 #define        LCK_SLEEP_SPIN          0x08    /* Reclaim the lock in spin mode (mutex only) */
 #define        LCK_SLEEP_PROMOTED_PRI  0x10    /* Sleep at a promoted priority */
+#define        LCK_SLEEP_SPIN_ALWAYS   0x20    /* Reclaim the lock in spin-always mode (mutex only) */
 
-#define        LCK_SLEEP_MASK          0x1f    /* Valid actions */
+#define        LCK_SLEEP_MASK          0x3f    /* Valid actions */
 
 #ifdef MACH_KERNEL_PRIVATE
 
@@ -115,6 +116,12 @@ typedef    struct _lck_grp_ {
        lck_grp_stat_t          lck_grp_stat;
 } lck_grp_t;
 
+#define lck_grp_miss           lck_grp_stat.lck_grp_mtx_stat.lck_grp_mtx_miss_cnt
+#define lck_grp_held           lck_grp_stat.lck_grp_mtx_stat.lck_grp_mtx_held_cnt
+#define lck_grp_util           lck_grp_stat.lck_grp_mtx_stat.lck_grp_mtx_util_cnt
+#define lck_grp_wait           lck_grp_stat.lck_grp_mtx_stat.lck_grp_mtx_wait_cnt
+#define lck_grp_direct_wait    lck_grp_stat.lck_grp_mtx_stat.lck_grp_mtx_held_cnt
+
 #define LCK_GRP_NULL   (lck_grp_t *)0
 
 #else
@@ -264,8 +271,14 @@ extern wait_result_t       lck_spin_sleep_deadline(
 
 #ifdef KERNEL_PRIVATE
 
+extern void                    lck_spin_lock_nopreempt(                lck_spin_t              *lck);
+
+extern void                    lck_spin_unlock_nopreempt(              lck_spin_t              *lck);
+
 extern boolean_t               lck_spin_try_lock(                      lck_spin_t              *lck);
 
+extern boolean_t               lck_spin_try_lock_nopreempt(            lck_spin_t              *lck);
+
 /* NOT SAFE: To be used only by kernel debugger to avoid deadlock. */
 extern boolean_t               kdp_lck_spin_is_acquired(               lck_spin_t              *lck);
 
@@ -312,6 +325,17 @@ extern wait_result_t       lck_mtx_sleep_deadline(
                                                                        event_t                         event,
                                                                        wait_interrupt_t        interruptible,
                                                                        uint64_t                        deadline);
+#if DEVELOPMENT || DEBUG
+extern void            erase_all_test_mtx_stats(void);
+extern int             get_test_mtx_stats_string(char* buffer, int buffer_size);
+extern void            lck_mtx_test_init(void);
+extern void            lck_mtx_test_lock(void);
+extern void            lck_mtx_test_unlock(void);
+extern int             lck_mtx_test_mtx_uncontended(int iter, char* buffer, int buffer_size);
+extern int             lck_mtx_test_mtx_contended(int iter, char* buffer, int buffer_size);
+extern int             lck_mtx_test_mtx_uncontended_loop_time(int iter, char* buffer, int buffer_size);
+extern int             lck_mtx_test_mtx_contended_loop_time(int iter, char* buffer, int buffer_size);
+#endif
 
 #ifdef KERNEL_PRIVATE
 
@@ -358,14 +382,22 @@ extern void                               lck_mtx_assert(
 
 #if MACH_ASSERT
 #define LCK_MTX_ASSERT(lck,type) lck_mtx_assert((lck),(type))
+#define LCK_SPIN_ASSERT(lck,type) lck_spin_assert((lck),(type))
+#define LCK_RW_ASSERT(lck,type) lck_rw_assert((lck),(type))
 #else /* MACH_ASSERT */
 #define LCK_MTX_ASSERT(lck,type)
+#define LCK_SPIN_ASSERT(lck,type)
+#define LCK_RW_ASSERT(lck,type)
 #endif /* MACH_ASSERT */
 
 #if DEBUG
 #define LCK_MTX_ASSERT_DEBUG(lck,type) lck_mtx_assert((lck),(type))
+#define LCK_SPIN_ASSERT_DEBUG(lck,type) lck_spin_assert((lck),(type))
+#define LCK_RW_ASSERT_DEBUG(lck,type) lck_rw_assert((lck),(type))
 #else /* DEBUG */
 #define LCK_MTX_ASSERT_DEBUG(lck,type)
+#define LCK_SPIN_ASSERT_DEBUG(lck,type)
+#define LCK_RW_ASSERT_DEBUG(lck,type)
 #endif /* DEBUG */
 
 __END_DECLS
@@ -387,8 +419,6 @@ extern int                          lck_mtx_lock_acquire(
 extern void                            lck_mtx_unlock_wakeup(
                                                                        lck_mtx_t               *lck,
                                                                        thread_t                holder);
-extern void                            lck_mtx_unlockspin_wakeup(
-                                                                       lck_mtx_t               *lck);
 
 extern boolean_t               lck_mtx_ilk_unlock(
                                                                        lck_mtx_t               *lck);
@@ -396,6 +426,8 @@ extern boolean_t            lck_mtx_ilk_unlock(
 extern boolean_t               lck_mtx_ilk_try_lock(
                                                                        lck_mtx_t               *lck);
 
+extern void lck_mtx_wakeup_adjust_pri(thread_t thread, integer_t priority);
+
 #endif
 
 #define decl_lck_rw_data(class,name)     class lck_rw_t name;
@@ -437,6 +469,10 @@ extern void                                lck_rw_lock_shared(
 extern void                            lck_rw_unlock_shared(
                                                                        lck_rw_t                *lck);
 
+extern boolean_t                       lck_rw_lock_yield_shared(
+                                                                       lck_rw_t                *lck,
+                                                                       boolean_t       force_yield);
+
 extern void                            lck_rw_lock_exclusive(
                                                                        lck_rw_t                *lck);
 
@@ -453,9 +489,10 @@ extern void                                lck_rw_assert(
                                                                        lck_rw_t                *lck,
                                                                        unsigned int            type);
 
-extern void                            lck_rw_clear_promotion(
-                                                                       thread_t                thread);
+extern void lck_rw_clear_promotion(thread_t thread, uintptr_t trace_obj);
 extern void lck_rw_set_promotion_locked(thread_t thread);
+
+uintptr_t unslide_for_kdebug(void* object);
 #endif
 
 #ifdef KERNEL_PRIVATE