From ad52dcdb3a75a69242a392165934e942cb76513b Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Mon, 25 Feb 2013 15:15:28 -0800 Subject: [PATCH] threads: construct Thread only with a given "parent" The Thread constructor really doesn't need to call thread_current(), since it will always be called from model-checker context. Clean up the use of default "parent_thrd" parameter and just pass NULL when we have no parent. --- model.cc | 2 +- threads-model.h | 4 ++-- threads.cc | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/model.cc b/model.cc index 24eb83d..436c337 100644 --- a/model.cc +++ b/model.cc @@ -2890,7 +2890,7 @@ void ModelChecker::run() { do { thrd_t user_thread; - Thread *t = new Thread(&user_thread, &user_main_wrapper, NULL); + Thread *t = new Thread(&user_thread, &user_main_wrapper, NULL, NULL); add_thread(t); do { diff --git a/threads-model.h b/threads-model.h index 30acd2d..2cd09ab 100644 --- a/threads-model.h +++ b/threads-model.h @@ -41,7 +41,7 @@ class ModelAction; class Thread { public: Thread(thread_id_t tid); - Thread(thrd_t *t, void (*func)(void *), void *a, Thread * parent_thrd = NULL); + Thread(thrd_t *t, void (*func)(void *), void *a, Thread *parent); ~Thread(); void complete(); @@ -128,7 +128,7 @@ private: int create_context(); /** @brief The parent Thread which created this Thread */ - Thread *parent; + Thread * const parent; /** @brief The THREAD_CREATE ModelAction which created this Thread */ ModelAction *creation; diff --git a/threads.cc b/threads.cc index cbedbb1..762bbff 100644 --- a/threads.cc +++ b/threads.cc @@ -151,7 +151,8 @@ Thread::Thread(thread_id_t tid) : * @param func The function that the thread will call. * @param a The parameter to pass to this function. */ -Thread::Thread(thrd_t *t, void (*func)(void *), void *a, Thread * parent_thrd) : +Thread::Thread(thrd_t *t, void (*func)(void *), void *a, Thread *parent) : + parent(parent), creation(NULL), pending(NULL), start_routine(func), @@ -171,7 +172,6 @@ Thread::Thread(thrd_t *t, void (*func)(void *), void *a, Thread * parent_thrd) : id = model->get_next_id(); user_thread->priv = this; - parent = parent_thrd ? parent_thrd : thread_current(); } /** Destructor */ -- 2.34.1