sched: implement task id allocation; remove thread id bitmap
This commit is contained in:
@@ -6,8 +6,6 @@
|
||||
|
||||
#define THREAD_CAST(p) OBJECT_C_CAST(struct thread, thr_base, &thread_type, p)
|
||||
|
||||
static DECLARE_BITMAP(thread_ids, THREAD_MAX) = {0};
|
||||
|
||||
static struct object_type thread_type = {
|
||||
.ob_name = "thread",
|
||||
.ob_size = sizeof(struct thread),
|
||||
@@ -33,8 +31,7 @@ struct thread *thread_alloc(void)
|
||||
|
||||
kern_status_t thread_init(struct thread *thr, uintptr_t ip)
|
||||
{
|
||||
thr->tr_id = bitmap_lowest_clear(thread_ids, THREAD_MAX);
|
||||
bitmap_set(thread_ids, thr->tr_id);
|
||||
thr->tr_id = thr->tr_parent->t_next_thread_id++;
|
||||
|
||||
thr->tr_prio = PRIO_NORMAL;
|
||||
thr->tr_state = THREAD_READY;
|
||||
@@ -85,8 +82,7 @@ struct thread *create_kernel_thread(void (*fn)(void))
|
||||
struct task *kernel = kernel_task();
|
||||
struct thread *thr = thread_alloc();
|
||||
|
||||
thr->tr_id = 1;
|
||||
bitmap_set(thread_ids, 1);
|
||||
thr->tr_id = kernel->t_next_thread_id++;
|
||||
|
||||
thr->tr_parent = kernel;
|
||||
thr->tr_prio = PRIO_NORMAL;
|
||||
@@ -110,8 +106,7 @@ struct thread *create_idle_thread(void)
|
||||
struct task *idle = idle_task();
|
||||
struct thread *thr = thread_alloc();
|
||||
|
||||
thr->tr_id = 0;
|
||||
bitmap_set(thread_ids, 0);
|
||||
thr->tr_id = idle->t_next_thread_id++;
|
||||
|
||||
thr->tr_parent = idle;
|
||||
thr->tr_prio = PRIO_NORMAL;
|
||||
|
||||
Reference in New Issue
Block a user