threads: don't call the userprogram interface for initial thread, just create it
[model-checker.git] / threads.cc
index dc7202e3aaa08e4e9dc00d8d6a40e6c04834180e..e0cb277563bb057c989be29379866ac8f090094b 100644 (file)
@@ -33,10 +33,6 @@ int Thread::create_context()
        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;
@@ -93,20 +89,6 @@ Thread::Thread(thrd_t *t, void (*func)(), void *a) {
        *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();
@@ -170,7 +152,7 @@ int main()
 
        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();