FreeBSD/Linux Kernel Cross Reference
sys/ipc/ipc_thread.h
1 /*
2 * Mach Operating System
3 * Copyright (c) 1993,1991,1990,1989 Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the
9 * software, derivative works or modified versions, and any portions
10 * thereof, and that both notices appear in supporting documentation.
11 *
12 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15 *
16 * Carnegie Mellon requests users of this software to return to
17 *
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
22 *
23 * any improvements or extensions that they make and grant Carnegie Mellon
24 * the rights to redistribute these changes.
25 */
26 /*
27 * HISTORY
28 * $Log: ipc_thread.h,v $
29 * Revision 2.5 93/11/17 17:03:13 dbg
30 * Remove ith_lock in favor of thread_lock.
31 * [93/07/12 dbg]
32 *
33 * Revision 2.4 91/05/14 16:38:20 mrt
34 * Correcting copyright
35 *
36 * Revision 2.3 91/02/05 17:24:26 mrt
37 * Changed to new Mach copyright
38 * [91/02/01 15:52:42 mrt]
39 *
40 * Revision 2.2 90/06/02 14:52:10 rpd
41 * Created for new IPC.
42 * [90/03/26 21:05:03 rpd]
43 *
44 */
45 /*
46 * File: ipc/ipc_thread.h
47 * Author: Rich Draves
48 * Date: 1989
49 *
50 * Definitions for the IPC component of threads.
51 */
52
53 #ifndef _IPC_IPC_THREAD_H_
54 #define _IPC_IPC_THREAD_H_
55
56 #include <kern/thread.h>
57
58 typedef thread_t ipc_thread_t;
59
60 #define ITH_NULL THREAD_NULL
61
62 typedef struct ipc_thread_queue {
63 ipc_thread_t ithq_base;
64 } *ipc_thread_queue_t;
65
66 #define ITHQ_NULL ((ipc_thread_queue_t) 0)
67
68
69 #define ipc_thread_links_init(thread) \
70 MACRO_BEGIN \
71 (thread)->ith_next = (thread); \
72 (thread)->ith_prev = (thread); \
73 MACRO_END
74
75 #define ipc_thread_queue_init(queue) \
76 MACRO_BEGIN \
77 (queue)->ithq_base = ITH_NULL; \
78 MACRO_END
79
80 #define ipc_thread_queue_empty(queue) ((queue)->ithq_base == ITH_NULL)
81
82 #define ipc_thread_queue_first(queue) ((queue)->ithq_base)
83
84 #define ipc_thread_rmqueue_first_macro(queue, thread) \
85 MACRO_BEGIN \
86 register ipc_thread_t _next; \
87 \
88 assert((queue)->ithq_base == (thread)); \
89 \
90 _next = (thread)->ith_next; \
91 if (_next == (thread)) { \
92 assert((thread)->ith_prev == (thread)); \
93 (queue)->ithq_base = ITH_NULL; \
94 } else { \
95 register ipc_thread_t _prev = (thread)->ith_prev; \
96 \
97 (queue)->ithq_base = _next; \
98 _next->ith_prev = _prev; \
99 _prev->ith_next = _next; \
100 ipc_thread_links_init(thread); \
101 } \
102 MACRO_END
103
104 #define ipc_thread_enqueue_macro(queue, thread) \
105 MACRO_BEGIN \
106 register ipc_thread_t _first = (queue)->ithq_base; \
107 \
108 if (_first == ITH_NULL) { \
109 (queue)->ithq_base = (thread); \
110 assert((thread)->ith_next == (thread)); \
111 assert((thread)->ith_prev == (thread)); \
112 } else { \
113 register ipc_thread_t _last = _first->ith_prev; \
114 \
115 (thread)->ith_next = _first; \
116 (thread)->ith_prev = _last; \
117 _first->ith_prev = (thread); \
118 _last->ith_next = (thread); \
119 } \
120 MACRO_END
121
122 extern void
123 ipc_thread_enqueue(ipc_thread_queue_t, ipc_thread_t);
124
125 extern ipc_thread_t
126 ipc_thread_dequeue(ipc_thread_queue_t);
127
128 extern void
129 ipc_thread_rmqueue(ipc_thread_queue_t, ipc_thread_t);
130
131 #endif /* _IPC_IPC_THREAD_H_ */
Cache object: 0a80c436761144229cd80246eeec1f30
|