From d17f01373231c13da5ff530f9c633ba4277f9954 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Mon, 12 Mar 2012 23:07:47 -0700 Subject: [PATCH] model: add thread ID assignment function --- model.c | 9 +++++++++ model.h | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/model.c b/model.c index cd431532..b44a911b 100644 --- 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 5031c8b2..625d2726 100644 --- 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__ */ -- 2.34.1