|
|
1.1 root 1: /*
2: * Mach Operating System
3: * Copyright (c) 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 [email protected]
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: */
28: /*
29: * File: ipc/ipc_thread.h
30: * Author: Rich Draves
31: * Date: 1989
32: *
33: * Definitions for the IPC component of threads.
34: */
35:
36: #ifndef _IPC_IPC_THREAD_H_
37: #define _IPC_IPC_THREAD_H_
38:
39: #include <kern/thread.h>
40:
41: typedef thread_t ipc_thread_t;
42:
43: #define ITH_NULL THREAD_NULL
44:
45: #define ith_lock_init(thread) simple_lock_init(&(thread)->ith_lock_data)
46: #define ith_lock(thread) simple_lock(&(thread)->ith_lock_data)
47: #define ith_unlock(thread) simple_unlock(&(thread)->ith_lock_data)
48:
49: typedef struct ipc_thread_queue {
50: ipc_thread_t ithq_base;
51: } *ipc_thread_queue_t;
52:
53: #define ITHQ_NULL ((ipc_thread_queue_t) 0)
54:
55:
56: #define ipc_thread_links_init(thread) \
57: MACRO_BEGIN \
58: (thread)->ith_next = (thread); \
59: (thread)->ith_prev = (thread); \
60: MACRO_END
61:
62: #define ipc_thread_queue_init(queue) \
63: MACRO_BEGIN \
64: (queue)->ithq_base = ITH_NULL; \
65: MACRO_END
66:
67: #define ipc_thread_queue_empty(queue) ((queue)->ithq_base == ITH_NULL)
68:
69: #define ipc_thread_queue_first(queue) ((queue)->ithq_base)
70:
71: #define ipc_thread_rmqueue_first_macro(queue, thread) \
72: MACRO_BEGIN \
73: register ipc_thread_t _next; \
74: \
75: assert((queue)->ithq_base == (thread)); \
76: \
77: _next = (thread)->ith_next; \
78: if (_next == (thread)) { \
79: assert((thread)->ith_prev == (thread)); \
80: (queue)->ithq_base = ITH_NULL; \
81: } else { \
82: register ipc_thread_t _prev = (thread)->ith_prev; \
83: \
84: (queue)->ithq_base = _next; \
85: _next->ith_prev = _prev; \
86: _prev->ith_next = _next; \
87: ipc_thread_links_init(thread); \
88: } \
89: MACRO_END
90:
91: #define ipc_thread_enqueue_macro(queue, thread) \
92: MACRO_BEGIN \
93: register ipc_thread_t _first = (queue)->ithq_base; \
94: \
95: if (_first == ITH_NULL) { \
96: (queue)->ithq_base = (thread); \
97: assert((thread)->ith_next == (thread)); \
98: assert((thread)->ith_prev == (thread)); \
99: } else { \
100: register ipc_thread_t _last = _first->ith_prev; \
101: \
102: (thread)->ith_next = _first; \
103: (thread)->ith_prev = _last; \
104: _first->ith_prev = (thread); \
105: _last->ith_next = (thread); \
106: } \
107: MACRO_END
108:
109: /* Enqueue a thread on a message queue */
110: extern void ipc_thread_enqueue(
111: ipc_thread_queue_t queue,
112: ipc_thread_t thread);
113:
114: /* Dequeue a thread from a message queue */
115: extern ipc_thread_t ipc_thread_dequeue(
116: ipc_thread_queue_t queue);
117:
118: /* Remove a thread from a message queue */
119: extern void ipc_thread_rmqueue(
120: ipc_thread_queue_t queue,
121: ipc_thread_t thread);
122:
123: #endif /* _IPC_IPC_THREAD_H_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.