static void thread_dispose(struct thread *t)
{
- DEBUG("completed thread %d\n", thread_current()->index);
+ DEBUG("completed thread %d\n", thread_current()->id);
t->state = THREAD_COMPLETED;
stack_free(t->stack);
}
next = model->scheduler->next_thread();
if (next)
next->state = THREAD_RUNNING;
- DEBUG("(%d, %d)\n", curr ? curr->index : -1, next ? next->index : -1);
+ DEBUG("(%d, %d)\n", curr ? curr->id : -1, next ? next->id : -1);
if (!next)
return 1;
return thread_swap(model->system_thread, next);
memset(t, 0, sizeof(*t));
model_checker_assign_id(t);
- DEBUG("create thread %d\n", t->index);
+ DEBUG("create thread %d\n", t->id);
t->start_routine = start_routine;
t->arg = arg;
model = malloc(sizeof(*model));
memset(model, 0, sizeof(*model));
- /* First thread created (system_thread) will have index 1 */
+ /* First thread created (system_thread) will have id 1 */
model->used_thread_id = 0;
scheduler_init(model);
void model_checker_assign_id(struct thread *t)
{
- t->index = ++model->used_thread_id;
+ t->id = ++model->used_thread_id;
}
static void default_add_thread(struct thread *t)
{
- DEBUG("thread %d\n", t->index);
+ DEBUG("thread %d\n", t->id);
enqueue_thread(t);
}
int i;
for (i = 0; i < 10; i++) {
- printf("Thread %d, loop %d\n", thread_current()->index, i);
+ printf("Thread %d, loop %d\n", thread_current()->id, i);
if (i % 2)
atomic_load(obj);
}