if (ret)
return ret;
- /* start_routine == NULL means this is our initial context */
- if (!start_routine)
- return 0;
-
/* Initialize new managed context */
stack = stack_allocate(STACK_SIZE);
context.uc_stack.ss_sp = stack;
*user_thread = id;
}
-Thread::Thread(thrd_t *t) {
- /* system thread */
- user_thread = t;
- start_routine = NULL;
- arg = NULL;
-
- create_context();
- stack = NULL;
- state = THREAD_CREATED;
- id = model->get_next_id();
- *user_thread = id;
- model->set_system_context(&context);
-}
-
Thread::~Thread()
{
complete();
do {
/* Start user program */
- thrd_create(&user_thread, &user_main, NULL);
+ model->add_thread(new Thread(&user_thread, &user_main, NULL));
/* Wait for all threads to complete */
thread_wait_finish();