schedule: move schedule.c --> schedule.cc
[model-checker.git] / libthreads.c
index 1b7f3db6ac79d37afc20b954f3423b4bd95dfae5..5a4c3a12f101f33252c042f7b5daf6c19d98cca4 100644 (file)
@@ -5,7 +5,7 @@
 #include "schedule.h"
 #include "common.h"
 
-/* global "model" struct */
+/* global "model" object */
 #include "model.h"
 
 #define STACK_SIZE (1024 * 1024)
@@ -47,7 +47,7 @@ static int create_context(struct thread *t)
 static int create_initial_thread(struct thread *t)
 {
        memset(t, 0, sizeof(*t));
-       model_checker_assign_id(t);
+       model->assign_id(t);
        return create_context(t);
 }
 
@@ -100,14 +100,14 @@ static void thread_wait_finish(void)
 /*
  * User program API functions
  */
-int thread_create(struct thread *t, void (*start_routine), void *arg)
+int thread_create(struct thread *t, void (*start_routine)(), void *arg)
 {
        int ret = 0;
 
        DBG();
 
        memset(t, 0, sizeof(*t));
-       model_checker_assign_id(t);
+       model->assign_id(t);
        DEBUG("create thread %d\n", t->id);
 
        t->start_routine = start_routine;
@@ -154,11 +154,11 @@ int main()
        struct thread user_thread;
        struct thread *main_thread;
 
-       model_checker_init();
+       model = new ModelChecker();
 
        main_thread = (struct thread *)malloc(sizeof(*main_thread));
        create_initial_thread(main_thread);
-       model_checker_add_system_thread(main_thread);
+       model->add_system_thread(main_thread);
 
        /* Start user program */
        thread_create(&user_thread, &user_main, NULL);
@@ -166,6 +166,8 @@ int main()
        /* Wait for all threads to complete */
        thread_wait_finish();
 
+       delete model;
+
        DEBUG("Exiting\n");
        return 0;
 }