model: add thread ID assignment function
authorBrian Norris <banorris@uci.edu>
Tue, 13 Mar 2012 06:07:47 +0000 (23:07 -0700)
committerBrian Norris <banorris@uci.edu>
Tue, 13 Mar 2012 06:07:47 +0000 (23:07 -0700)
model.c
model.h

diff --git a/model.c b/model.c
index cd4315327e280a04a6eca3108e1d0cd92531f7ad..b44a911b531f6245b5523287d4887cec1a752ab8 100644 (file)
--- a/model.c
+++ b/model.c
@@ -14,6 +14,10 @@ void model_checker_init(void)
 {
        model = malloc(sizeof(*model));
        memset(model, 0, sizeof(*model));
+
+       /* First thread created (system_thread) will have index 1 */
+       model->used_thread_id = 0;
+
        scheduler_init(model);
 }
 
@@ -26,3 +30,8 @@ void model_checker_exit(void)
        free(sched);
        free(model);
 }
+
+void model_checker_assign_id(struct thread *t)
+{
+       t->index = ++model->used_thread_id;
+}
diff --git a/model.h b/model.h
index 5031c8b207c12c1e4123fbe829e4daa0f0a0df29..625d2726fe775921f981e5d666426eb85cb32148 100644 (file)
--- a/model.h
+++ b/model.h
@@ -4,11 +4,15 @@
 struct model_checker {
        struct scheduler *scheduler;
        struct thread *system_thread;
+
+       /* "Private" fields */
+       int used_thread_id;
 };
 
 extern struct model_checker *model;
 
 void model_checker_init(void);
 void model_checker_add_system_thread(struct thread *t);
+void model_checker_assign_id(struct thread *t);
 
 #endif /* __MODEL_H__ */