]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
43866e37 | 6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. |
1c79356b | 7 | * |
43866e37 A |
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 | |
13 | * file. | |
14 | * | |
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 | |
1c79356b A |
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
43866e37 A |
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. | |
1c79356b A |
22 | * |
23 | * @APPLE_LICENSE_HEADER_END@ | |
24 | */ | |
25 | /* | |
26 | * @OSF_COPYRIGHT@ | |
27 | * | |
28 | */ | |
29 | /* | |
30 | * File: kern/sync_sema.h | |
31 | * Author: Joseph CaraDonna | |
32 | * | |
33 | * Contains RT distributed semaphore synchronization service definitions. | |
34 | */ | |
35 | ||
36 | #ifndef _KERN_SYNC_SEMA_H_ | |
37 | #define _KERN_SYNC_SEMA_H_ | |
38 | ||
39 | #include <kern/kern_types.h> | |
40 | #include <mach/sync_policy.h> | |
41 | ||
42 | #ifdef MACH_KERNEL_PRIVATE | |
43 | ||
44 | #include <kern/queue.h> | |
45 | #include <kern/lock.h> | |
46 | #include <kern/wait_queue.h> | |
47 | ||
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 */ | |
56 | } Semaphore; | |
57 | ||
58 | #define semaphore_lock(semaphore) wait_queue_lock(&(semaphore)->wait_queue) | |
59 | #define semaphore_unlock(semaphore) wait_queue_unlock(&(semaphore)->wait_queue) | |
60 | ||
61 | extern void semaphore_init(void); | |
62 | ||
63 | extern void semaphore_reference (semaphore_t semaphore); | |
64 | extern void semaphore_dereference (semaphore_t semaphore); | |
65 | ||
66 | #endif /* MACH_KERNEL_PRIVATE */ | |
67 | ||
68 | #endif /* _KERN_SYNC_SEMA_H_ */ |