projects
/
model-checker.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
snapshot: rename 'SnapShot' -> 'Snapshot'
[model-checker.git]
/
schedule.cc
diff --git
a/schedule.cc
b/schedule.cc
index b19a5d304ce4d28b5e8ad7064c7b37aa18afaf17..b1b41c3d88d579a766d5cd45ccf26815bc551a1e 100644
(file)
--- a/
schedule.cc
+++ b/
schedule.cc
@@
-1,3
+1,6
@@
+#include <string.h>
+#include <stdlib.h>
+
#include "threads.h"
#include "schedule.h"
#include "common.h"
#include "threads.h"
#include "schedule.h"
#include "common.h"
@@
-15,10
+18,12
@@
Scheduler::Scheduler() :
void Scheduler::set_enabled(Thread *t, bool enabled_status) {
int threadid=id_to_int(t->get_id());
if (threadid>=enabled_len) {
void Scheduler::set_enabled(Thread *t, bool enabled_status) {
int threadid=id_to_int(t->get_id());
if (threadid>=enabled_len) {
- bool * new_enabled=(bool *)malloc(sizeof(bool)*(threadid+1));
- memcpy(new_enabled, is_enabled, enabled_len*sizeof(bool));
+ bool *new_enabled = (bool *)snapshot_malloc(sizeof(bool) * (threadid + 1));
memset(&new_enabled[enabled_len], 0, (threadid+1-enabled_len)*sizeof(bool));
memset(&new_enabled[enabled_len], 0, (threadid+1-enabled_len)*sizeof(bool));
- free(is_enabled);
+ if (is_enabled != NULL) {
+ memcpy(new_enabled, is_enabled, enabled_len*sizeof(bool));
+ snapshot_free(is_enabled);
+ }
is_enabled=new_enabled;
enabled_len=threadid+1;
}
is_enabled=new_enabled;
enabled_len=threadid+1;
}
@@
-68,8
+73,8
@@
void Scheduler::wake(Thread *t)
}
/**
}
/**
- *
Remove one Thread from the scheduler. This implementation defaults to FIFO,
- *
if a
thread is not already provided.
+ *
Select a Thread. This implementation defaults to round-robin, if a
+ * thread is not already provided.
*
* @param t Thread to run, if chosen by an external entity (e.g.,
* ModelChecker). May be NULL to indicate no external choice.
*
* @param t Thread to run, if chosen by an external entity (e.g.,
* ModelChecker). May be NULL to indicate no external choice.
@@
-90,7
+95,10
@@
Thread * Scheduler::next_thread(Thread *t)
return NULL;
}
}
return NULL;
}
}
+ } else {
+ curr_thread_index = id_to_int(t->get_id());
}
}
+
current = t;
print();
return t;
current = t;
print();
return t;