fix bugs with promise check...
authorBrian Demsky <bdemsky@uci.edu>
Sat, 3 Nov 2012 01:50:11 +0000 (18:50 -0700)
committerBrian Demsky <bdemsky@uci.edu>
Sat, 3 Nov 2012 01:50:11 +0000 (18:50 -0700)
promise.cc

index 5197ed3a1e0376d1ea4f6060bcfa042f7cd4f0e9..cbd45c2ffcf96f5398c49b29c4fdc2ef169c9b61 100644 (file)
@@ -4,7 +4,7 @@
 
 bool Promise::increment_threads(thread_id_t tid) { 
        unsigned int id=id_to_int(tid); 
-       if (id>=synced_thread.size()) {
+       if ( id >= synced_thread.size() ) {
                synced_thread.resize(id+1, false);
        }
        if (synced_thread[id])
@@ -12,9 +12,9 @@ bool Promise::increment_threads(thread_id_t tid) {
        
        synced_thread[id]=true;
        enabled_type_t * enabled=model->get_scheduler()->get_enabled();
-
+       unsigned int sync_size=synced_thread.size();
        for(unsigned int i=0;i<model->get_num_threads();i++) {
-               if (!synced_thread[id] && (enabled[id] == THREAD_ENABLED))
+               if ((i >= sync_size || !synced_thread[i]) && (enabled[i] != THREAD_DISABLED))
                        return false;
        }
        return true;