*
* @APPLE_LICENSE_HEADER_END@
*/
-/*
- * Copyright (C) 1998 Apple Computer
- * All Rights Reserved
- */
/*
* @OSF_COPYRIGHT@
*/
*
*/
+#include <sys/appleapiopts.h>
+
+#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 <mach_ldebug.h>
#include <kern/etap_options.h>
#include <kern/etap_pool.h>
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
#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,
* 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
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*);
#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_ */