2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
26 * Mach Operating System
27 * Copyright (c) 1989 Carnegie-Mellon University
28 * Copyright (c) 1988 Carnegie-Mellon University
29 * Copyright (c) 1987 Carnegie-Mellon University
30 * All rights reserved. The CMU software License Agreement specifies
31 * the terms and conditions for use and redistribution.
36 * Revision 1.1.1.1 1998/09/22 21:05:32 wsanchez
37 * Import of Mac OS X kernel (~semeria)
39 * Revision 1.1.1.1 1998/03/07 02:25:57 wsanchez
40 * Import of OSF Mach kernel (~mburg)
42 * Revision 1.1.11.7 1995/06/13 18:58:49 bolinger
43 * Fix ri-osc CR1391: New return type from thread_swapin_blocking().
44 * [1995/06/13 18:56:52 bolinger]
46 * Revision 1.1.11.6 1995/06/05 21:46:36 dwm
47 * ri-osc CR1357 - ensure activation being returned to is swapped in.
48 * added thread_swapin_blocking [bolinger]
49 * [1995/06/05 21:34:08 dwm]
51 * Revision 1.1.11.5 1995/05/19 15:48:34 bernadat
52 * Let thread swapping be configurable.
55 * Revision 1.1.11.4 1995/04/07 19:04:46 barbou
56 * Merged into mainline.
59 * Revision 1.1.12.2 1995/02/13 15:59:18 barbou
60 * Merged/ported to MK6.
62 * Revision 1.1.9.3 1994/08/12 14:22:30 barbou
63 * Overwritten with copy from IK.
64 * Old kern/thread_swap.h was renamed kern/thread_handoff.c.
65 * Added prototype for thread_swapout and thread_swapout_enqueue.
68 * Revision 3.0.3.2 1994/01/20 19:53:20 chasb
69 * Remove excessively restrictive copyright notice
70 * [1994/01/20 17:50:56 chasb]
72 * Revision 3.0.3.1 1993/12/20 21:07:59 gupta
73 * Expanded C O P Y R I G H T
74 * [1993/12/17 22:19:43 gupta]
76 * Revision 3.0 1992/12/31 22:08:45 ede
77 * Initial revision for OSF/1 R1.3
79 * Revision 1.6.2.2 1992/01/22 22:14:42 gmf
80 * Added TH_SW_TASK_SWAPPING flag to swap_state. This state
81 * indicates that the thread is about to be swapped out by
82 * the task swapping mechanism, and prevents the thread
83 * swapper from doing it first.
84 * [1992/01/20 22:06:36 gmf]
86 * Revision 1.6 1991/08/15 19:16:39 devrcs
87 * Prototype all functions, change name to thread_swapper_init.
88 * [91/06/26 10:45:44 jeffc]
90 * Revision 1.5 91/06/10 16:19:07 devrcs
91 * Additions to allow thread to be made non-swappable on swap in,
92 * change thread_swapin interface.
93 * [91/05/30 15:56:38 jeffc]
95 * Revision 1.4 91/03/04 17:07:14 devrcs
96 * A small step toward ansiC: commented else/endif/elif trailers.
97 * [91/01/12 16:39:43 dwm]
99 * Revision 1.3 90/10/07 13:57:13 devrcs
100 * Added EndLog Marker.
101 * [90/09/28 09:59:56 gm]
103 * Revision 1.2 90/01/02 20:06:28 gm
104 * Fixes for first snapshot.
106 * Revision 1.1 89/10/16 19:36:28 gm
107 * Mach 2.5 and Encore 0.6 merge
109 * Revision 2.4 89/03/09 20:17:07 rpd
112 * Revision 2.3 89/02/25 18:10:24 gm0w
113 * Kernel code cleanup.
114 * Put entire file under #indef KERNEL.
117 * Revision 0.0 88/01/21 dbg
124 * File: kern/thread_swap.h
126 * Declarations of thread swap_states and swapping routines.
130 * Swap states for threads.
133 #ifndef _KERN_THREAD_SWAP_H_
134 #define _KERN_THREAD_SWAP_H_
136 #if 1 /* USED CODE */
142 extern void swapper_init();
143 extern void thread_swapin(thread_t thread
);
144 extern void thread_doswapin(thread_t thread
);
145 extern void swapin_thread();
147 #define thread_swappable(act, bool)
150 #else /* UNUSED SWAPPER CODE */
152 #define TH_SW_STATE 7 /* mask of swap state bits */
153 #define TH_SW_UNSWAPPABLE 1 /* not swappable */
154 #define TH_SW_IN 2 /* swapped in */
155 #define TH_SW_GOING_OUT 3 /* being swapped out */
156 #define TH_SW_WANT_IN 4 /* being swapped out, but should
157 immediately be swapped in */
158 #define TH_SW_OUT 5 /* swapped out */
159 #define TH_SW_COMING_IN 6 /* queued for swapin, or being
162 #define TH_SW_MAKE_UNSWAPPABLE 8 /*not state, command to swapin_thread */
165 * This flag is only used by the task swapper. It implies that
166 * the thread is about to be swapped, but hasn't yet.
168 #define TH_SW_TASK_SWAPPING 0x10
173 extern void thread_swapper_init(void);
174 extern void swapin_thread(void);
175 extern void swapout_thread(void);
176 extern void thread_doswapin(thread_act_t thr_act
);
177 extern void thread_swapin(thread_act_t thr_act
,
178 boolean_t make_unswappable
);
180 thread_swapin_blocking(thread_act_t thr_act
);
181 extern void thread_swapout(thread_act_t thr_act
);
182 extern void swapout_threads(boolean_t now
);
183 extern void thread_swapout_enqueue(thread_act_t thr_act
);
184 extern void thread_swap_disable(thread_act_t thr_act
);
186 extern void thread_swappable(thread_act_t thr_act
, boolean_t swappable
);
188 #else /* THREAD_SWAPPER */
189 #define thread_swappable(thr_act, swappable)
190 #endif /* THREAD_SWAPPER */
192 #endif /* UNUSED SWAPPER CODE */
194 #endif /*_KERN_THREAD_SWAP_H_*/