From: Brian Norris Date: Tue, 13 Mar 2012 06:07:47 +0000 (-0700) Subject: model: add thread ID assignment function X-Git-Tag: pldi2013~588 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=d17f01373231c13da5ff530f9c633ba4277f9954;p=model-checker.git model: add thread ID assignment function --- diff --git a/model.c b/model.c index cd43153..b44a911 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 5031c8b..625d272 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__ */