]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/kern/sync_sema.h
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
27 * File: kern/sync_sema.h
28 * Author: Joseph CaraDonna
30 * Contains RT distributed semaphore synchronization service definitions.
33 #ifndef _KERN_SYNC_SEMA_H_
34 #define _KERN_SYNC_SEMA_H_
36 #include <kern/kern_types.h>
37 #include <mach/sync_policy.h>
39 #ifdef MACH_KERNEL_PRIVATE
41 #include <kern/queue.h>
42 #include <kern/lock.h>
43 #include <kern/wait_queue.h>
45 typedef struct semaphore
{
46 queue_chain_t task_link
; /* chain of semaphores owned by a task */
47 struct wait_queue wait_queue
; /* queue of blocked threads & lock */
48 task_t owner
; /* task that owns semaphore */
49 ipc_port_t port
; /* semaphore port */
50 int ref_count
; /* reference count */
51 int count
; /* current count value */
52 boolean_t active
; /* active status */
55 #define semaphore_lock(semaphore) wait_queue_lock(&(semaphore)->wait_queue)
56 #define semaphore_unlock(semaphore) wait_queue_unlock(&(semaphore)->wait_queue)
58 extern void semaphore_init(void);
60 extern void semaphore_reference (semaphore_t semaphore
);
61 extern void semaphore_dereference (semaphore_t semaphore
);
63 #endif /* MACH_KERNEL_PRIVATE */
65 #endif /* _KERN_SYNC_SEMA_H_ */