|
|
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: struct task;
44: struct thread;
45: struct Act;
46:
47:
48: struct ReturnHandler {
49: struct ReturnHandler *next;
50: void (*handler)(struct ReturnHandler *rh, struct Act *act);
51: };
52: typedef struct ReturnHandler ReturnHandler;
53:
54:
55:
56: struct Act {
57:
58: /*** Task linkage ***/
59:
60: /* Links for task's circular list of activations.
61: The activation is only on the task's activation list while active.
62: Must be first. */
63: queue_chain_t task_links;
64:
65: /* Reference to the task this activation is in.
66: This is constant as long as the activation is allocated. */
67: struct task *task;
68:
69:
70:
71: /*** Machine-dependent state ***/
72: /* XXX should be first to allow maximum flexibility to MD code */
73: MachineAct mact;
74:
75:
76:
77: /*** Consistency ***/
78: RefCount ref_count;
79: decl_simple_lock_data(,lock)
80:
81:
82:
83: /*** ipc_target-related stuff ***/
84:
85: /* ActPool this activation normally lives on, zero if none.
86: The activation and actpool hold references to each other as long as this is nonzero
87: (even when the activation isn't actually on the actpool's list). */
88: struct ipc_target *ipt;
89:
90: /* Link on the ipt's list of activations.
91: The activation is only actually on the ipt's list (and hence this is valid)
92: when we're not in use (thread == 0) and not suspended (suspend_count == 0). */
93: struct Act *ipt_next;
94:
95:
96:
97: /*** Thread linkage ***/
98:
99: /* Thread this activation is in, zero if not in use.
100: The thread holds a reference on the activation while this is nonzero. */
101: struct thread *thread;
102:
103: /* The rest in this section is only valid when thread is nonzero. */
104:
105: /* Next higher and next lower activation on the thread's activation stack.
106: For a topmost activation or the null_act, higher is undefined.
107: The bottommost activation is always the null_act. */
108: struct Act *higher, *lower;
109:
110: /* Alert bits pending at this activation;
111: some of them may have propagated from lower activations. */
112: unsigned alerts;
113:
114: /* Mask of alert bits to be allowed to pass through from lower levels. */
115: unsigned alert_mask;
116:
117:
118:
119: /*** Control information ***/
120:
121: /* Number of outstanding suspensions on this activation. */
122: int suspend_count;
123:
124: /* This is normally true, but is set to false when the activation is terminated. */
125: int active;
126:
127: /* Chain of return handlers to be called
128: before the thread is allowed to return to this invocation */
129: ReturnHandler *handlers;
130:
131: /* A special ReturnHandler attached to the above chain to handle suspension and such */
132: ReturnHandler special_handler;
133:
134:
135:
136: /* Special ports attached to this activation */
137: struct ipc_port *self; /* not a right, doesn't hold ref */
138: struct ipc_port *self_port; /* a send right */
139: struct ipc_port *exception_port; /* a send right */
140: struct ipc_port *syscall_port; /* a send right */
141: };
142: typedef struct Act Act;
143: typedef struct Act *act_t;
144: typedef mach_port_t *act_array_t;
145:
146: #define ACT_NULL ((Act*)0)
147:
148:
149: /* Exported to world */
150: 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);
151: kern_return_t act_alert_mask(struct Act *act, unsigned alert_mask);
152: kern_return_t act_alert(struct Act *act, unsigned alerts);
153: kern_return_t act_abort(struct Act *act);
154: kern_return_t act_abort_safely(struct Act *act);
155: kern_return_t act_terminate(struct Act *act);
156: kern_return_t act_suspend(struct Act *act);
157: kern_return_t act_resume(struct Act *act);
158: kern_return_t act_get_state(struct Act *act, int flavor,
159: natural_t *state, natural_t *pcount);
160: kern_return_t act_set_state(struct Act *act, int flavor,
161: natural_t *state, natural_t count);
162:
163: #define act_lock(act) simple_lock(&(act)->lock)
164: #define act_unlock(act) simple_unlock(&(act)->lock)
165:
166: #define act_reference(act) refcount_take(&(act)->ref_count)
167: void act_deallocate(struct Act *act);
168:
169: /* Exported to startup.c */
170: void act_init(void);
171:
172: /* Exported to task.c */
173: kern_return_t act_terminate_task_locked(struct Act *act);
174:
175: /* Exported to thread.c */
176: extern Act null_act;
177:
178: /* Exported to machine-dependent activation code */
179: void act_execute_returnhandlers(void);
180:
181:
182:
183: /* System-dependent functions */
184: 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);
185: void act_machine_destroy(Act *inc);
186: kern_return_t act_machine_set_state(Act *inc, int flavor, int *tstate, unsigned count);
187: kern_return_t act_machine_get_state(Act *inc, int flavor, int *tstate, unsigned *count);
188:
189:
190:
191: #endif /* MIGRATING_THREADS */
1.1.1.3 ! root 192: #endif /* _KERN_ACT_H_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.