|
|
1.1 root 1: /*
2: * Mach Operating System
3: * Copyright (c) 1993-1988 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: * File: task.h
28: * Author: Avadis Tevanian, Jr.
29: *
30: * This file contains the structure definitions for tasks.
31: *
32: */
33:
34: #ifndef _KERN_TASK_H_
35: #define _KERN_TASK_H_
36:
37: #include <norma_task.h>
38: #include <fast_tas.h>
39: #include <net_atm.h>
40:
41: #include <mach/boolean.h>
42: #include <mach/port.h>
43: #include <mach/time_value.h>
44: #include <mach/mach_param.h>
45: #include <mach/task_info.h>
46: #include <kern/kern_types.h>
47: #include <kern/lock.h>
48: #include <kern/queue.h>
49: #include <kern/pc_sample.h>
50: #include <kern/processor.h>
51: #include <kern/syscall_emulation.h>
52: #include <vm/vm_map.h>
53:
54: #if NET_ATM
55: typedef struct nw_ep_owned {
56: unsigned int ep;
57: struct nw_ep_owned *next;
58: } nw_ep_owned_s, *nw_ep_owned_t;
59: #endif
60:
61: struct task {
62: /* Synchronization/destruction information */
63: decl_simple_lock_data(,lock) /* Task's lock */
64: int ref_count; /* Number of references to me */
65: boolean_t active; /* Task has not been terminated */
66:
67: /* Miscellaneous */
68: vm_map_t map; /* Address space description */
69: queue_chain_t pset_tasks; /* list of tasks assigned to pset */
70: int suspend_count; /* Internal scheduling only */
71:
72: /* Thread information */
73: queue_head_t thread_list; /* list of threads */
74: int thread_count; /* number of threads */
75: processor_set_t processor_set; /* processor set for new threads */
76: boolean_t may_assign; /* can assigned pset be changed? */
77: boolean_t assign_active; /* waiting for may_assign */
78:
79: /* User-visible scheduling information */
80: int user_stop_count; /* outstanding stops */
81: int priority; /* for new threads */
82:
83: /* Statistics */
84: time_value_t total_user_time;
85: /* total user time for dead threads */
86: time_value_t total_system_time;
87: /* total system time for dead threads */
88:
89: /* IPC structures */
90: decl_simple_lock_data(, itk_lock_data)
91: struct ipc_port *itk_self; /* not a right, doesn't hold ref */
92: struct ipc_port *itk_sself; /* a send right */
93: struct ipc_port *itk_exception; /* a send right */
94: struct ipc_port *itk_bootstrap; /* a send right */
95: struct ipc_port *itk_registered[TASK_PORT_REGISTER_MAX];
96: /* all send rights */
97:
98: struct ipc_space *itk_space;
99:
100: /* User space system call emulation support */
101: struct eml_dispatch *eml_dispatch;
102:
103: sample_control_t pc_sample;
104:
105: #if NORMA_TASK
106: long child_node; /* if != -1, node for new children */
107: #endif /* NORMA_TASK */
108:
109: #if FAST_TAS
110: #define TASK_FAST_TAS_NRAS 8
111: vm_offset_t fast_tas_base[TASK_FAST_TAS_NRAS];
112: vm_offset_t fast_tas_end[TASK_FAST_TAS_NRAS];
113: #endif /* FAST_TAS */
114:
115: #if NET_ATM
116: nw_ep_owned_t nw_ep_owned;
117: #endif /* NET_ATM */
118: };
119:
120: #define task_lock(task) simple_lock(&(task)->lock)
121: #define task_unlock(task) simple_unlock(&(task)->lock)
122:
123: #define itk_lock_init(task) simple_lock_init(&(task)->itk_lock_data)
124: #define itk_lock(task) simple_lock(&(task)->itk_lock_data)
125: #define itk_unlock(task) simple_unlock(&(task)->itk_lock_data)
126:
127: /*
128: * Exported routines/macros
129: */
130:
131: extern kern_return_t task_create(
132: task_t parent_task,
133: boolean_t inherit_memory,
134: task_t *child_task);
135: extern kern_return_t task_terminate(
136: task_t task);
137: extern kern_return_t task_suspend(
138: task_t task);
139: extern kern_return_t task_resume(
140: task_t task);
141: extern kern_return_t task_threads(
142: task_t task,
143: thread_array_t *thread_list,
144: natural_t *count);
145: extern kern_return_t task_info(
146: task_t task,
147: int flavor,
148: task_info_t task_info_out,
149: natural_t *task_info_count);
150: extern kern_return_t task_get_special_port(
151: task_t task,
152: int which,
153: struct ipc_port **portp);
154: extern kern_return_t task_set_special_port(
155: task_t task,
156: int which,
157: struct ipc_port *port);
158: extern kern_return_t task_assign(
159: task_t task,
160: processor_set_t new_pset,
161: boolean_t assign_threads);
162: extern kern_return_t task_assign_default(
163: task_t task,
164: boolean_t assign_threads);
165:
166: /*
167: * Internal only routines
168: */
169:
170: extern void task_init();
171: extern void task_reference();
172: extern void task_deallocate();
173: extern kern_return_t task_hold();
174: extern kern_return_t task_dowait();
175: extern kern_return_t task_release();
176: extern kern_return_t task_halt();
177:
178: extern kern_return_t task_suspend_nowait();
179: extern task_t kernel_task_create();
180:
181: extern task_t kernel_task;
182:
183: #endif _KERN_TASK_H_
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.