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