]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/i386/locks.h
xnu-792.22.5.tar.gz
[apple/xnu.git] / osfmk / i386 / locks.h
index 6df093a6afc8ca607ffb5a1fbee73c47ac9e9da8..3129d79bd0942f67334e7110fe0563baa81f6b6f 100644 (file)
@@ -1,31 +1,29 @@
 /*
  * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
  *
 /*
  * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
  *
- * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
  * 
- * This file contains Original Code and/or Modifications of Original Code 
- * as defined in and that are subject to the Apple Public Source License 
- * Version 2.0 (the 'License'). You may not use this file except in 
- * compliance with the License.  The rights granted to you under the 
- * License may not be used to create, or enable the creation or 
- * redistribution of, unlawful or unlicensed copies of an Apple operating 
- * system, or to circumvent, violate, or enable the circumvention or 
- * violation of, any terms of an Apple operating system software license 
- * agreement.
- *
- * Please obtain a copy of the License at 
- * http://www.opensource.apple.com/apsl/ and read it before using this 
- * file.
- *
- * The Original Code and all software distributed under the License are 
- * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 
- * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 
- * Please see the License for the specific language governing rights and 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
+ * 
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
  * limitations under the License.
  * limitations under the License.
- *
- * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
+ * 
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
  */
 
 #ifndef        _I386_LOCKS_H_
  */
 
 #ifndef        _I386_LOCKS_H_
@@ -90,6 +88,12 @@ typedef struct _lck_mtx_ {
 #define        LCK_MTX_TAG_INDIRECT                    0x00001007      /* lock marked as Indirect  */
 #define        LCK_MTX_TAG_DESTROYED                   0x00002007      /* lock marked as Destroyed */
 
 #define        LCK_MTX_TAG_INDIRECT                    0x00001007      /* lock marked as Indirect  */
 #define        LCK_MTX_TAG_DESTROYED                   0x00002007      /* lock marked as Destroyed */
 
+/* Adaptive spin before blocking */
+extern unsigned int    MutexSpin;
+extern void            lck_mtx_lock_spin(lck_mtx_t *lck);
+
+extern void            lck_mtx_interlock_spin(lck_mtx_t *lck);
+
 typedef struct {
        unsigned int            type;
        vm_offset_t             pc;
 typedef struct {
        unsigned int            type;
        vm_offset_t             pc;
@@ -111,9 +115,9 @@ typedef struct _lck_mtx_ext_ {
 } lck_mtx_ext_t;
 
 #define        LCK_MTX_ATTR_DEBUG      0x1
 } lck_mtx_ext_t;
 
 #define        LCK_MTX_ATTR_DEBUG      0x1
-#define        LCK_MTX_ATTR_DEBUGb     31
+#define        LCK_MTX_ATTR_DEBUGb     0
 #define        LCK_MTX_ATTR_STAT       0x2
 #define        LCK_MTX_ATTR_STAT       0x2
-#define        LCK_MTX_ATTR_STATb      30
+#define        LCK_MTX_ATTR_STATb      1
 
 #else
 #ifdef KERNEL_PRIVATE
 
 #else
 #ifdef KERNEL_PRIVATE
@@ -131,12 +135,24 @@ typedef struct {
        volatile unsigned int
                                                read_count:16,  /* No. of accepted readers */
                                                want_upgrade:1, /* Read-to-write upgrade waiting */
        volatile unsigned int
                                                read_count:16,  /* No. of accepted readers */
                                                want_upgrade:1, /* Read-to-write upgrade waiting */
-                                               want_write:1,   /* Writer is waiting, or locked for write */
+                       want_write:1,   /* Writer waiting or locked for write */
                                                waiting:1,              /* Someone is sleeping on lock */
                                                waiting:1,              /* Someone is sleeping on lock */
-                                               can_sleep:1;    /* Can attempts to lock go to sleep? */
+                       can_sleep:1,    /* Can attempts to lock go to sleep? */
+                       read_priority:1;/* New read takes piority over write */
        unsigned int            lck_rw_tag;
 } lck_rw_t;
 
        unsigned int            lck_rw_tag;
 } lck_rw_t;
 
+#define        LCK_RW_ATTR_DEBUG       0x1
+#define        LCK_RW_ATTR_DEBUGb      0
+#define        LCK_RW_ATTR_STAT        0x2
+#define        LCK_RW_ATTR_STATb       1
+#define LCK_RW_ATTR_READ_PRI   0x3
+#define LCK_RW_ATTR_READ_PRIb  2
+#define        LCK_RW_ATTR_DIS_THREAD  0x40000000
+#define        LCK_RW_ATTR_DIS_THREADb 30
+#define        LCK_RW_ATTR_DIS_MYLOCK  0x10000000
+#define        LCK_RW_ATTR_DIS_MYLOCKb 28
+
 #define        LCK_RW_TAG_DESTROYED            0x00002007      /* lock marked as Destroyed */
 
 #else
 #define        LCK_RW_TAG_DESTROYED            0x00002007      /* lock marked as Destroyed */
 
 #else