]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/kern/sync_sema.h
c25950a936aa2ad8d9b926d14aaa7fea804f0b95
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
30 * File: kern/sync_sema.h
31 * Author: Joseph CaraDonna
33 * Contains RT distributed semaphore synchronization service definitions.
36 #ifndef _KERN_SYNC_SEMA_H_
37 #define _KERN_SYNC_SEMA_H_
39 #include <kern/kern_types.h>
40 #include <mach/sync_policy.h>
42 #ifdef MACH_KERNEL_PRIVATE
44 #include <kern/queue.h>
45 #include <kern/lock.h>
46 #include <kern/wait_queue.h>
48 typedef struct semaphore
{
49 queue_chain_t task_link
; /* chain of semaphores owned by a task */
50 struct wait_queue wait_queue
; /* queue of blocked threads & lock */
51 task_t owner
; /* task that owns semaphore */
52 ipc_port_t port
; /* semaphore port */
53 int ref_count
; /* reference count */
54 int count
; /* current count value */
55 boolean_t active
; /* active status */
58 #define semaphore_lock(semaphore) wait_queue_lock(&(semaphore)->wait_queue)
59 #define semaphore_unlock(semaphore) wait_queue_unlock(&(semaphore)->wait_queue)
61 extern void semaphore_init(void);
63 extern void semaphore_reference (semaphore_t semaphore
);
64 extern void semaphore_dereference (semaphore_t semaphore
);
66 #endif /* MACH_KERNEL_PRIVATE */
68 #endif /* _KERN_SYNC_SEMA_H_ */