#include #include #include static struct object_type thread_type = { .ob_name = "thread", .ob_size = sizeof(struct thread), }; kern_status_t thread_object_type_init(void) { return object_type_register(&thread_type); } struct thread *thread_alloc(void) { struct object *thread_obj = object_create(&thread_type); if (!thread_obj) { return NULL; } struct thread *t = object_data(thread_obj); memset(t, 0x00, sizeof *t); return t; } void thread_free(struct thread *thr) { } struct thread *current_thread(void) { struct cpu_data *cpu = get_this_cpu(); if (!cpu) { return NULL; } struct thread *out = cpu->c_current_thread; put_cpu(cpu); return out; } bool need_resched(void) { return (current_thread()->tr_flags & THREAD_F_NEED_RESCHED) != 0; }