|
|
1.1 root 1: /*
2: * Mach Operating System
3: * Copyright (c) 1991,1990,1989 Carnegie Mellon University.
4: * Copyright (c) 1993,1994 The University of Utah and
5: * the Computer Systems Laboratory (CSL).
6: * All rights reserved.
7: *
8: * Permission to use, copy, modify and distribute this software and its
9: * documentation is hereby granted, provided that both the copyright
10: * notice and this permission notice appear in all copies of the
11: * software, derivative works or modified versions, and any portions
12: * thereof, and that both notices appear in supporting documentation.
13: *
14: * CARNEGIE MELLON, THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF
15: * THIS SOFTWARE IN ITS "AS IS" CONDITION, AND DISCLAIM ANY LIABILITY
16: * OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF
17: * THIS SOFTWARE.
18: *
19: * Carnegie Mellon requests users of this software to return to
20: *
21: * Software Distribution Coordinator or [email protected]
22: * School of Computer Science
23: * Carnegie Mellon University
24: * Pittsburgh PA 15213-3890
25: *
26: * any improvements or extensions that they make and grant Carnegie Mellon
27: * the rights to redistribute these changes.
28: */
29: /*
30: * kern/ast.h: Definitions for Asynchronous System Traps.
31: */
32:
33: #ifndef _KERN_AST_H_
34: #define _KERN_AST_H_
35:
36: /*
37: * A CPU takes an AST when it is about to return to user code.
38: * Instead of going back to user code, it calls ast_taken.
39: * Machine-dependent code is responsible for maintaining
40: * a set of reasons for an AST, and passing this set to ast_taken.
41: */
42:
43: #include <cpus.h>
44:
45: #include "cpu_number.h"
46: #include <kern/macro_help.h>
47: #include <machine/ast.h>
48:
49: /*
50: * Bits for reasons
51: */
52:
53: #define AST_ZILCH 0x0
54: #define AST_HALT 0x1
55: #define AST_TERMINATE 0x2
56: #define AST_BLOCK 0x4
57: #define AST_NETWORK 0x8
58: #define AST_NETIPC 0x10
59:
60: #define AST_SCHEDULING (AST_HALT|AST_TERMINATE|AST_BLOCK)
61:
62: /*
63: * Per-thread ASTs are reset at context-switch time.
64: * machine/ast.h can define MACHINE_AST_PER_THREAD.
65: */
66:
67: #ifndef MACHINE_AST_PER_THREAD
68: #define MACHINE_AST_PER_THREAD 0
69: #endif
70:
71: #define AST_PER_THREAD (AST_HALT | AST_TERMINATE | MACHINE_AST_PER_THREAD)
72:
73: typedef unsigned int ast_t;
74:
75: extern volatile ast_t need_ast[NCPUS];
76:
77: #ifdef MACHINE_AST
78: /*
79: * machine/ast.h is responsible for defining aston and astoff.
80: */
81: #else /* MACHINE_AST */
82:
83: #define aston(mycpu)
84: #define astoff(mycpu)
85:
86: #endif /* MACHINE_AST */
87:
88: extern void ast_taken();
89:
90: /*
91: * ast_needed, ast_on, ast_off, ast_context, and ast_propagate
92: * assume splsched. mycpu is always cpu_number(). It is an
93: * argument in case cpu_number() is expensive.
94: */
95:
96: #define ast_needed(mycpu) need_ast[mycpu]
97:
98: #define ast_on(mycpu, reasons) \
99: MACRO_BEGIN \
100: if ((need_ast[mycpu] |= (reasons)) != AST_ZILCH) \
101: { aston(mycpu); } \
102: MACRO_END
103:
104: #define ast_off(mycpu, reasons) \
105: MACRO_BEGIN \
106: if ((need_ast[mycpu] &= ~(reasons)) == AST_ZILCH) \
107: { astoff(mycpu); } \
108: MACRO_END
109:
110: #define ast_propagate(thread, mycpu) ast_on((mycpu), (thread)->ast)
111:
112: #define ast_context(thread, mycpu) \
113: MACRO_BEGIN \
114: if ((need_ast[mycpu] = \
115: (need_ast[mycpu] &~ AST_PER_THREAD) | (thread)->ast) \
116: != AST_ZILCH) \
117: { aston(mycpu); } \
118: else \
119: { astoff(mycpu); } \
120: MACRO_END
121:
122:
123: #define thread_ast_set(thread, reason) (thread)->ast |= (reason)
124: #define thread_ast_clear(thread, reason) (thread)->ast &= ~(reason)
125: #define thread_ast_clear_all(thread) (thread)->ast = AST_ZILCH
126:
127: /*
128: * NOTE: if thread is the current thread, thread_ast_set should
129: * be followed by ast_propagate().
130: */
131:
132: #endif /* _KERN_AST_H_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.