X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/1c79356b52d46aa6b508fb032f5ae709b1f2897b..a3d08fcd5120d2aa8303b6349ca8b14e3f284af3:/osfmk/kern/lock.h diff --git a/osfmk/kern/lock.h b/osfmk/kern/lock.h index 65cd1f18f..cbb9cdb6b 100644 --- a/osfmk/kern/lock.h +++ b/osfmk/kern/lock.h @@ -19,10 +19,6 @@ * * @APPLE_LICENSE_HEADER_END@ */ -/* - * Copyright (C) 1998 Apple Computer - * All Rights Reserved - */ /* * @OSF_COPYRIGHT@ */ @@ -108,13 +104,19 @@ * */ +#include + +#ifdef __APPLE_API_PRIVATE + +#ifdef MACH_KERNEL_PRIVATE + /* * A simple mutex lock. * Do not change the order of the fields in this structure without * changing the machine-dependent assembler routines which depend * on them. */ -#ifdef MACH_KERNEL_PRIVATE + #include #include #include @@ -122,7 +124,8 @@ typedef struct { hw_lock_data_t interlock; hw_lock_data_t locked; - short waiters; + uint16_t waiters; + uint16_t promoted_pri; #if MACH_LDEBUG int type; #define MUTEX_TAG 0x4d4d @@ -150,32 +153,63 @@ typedef struct { #define decl_mutex_data(class,name) class mutex_t name; #define mutex_addr(m) (&(m)) -#if MACH_LDEBUG -#define mutex_held(m) (hw_lock_held(&((m)->locked)) && \ - ((m)->thread == (int)current_thread())) -#else /* MACH_LDEBUG */ -#define mutex_held(m) hw_lock_held(&((m)->locked)) -#endif /* MACH_LDEBUG */ +extern void mutex_init( + mutex_t *mutex, + etap_event_t tag); + +extern void mutex_lock_wait( + mutex_t *mutex, + thread_t holder); + +extern int mutex_lock_acquire( + mutex_t *mutex); + +extern void mutex_unlock_wakeup( + mutex_t *mutex, + thread_t holder); + +extern boolean_t mutex_preblock( + mutex_t *mutex, + thread_t thread); + +extern boolean_t mutex_preblock_wait( + mutex_t *mutex, + thread_t thread, + thread_t holder); -#else /* MACH_KERNEL_PRIVATE */ +extern void interlock_unlock( + hw_lock_t lock); + +#endif /* MACH_KERNEL_PRIVATE */ + +extern void mutex_pause(void); + +#endif /* __APPLE_API_PRIVATE */ + +#if !defined(MACH_KERNEL_PRIVATE) typedef struct __mutex__ mutex_t; -extern boolean_t mutex_held(mutex_t*); -#endif /* !MACH_KERNEL_PRIVATE */ +#endif /* MACH_KERNEL_PRIVATE */ + +extern mutex_t *mutex_alloc( + etap_event_t tag); + +extern void mutex_free( + mutex_t *mutex); + +extern void mutex_lock( + mutex_t *mutex); -extern mutex_t *mutex_alloc (etap_event_t); -extern void mutex_free (mutex_t*); +extern void mutex_unlock( + mutex_t *mutex); -extern void mutex_init (mutex_t*, etap_event_t); -extern void _mutex_lock (mutex_t*); -extern void mutex_unlock (mutex_t*); -extern boolean_t _mutex_try (mutex_t*); +extern boolean_t mutex_try( + mutex_t *mutex); -extern void mutex_lock_wait (mutex_t*); -extern void mutex_unlock_wakeup (mutex_t*); -extern void mutex_pause (void); -extern void interlock_unlock (hw_lock_t); +#ifdef __APPLE_API_PRIVATE + +#ifdef MACH_KERNEL_PRIVATE /* * The general lock structure. Provides for multiple readers, @@ -190,7 +224,7 @@ extern void interlock_unlock (hw_lock_t); * other fields are modified with normal instructions after * acquiring the interlock bit. */ -#ifdef MACH_KERNEL_PRIVATE + typedef struct { decl_simple_lock_data(,interlock) /* "hardware" interlock field */ volatile unsigned int @@ -253,13 +287,19 @@ extern void lock_init (lock_t*, etap_event_t, etap_event_t); -#else /* MACH_KERNEL_PRIVATE */ +#endif /* MACH_KERNEL_PRIVATE */ + +extern unsigned int LockTimeOut; /* Standard lock timeout value */ + +#endif /* __APPLE_API_PRIVATE */ + +#if !defined(MACH_KERNEL_PRIVATE) typedef struct __lock__ lock_t; extern lock_t *lock_alloc(boolean_t, etap_event_t, etap_event_t); void lock_free(lock_t *); -#endif /* !MACH_KERNEL_PRIVATE */ +#endif /* MACH_KERNEL_PRIVATE */ extern void lock_write (lock_t*); extern void lock_read (lock_t*); @@ -270,6 +310,5 @@ extern void lock_write_to_read (lock_t*); #define lock_write_done(l) lock_done(l) extern boolean_t lock_read_to_write (lock_t*); /* vm_map is only user */ -extern unsigned int LockTimeOut; /* Standard lock timeout value */ #endif /* _KERN_LOCK_H_ */