1 /* 2 * Copyright 1991-1998 by Open Software Foundation, Inc. 3 * All Rights Reserved 4 * 5 * Permission to use, copy, modify, and distribute this software and 6 * its documentation for any purpose and without fee is hereby granted, 7 * provided that the above copyright notice appears in all copies and 8 * that both the copyright notice and this permission notice appear in 9 * supporting documentation. 10 * 11 * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 12 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 13 * FOR A PARTICULAR PURPOSE. 14 * 15 * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR 16 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 17 * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, 18 * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 19 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 20 */ 21 /* 22 * MkLinux 23 */ 24 /* CMU_HIST */ 25 /* 26 * Revision 2.4 91/05/14 16:38:20 mrt 27 * Correcting copyright 28 * 29 * Revision 2.3 91/02/05 17:24:26 mrt 30 * Changed to new Mach copyright 31 * [91/02/01 15:52:42 mrt] 32 * 33 * Revision 2.2 90/06/02 14:52:10 rpd 34 * Created for new IPC. 35 * [90/03/26 21:05:03 rpd] 36 * 37 */ 38 /* CMU_ENDHIST */ 39 /* 40 * Mach Operating System 41 * Copyright (c) 1991,1990,1989 Carnegie Mellon University 42 * All Rights Reserved. 43 * 44 * Permission to use, copy, modify and distribute this software and its 45 * documentation is hereby granted, provided that both the copyright 46 * notice and this permission notice appear in all copies of the 47 * software, derivative works or modified versions, and any portions 48 * thereof, and that both notices appear in supporting documentation. 49 * 50 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 51 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 52 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 53 * 54 * Carnegie Mellon requests users of this software to return to 55 * 56 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 57 * School of Computer Science 58 * Carnegie Mellon University 59 * Pittsburgh PA 15213-3890 60 * 61 * any improvements or extensions that they make and grant Carnegie Mellon 62 * the rights to redistribute these changes. 63 */ 64 /* 65 */ 66 /* 67 * File: ipc/ipc_thread.h 68 * Author: Rich Draves 69 * Date: 1989 70 * 71 * Definitions for the IPC component of threads. 72 */ 73 74 #ifndef _IPC_IPC_THREAD_H_ 75 #define _IPC_IPC_THREAD_H_ 76 #include <sys/cdefs.h> 77 #include <sys/types.h> 78 #include <sys/param.h> 79 #include <sys/proc.h> 80 81 typedef struct timer_elt timer_elt_data_t; 82 83 typedef thread_t ipc_thread_t; 84 85 #define counter(x) 86 87 88 #define ITH_NULL THREAD_NULL 89 90 typedef struct ipc_thread_queue { 91 ipc_thread_t ithq_base; 92 } *ipc_thread_queue_t; 93 94 #define ITHQ_NULL ((ipc_thread_queue_t) 0) 95 96 97 #define ipc_thread_links_init(thread) \ 98 MACRO_BEGIN \ 99 (thread)->ith_next = (thread); \ 100 (thread)->ith_prev = (thread); \ 101 MACRO_END 102 103 #define ipc_thread_queue_init(queue) \ 104 MACRO_BEGIN \ 105 (queue)->ithq_base = ITH_NULL; \ 106 MACRO_END 107 108 #define ipc_thread_queue_empty(queue) ((queue)->ithq_base == ITH_NULL) 109 110 #define ipc_thread_queue_first(queue) ((queue)->ithq_base) 111 112 #define ipc_thread_rmqueue_first_macro(queue, thread) \ 113 MACRO_BEGIN \ 114 register ipc_thread_t _next; \ 115 \ 116 assert((queue)->ithq_base == (thread)); \ 117 \ 118 _next = (thread)->ith_next; \ 119 if (_next == (thread)) { \ 120 assert((thread)->ith_prev == (thread)); \ 121 (queue)->ithq_base = ITH_NULL; \ 122 } else { \ 123 register ipc_thread_t _prev = (thread)->ith_prev; \ 124 \ 125 (queue)->ithq_base = _next; \ 126 _next->ith_prev = _prev; \ 127 _prev->ith_next = _next; \ 128 ipc_thread_links_init(thread); \ 129 } \ 130 MACRO_END 131 132 #define ipc_thread_enqueue_macro(queue, thread) \ 133 MACRO_BEGIN \ 134 register ipc_thread_t _first = (queue)->ithq_base; \ 135 \ 136 if (_first == ITH_NULL) { \ 137 (queue)->ithq_base = (thread); \ 138 assert((thread)->ith_next == (thread)); \ 139 assert((thread)->ith_prev == (thread)); \ 140 } else { \ 141 register ipc_thread_t _last = _first->ith_prev; \ 142 \ 143 (thread)->ith_next = _first; \ 144 (thread)->ith_prev = _last; \ 145 _first->ith_prev = (thread); \ 146 _last->ith_next = (thread); \ 147 } \ 148 MACRO_END 149 150 /* Enqueue a thread on a message queue */ 151 extern void ipc_thread_enqueue( 152 ipc_thread_queue_t queue, 153 ipc_thread_t thread); 154 155 /* Dequeue a thread from a message queue */ 156 extern ipc_thread_t ipc_thread_dequeue( 157 ipc_thread_queue_t queue); 158 159 /* Remove a thread from a message queue */ 160 extern void ipc_thread_rmqueue( 161 ipc_thread_queue_t queue, 162 ipc_thread_t thread); 163 164 /* Check if a thread is on the queue */ 165 extern boolean_t ipc_thread_inqueue( 166 ipc_thread_queue_t queue, 167 ipc_thread_t thread); 168 169 #endif /* _IPC_IPC_THREAD_H_ */ 170