X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;ds=sidebyside;f=schedule.cc;h=e75e7eca7f8bda92295493f8f48bfa1f9056743c;hb=82df62c2b0805848b87bb71df5b66a4a66f8e25d;hp=444e1a82982535339f241d5eb203fddf1d00a15a;hpb=9d9c0f4e9909c2f58889e198a065479003f7bced;p=model-checker.git diff --git a/schedule.cc b/schedule.cc index 444e1a8..e75e7ec 100644 --- a/schedule.cc +++ b/schedule.cc @@ -7,6 +7,32 @@ #include "model.h" #include "nodestack.h" +/** + * Format an "enabled_type_t" for printing + * @param e The type to format + * @param str The output character array + */ +static void enabled_type_to_string(enabled_type_t e, char *str) +{ + const char *res; + switch (e) { + case THREAD_DISABLED: + res = "disabled"; + break; + case THREAD_ENABLED: + res = "enabled"; + break; + case THREAD_SLEEP_SET: + res = "sleep"; + break; + default: + ASSERT(0); + res = NULL; + break; + } + strcpy(str, res); +} + /** Constructor */ Scheduler::Scheduler() : enabled(NULL), @@ -184,19 +210,22 @@ Thread * Scheduler::next_thread(Thread *t) break; } if (curr_thread_index == old_curr_thread) { - print(); + if (DBG_ENABLED()) + print(); return NULL; } } } else if (t->is_model_thread()) { /* model-checker threads never run */ + ASSERT(false); t = NULL; } else { curr_thread_index = id_to_int(t->get_id()); } current = t; - print(); + if (DBG_ENABLED()) + print(); return t; } @@ -215,8 +244,13 @@ Thread * Scheduler::get_current_thread() const */ void Scheduler::print() const { - if (current) - DEBUG("Current thread: %d\n", id_to_int(current->get_id())); - else - DEBUG("No current thread\n"); + int curr_id = current ? id_to_int(current->get_id()) : -1; + + model_print("Scheduler: "); + for (int i = 0; i < enabled_len; i++) { + char str[20]; + enabled_type_to_string(enabled[i], str); + model_print("[%i: %s%s]", i, i == curr_id ? "current, " : "", str); + } + model_print("\n"); }