|
|
1.1 root 1: /*
2: * Copyright (c) 1993,1994 The University of Utah and
3: * the Computer Systems Laboratory (CSL). All rights reserved.
4: *
5: * Permission to use, copy, modify and distribute this software and its
6: * documentation is hereby granted, provided that both the copyright
7: * notice and this permission notice appear in all copies of the
8: * software, derivative works or modified versions, and any portions
9: * thereof, and that both notices appear in supporting documentation.
10: *
11: * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS
12: * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF
13: * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
14: *
15: * CSL requests users of this software to return to [email protected] any
16: * improvements that they make and grant CSL redistribution rights.
17: *
18: * Author: Bryan Ford, University of Utah CSL
19: */
20: /*
21: * File: act.h
22: *
23: * This defines the Act structure,
24: * which is the kernel representation of a user-space activation.
25: *
26: */
27:
28: #ifndef _KERN_ACT_H_
29: #define _KERN_ACT_H_
30:
31: #ifdef MIGRATING_THREADS
32:
33: #ifndef __dead /* XXX */
34: #define __dead
35: #endif
36:
37: #include <mach/vm_param.h>
38: #include <mach/port.h>
39: #include <kern/lock.h>
40: #include <kern/refcount.h>
41: #include <kern/queue.h>
42:
43: #include "act.h"/*XXX*/
44:
45: struct task;
46: struct thread;
47: struct Act;
48:
49:
50: struct ReturnHandler {
51: struct ReturnHandler *next;
52: void (*handler)(struct ReturnHandler *rh, struct Act *act);
53: };
54: typedef struct ReturnHandler ReturnHandler;
55:
56:
57:
58: struct Act {
59:
60: /*** Task linkage ***/
61:
62: /* Links for task's circular list of activations.
63: The activation is only on the task's activation list while active.
64: Must be first. */
65: queue_chain_t task_links;
66:
67: /* Reference to the task this activation is in.
68: This is constant as long as the activation is allocated. */
69: struct task *task;
70:
71:
72:
73: /*** Machine-dependent state ***/
74: /* XXX should be first to allow maximum flexibility to MD code */
75: MachineAct mact;
76:
77:
78:
79: /*** Consistency ***/
80: RefCount ref_count;
81: decl_simple_lock_data(,lock)
82:
83:
84:
85: /*** ipc_target-related stuff ***/
86:
87: /* ActPool this activation normally lives on, zero if none.
88: The activation and actpool hold references to each other as long as this is nonzero
89: (even when the activation isn't actually on the actpool's list). */
90: struct ipc_target *ipt;
91:
92: /* Link on the ipt's list of activations.
93: The activation is only actually on the ipt's list (and hence this is valid)
94: when we're not in use (thread == 0) and not suspended (suspend_count == 0). */
95: struct Act *ipt_next;
96:
97:
98:
99: /*** Thread linkage ***/
100:
101: /* Thread this activation is in, zero if not in use.
102: The thread holds a reference on the activation while this is nonzero. */
103: struct thread *thread;
104:
105: /* The rest in this section is only valid when thread is nonzero. */
106:
107: /* Next higher and next lower activation on the thread's activation stack.
108: For a topmost activation or the null_act, higher is undefined.
109: The bottommost activation is always the null_act. */
110: struct Act *higher, *lower;
111:
112: /* Alert bits pending at this activation;
113: some of them may have propagated from lower activations. */
114: unsigned alerts;
115:
116: /* Mask of alert bits to be allowed to pass through from lower levels. */
117: unsigned alert_mask;
118:
119:
120:
121: /*** Control information ***/
122:
123: /* Number of outstanding suspensions on this activation. */
124: int suspend_count;
125:
126: /* This is normally true, but is set to false when the activation is terminated. */
127: int active;
128:
129: /* Chain of return handlers to be called
130: before the thread is allowed to return to this invocation */
131: ReturnHandler *handlers;
132:
133: /* A special ReturnHandler attached to the above chain to handle suspension and such */
134: ReturnHandler special_handler;
135:
136:
137:
138: /* Special ports attached to this activation */
139: struct ipc_port *self; /* not a right, doesn't hold ref */
140: struct ipc_port *self_port; /* a send right */
141: struct ipc_port *exception_port; /* a send right */
142: struct ipc_port *syscall_port; /* a send right */
143: };
144: typedef struct Act Act;
145: typedef struct Act *act_t;
146: typedef mach_port_t *act_array_t;
147:
148: #define ACT_NULL ((Act*)0)
149:
150:
151: /* Exported to world */
152: kern_return_t act_create(struct task *task, vm_offset_t user_stack, vm_offset_t user_rbuf, vm_size_t user_rbuf_size, struct Act **new_act);
153: kern_return_t act_alert_mask(struct Act *act, unsigned alert_mask);
154: kern_return_t act_alert(struct Act *act, unsigned alerts);
155: kern_return_t act_abort(struct Act *act);
156: kern_return_t act_abort_safely(struct Act *act);
157: kern_return_t act_terminate(struct Act *act);
158: kern_return_t act_suspend(struct Act *act);
159: kern_return_t act_resume(struct Act *act);
160: kern_return_t act_get_state(struct Act *act, int flavor,
161: natural_t *state, natural_t *pcount);
162: kern_return_t act_set_state(struct Act *act, int flavor,
163: natural_t *state, natural_t count);
164:
165: #define act_lock(act) simple_lock(&(act)->lock)
166: #define act_unlock(act) simple_unlock(&(act)->lock)
167:
168: #define act_reference(act) refcount_take(&(act)->ref_count)
169: void act_deallocate(struct Act *act);
170:
171: /* Exported to startup.c */
172: void act_init(void);
173:
174: /* Exported to task.c */
175: kern_return_t act_terminate_task_locked(struct Act *act);
176:
177: /* Exported to thread.c */
178: extern Act null_act;
179: kern_return_t act_create_kernel(Act **out_act);
180:
181: /* Exported to machine-dependent activation code */
182: void act_execute_returnhandlers(void);
183:
184:
185:
186: /* System-dependent functions */
187: kern_return_t act_machine_create(struct task *task, Act *inc, vm_offset_t user_stack, vm_offset_t user_rbuf, vm_size_t user_rbuf_size);
188: void act_machine_destroy(Act *inc);
189: kern_return_t act_machine_set_state(Act *inc, int flavor, int *tstate, unsigned count);
190: kern_return_t act_machine_get_state(Act *inc, int flavor, int *tstate, unsigned *count);
191:
192:
193:
194: #endif /* MIGRATING_THREADS */
195: #endif _KERN_ACT_H_
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.