X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=promise.cc;h=5197ed3a1e0376d1ea4f6060bcfa042f7cd4f0e9;hb=89c68eaa8c88e6ff491a7611fdf94abddd7378ae;hp=b051ef078bf8dbe92e817cb75b06a593b46ab1ca;hpb=bdef0741b8a01e16946d261bc2a657af5a683b3e;p=model-checker.git diff --git a/promise.cc b/promise.cc index b051ef0..5197ed3 100644 --- a/promise.cc +++ b/promise.cc @@ -1,8 +1,21 @@ #include "promise.h" +#include "model.h" +#include "schedule.h" -Promise::Promise(ModelAction *act, uint64_t value) { - this->value=value; - this->read=act; - this->numthreads=1; -} +bool Promise::increment_threads(thread_id_t tid) { + unsigned int id=id_to_int(tid); + if (id>=synced_thread.size()) { + synced_thread.resize(id+1, false); + } + if (synced_thread[id]) + return false; + + synced_thread[id]=true; + enabled_type_t * enabled=model->get_scheduler()->get_enabled(); + for(unsigned int i=0;iget_num_threads();i++) { + if (!synced_thread[id] && (enabled[id] == THREAD_ENABLED)) + return false; + } + return true; +}