Annotation of XNU/osfmk/kern/sync_lock.h, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
                      3:  *
                      4:  * @APPLE_LICENSE_HEADER_START@
                      5:  * 
                      6:  * The contents of this file constitute Original Code as defined in and
                      7:  * are subject to the Apple Public Source License Version 1.1 (the
                      8:  * "License").  You may not use this file except in compliance with the
                      9:  * License.  Please obtain a copy of the License at
                     10:  * http://www.apple.com/publicsource and read it before using this file.
                     11:  * 
                     12:  * This Original Code and all software distributed under the License are
                     13:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
                     14:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
                     15:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
                     16:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
                     17:  * License for the specific language governing rights and limitations
                     18:  * under the License.
                     19:  * 
                     20:  * @APPLE_LICENSE_HEADER_END@
                     21:  */
                     22: /*
                     23:  * @OSF_COPYRIGHT@
                     24:  * 
                     25:  */
                     26: /*
                     27:  *     File:   kern/sync_lock.h
                     28:  *     Author: Joseph CaraDonna
                     29:  *
                     30:  *     Contains RT distributed lock synchronization service definitions.
                     31:  */
                     32: 
                     33: #ifndef _KERN_SYNC_LOCK_H_
                     34: #define _KERN_SYNC_LOCK_H_
                     35: 
                     36: #include <mach/mach_types.h>
                     37: 
                     38: #ifdef MACH_KERNEL_PRIVATE
                     39: 
                     40: #include <kern/wait_queue.h>
                     41: #include <kern/macro_help.h>
                     42: #include <kern/queue.h>
                     43: #include <kern/lock.h>
                     44: 
                     45: typedef struct ulock {
                     46:        queue_chain_t   thread_link;    /* ulocks owned by a thread         */
                     47:        queue_chain_t   held_link;      /* ulocks held in the lock set      */
                     48:        queue_chain_t   handoff_link;   /* ulocks w/ active handoffs        */
                     49: 
                     50:        decl_mutex_data(,lock)          /* ulock lock                       */
                     51: 
                     52:        struct lock_set *lock_set;      /* the retaining lock set           */
                     53:        thread_act_t    holder;         /* thread_act that holds the lock   */
                     54:        unsigned int                    /* flags                            */
                     55:        /* boolean_t */ blocked:1,      /*     did threads block waiting?   */
                     56:        /* boolean_t */ unstable:1,     /*     unstable? (holder died)      */
                     57:        /* boolean_t */ ho_wait:1,      /*     handoff thread waiting?      */
                     58:        /* boolean_t */ accept_wait:1,  /*     accepting thread waiting?    */
                     59:                        :0;             /*     force to long boundary       */
                     60: 
                     61:        struct wait_queue wait_queue;   /* queue of blocked threads         */
                     62: } Ulock;
                     63: 
                     64: typedef struct ulock *ulock_t;
                     65: 
                     66: typedef struct lock_set {
                     67:        queue_chain_t   task_link;   /* chain of lock sets owned by a task  */
                     68:        decl_mutex_data(,lock)       /* lock set lock                       */
                     69:        task_t          owner;       /* task that owns the lock set         */
                     70:        ipc_port_t      port;        /* lock set port                       */
                     71:        int             ref_count;   /* reference count                     */
                     72: 
                     73:        boolean_t       active;      /* active status                       */
                     74:        int             n_ulocks;    /* number of ulocks in the lock set    */
                     75: 
                     76:        struct ulock    ulock_list[1];  /* ulock group list place holder    */
                     77: } Lock_Set;
                     78: 
                     79: #define ULOCK_NULL     ((ulock_t) 0)
                     80: 
                     81: #define ULOCK_FREE     0
                     82: #define ULOCK_HELD     1
                     83: 
                     84: #define LOCK_OPERATION_ABORTED(th)   ((th)->wait_link.prev != (queue_entry_t) 0)
                     85: #define LOCK_OPERATION_COMPLETE(th)  ((th)->wait_link.prev  = (queue_entry_t) 0)
                     86: 
                     87: /*
                     88:  *  Data structure internal lock macros
                     89:  */
                     90: 
                     91: #define lock_set_lock_init(ls)         mutex_init(&(ls)->lock, \
                     92:                                                   ETAP_THREAD_LOCK_SET)
                     93: #define lock_set_lock(ls)              mutex_lock(&(ls)->lock)
                     94: #define lock_set_unlock(ls)            mutex_unlock(&(ls)->lock)
                     95: 
                     96: #define ulock_lock_init(ul)            mutex_init(&(ul)->lock, \
                     97:                                                   ETAP_THREAD_ULOCK)
                     98: #define ulock_lock(ul)                 mutex_lock(&(ul)->lock)
                     99: #define ulock_unlock(ul)               mutex_unlock(&(ul)->lock)
                    100: 
                    101: #endif /* MACH_KERNEL_PRIVATE */
                    102: 
                    103: /*
                    104:  *     Forward Declarations
                    105:  */
                    106: 
                    107: extern kern_return_t   lock_set_create         (task_t task,
                    108:                                                 lock_set_t *new_lock_set,
                    109:                                                 int n_ulocks,
                    110:                                                 int policy);
                    111: 
                    112: extern kern_return_t   lock_set_destroy        (task_t task,
                    113:                                                 lock_set_t lock_set);
                    114: 
                    115: extern kern_return_t   lock_acquire            (lock_set_t lock_set,
                    116:                                                 int lock_id);
                    117: 
                    118: extern kern_return_t   lock_release            (lock_set_t lock_set,
                    119:                                                 int lock_id);
                    120: 
                    121: extern kern_return_t   lock_try                (lock_set_t lock_set,
                    122:                                                 int lock_id);
                    123: 
                    124: extern kern_return_t   lock_make_stable        (lock_set_t lock_set,
                    125:                                                 int lock_id);         
                    126: 
                    127: extern  kern_return_t  lock_make_unstable      (ulock_t ulock,
                    128:                                                 thread_act_t thr_act);
                    129: 
                    130: extern kern_return_t   lock_release_internal   (ulock_t ulock,
                    131:                                                 thread_act_t thr_act);
                    132: 
                    133: extern kern_return_t   lock_handoff            (lock_set_t lock_set,
                    134:                                                 int lock_id);
                    135: 
                    136: extern kern_return_t   lock_handoff_accept     (lock_set_t lock_set,
                    137:                                                 int lock_id);
                    138: 
                    139: extern void            lock_set_reference      (lock_set_t lock_set);
                    140: extern void            lock_set_dereference    (lock_set_t lock_set);
                    141: 
                    142: #endif /* _KERN_SYNC_LOCK_H_ */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.