100 |
|
|
101 |
err = task_alloc (task_id, nr_threads, threads, &task); |
err = task_alloc (task_id, nr_threads, threads, &task); |
102 |
if (err) |
if (err) |
103 |
panic ("task_alloc: %i\n", err); |
panic ("task_alloc: %i", err); |
104 |
|
|
105 |
obj = hurd_cap_obj_from_user (task_t, task); |
obj = hurd_cap_obj_from_user (task_t, task); |
106 |
hurd_cap_obj_unlock (obj); |
hurd_cap_obj_unlock (obj); |
107 |
|
|
108 |
err = task_id_enter (task); |
err = task_id_enter (task); |
109 |
if (err) |
if (err) |
110 |
panic ("task_id_enter: %i\n", err); |
panic ("task_id_enter: %i", err); |
111 |
|
|
112 |
err = hurd_cap_bucket_inject (bucket, obj, task_id, &cap); |
err = hurd_cap_bucket_inject (bucket, obj, task_id, &cap); |
113 |
if (err) |
if (err) |
114 |
panic ("hurd_cap_bucket_inject: %i\n", err); |
panic ("hurd_cap_bucket_inject: %i", err); |
115 |
|
|
116 |
hurd_cap_obj_lock (obj); |
hurd_cap_obj_lock (obj); |
117 |
hurd_cap_obj_drop (obj); |
hurd_cap_obj_drop (obj); |
133 |
} |
} |
134 |
|
|
135 |
|
|
|
/* The first free thread number. */ |
|
|
l4_word_t first_free_thread_no; |
|
|
|
|
136 |
/* Initialize the thread support, and return the L4 thread ID to be |
/* Initialize the thread support, and return the L4 thread ID to be |
137 |
used for the server thread. */ |
used for the server thread. */ |
138 |
static l4_thread_id_t |
static l4_thread_id_t |
139 |
setup_threads (void) |
setup_threads (void) |
140 |
{ |
{ |
141 |
l4_word_t err; |
l4_word_t err; |
142 |
|
l4_word_t first_free_thread_no; |
143 |
pthread_t thread; |
pthread_t thread; |
144 |
l4_thread_id_t server_thread; |
l4_thread_id_t server_thread; |
145 |
l4_thread_id_t main_thread; |
l4_thread_id_t main_thread; |
172 |
err = pthread_create (&thread, 0, 0, 0); |
err = pthread_create (&thread, 0, 0, 0); |
173 |
|
|
174 |
if (err) |
if (err) |
175 |
panic ("could not create main thread: %i\n", err); |
panic ("could not create main thread: %i", err); |
176 |
|
|
177 |
/* FIXME: This is unecessary as soon as we implement this properly |
/* FIXME: This is unecessary as soon as we implement this properly |
178 |
in pthread (of course, within the task server, we will use an |
in pthread (of course, within the task server, we will use an |
195 |
+ 3 * l4_utcb_size ())); |
+ 3 * l4_utcb_size ())); |
196 |
pthread_pool_add_np (extra_thread); |
pthread_pool_add_np (extra_thread); |
197 |
|
|
198 |
|
/* FIXME: Look up the real limits on the KIP, or get them from wortel. */ |
199 |
|
thread_set_range (l4_global_id (first_free_thread_no + 3, 1), |
200 |
|
l4_global_id (first_free_thread_no & 0xffff, 1)); |
201 |
|
|
202 |
return server_thread; |
return server_thread; |
203 |
} |
} |
204 |
|
|
254 |
|
|
255 |
err = task_class_init (); |
err = task_class_init (); |
256 |
if (err) |
if (err) |
257 |
panic ("task_class_init: %i\n", err); |
panic ("task_class_init: %i", err); |
258 |
|
|
259 |
err = hurd_cap_bucket_create (&bucket); |
err = hurd_cap_bucket_create (&bucket); |
260 |
if (err) |
if (err) |
261 |
panic ("bucket_create: %i\n", err); |
panic ("bucket_create: %i", err); |
262 |
|
|
263 |
create_bootstrap_caps (bucket); |
create_bootstrap_caps (bucket); |
264 |
|
|
267 |
task_server, bucket); |
task_server, bucket); |
268 |
|
|
269 |
if (err) |
if (err) |
270 |
panic ("pthread_create_from_l4_tid_np: %i\n", err); |
panic ("pthread_create_from_l4_tid_np: %i", err); |
271 |
pthread_detach (manager); |
pthread_detach (manager); |
272 |
|
|
273 |
bootstrap_final (); |
bootstrap_final (); |