projects
/
model-checker.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
unify style for returning pointers
[model-checker.git]
/
schedule.cc
diff --git
a/schedule.cc
b/schedule.cc
index 2498347c44cc6e2cb6cbb870a829465c318504db..67b40ec88a809d5c2bff10e07787481a7d934566 100644
(file)
--- a/
schedule.cc
+++ b/
schedule.cc
@@
-9,26
+9,27
@@
void Scheduler::add_thread(Thread *t)
readyList.push_back(t);
}
readyList.push_back(t);
}
-Thread *Scheduler::next_thread(void)
+Thread *
Scheduler::next_thread(void)
{
Thread *t = model->schedule_next_thread();
{
Thread *t = model->schedule_next_thread();
- print();
-
if (t != NULL) {
if (t != NULL) {
+ current = t;
readyList.remove(t);
readyList.remove(t);
- return t;
+ } else if (readyList.empty()) {
+ t = NULL;
+ } else {
+ t = readyList.front();
+ current = t;
+ readyList.pop_front();
}
}
- if (readyList.empty())
- return NULL;
- current = readyList.front();
- readyList.pop_front();
+ print();
- return
curren
t;
+ return t;
}
}
-Thread *Scheduler::get_current_thread(void)
+Thread *
Scheduler::get_current_thread(void)
{
return current;
}
{
return current;
}
@@
-39,7
+40,7
@@
void Scheduler::print()
printf("Current thread: %d\n", current->get_id());
else
printf("No current thread\n");
printf("Current thread: %d\n", current->get_id());
else
printf("No current thread\n");
- printf("
# T
hreads in ready list: %ld\n", readyList.size());
+ printf("
Num. t
hreads in ready list: %ld\n", readyList.size());
std::list<Thread *>::iterator it;
for (it = readyList.begin(); it != readyList.end(); it++)
std::list<Thread *>::iterator it;
for (it = readyList.begin(); it != readyList.end(); it++)