assert(!"thread_exit returned");
}
+/// int counter for assigning initial thread ids
+static uintptr_t threadid = 0;
+
#ifndef NDEBUG
/// Debugging assertions on thread queues
static void check_queue(struct thread *queue)
newthread->stack_top = (char *)newthread->stack_top
- (lvaddr_t)newthread->stack_top % STACK_ALIGNMENT;
+ // set thread's ID
+ newthread->id = threadid++;
+
// init registers
registers_set_initial(&newthread->regs, newthread, (lvaddr_t)thread_entry,
(lvaddr_t)newthread->stack_top,
return thread_self()->id;
}
+uintptr_t thread_get_id(struct thread *t)
+{
+ return t->id;
+}
+
void thread_set_id(uintptr_t id)
{
struct thread *me = thread_self();