X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=threads.cc;h=00e5c2fbd4a0f1287ac6b68b8be50a1a49b82bd8;hb=a575b5d5d2f0edab95e7e0ef8ca6e40b68e0bad9;hp=762bbff34c2463a3dbaf6179e3af3e1eb977ca8b;hpb=ad52dcdb3a75a69242a392165934e942cb76513b;p=model-checker.git diff --git a/threads.cc b/threads.cc index 762bbff..00e5c2f 100644 --- a/threads.cc +++ b/threads.cc @@ -5,6 +5,7 @@ #include #include +#include #include "common.h" #include "threads-model.h" #include "action.h" @@ -179,7 +180,6 @@ Thread::~Thread() { if (!is_complete()) complete(); - model->remove_thread(this); } /** @return The thread_id_t corresponding to this Thread object. */ @@ -197,3 +197,19 @@ void Thread::set_state(thread_state s) ASSERT(s == THREAD_COMPLETED || state != THREAD_COMPLETED); state = s; } + +/** + * Get the Thread that this Thread is waiting on + * @return The thread we are waiting on, if any; otherwise NULL + */ +Thread * Thread::waiting_on() const +{ + if (!pending) + return NULL; + + if (pending->get_type() == THREAD_JOIN) + return pending->get_thread_operand(); + else if (pending->is_lock()) + return (Thread *)pending->get_mutex()->get_state()->locked; + return NULL; +}