thread_init_early

本文介绍了一个操作系统内核中线程系统的早期初始化过程。该过程包括设置优先级队列、初始化线程列表、创建引导线程并将其设置为运行状态等关键步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

lk/kernel/thread.c:
thread_init_early:

/**  * @brief  Initialize threading system  *  * This function is called once, from kmain()  */ void thread_init_early(void) {     int i;

    DEBUG_ASSERT(arch_curr_cpu_num() == 0);

    /* initialize the run queues */     for (i=0; i < NUM_PRIORITIES; i++)         list_initialize(&run_queue[i]);

    /* initialize the thread list */     list_initialize(&thread_list);

    /* create a thread to cover the current running state */     thread_t *t = idle_thread(0);     init_thread_struct(t, "bootstrap");

    /* half construct this thread, since we're already running */     t->priority = HIGHEST_PRIORITY;     t->state = THREAD_RUNNING;     t->flags = THREAD_FLAG_DETACHED;     thread_set_curr_cpu(t, 0);     thread_set_pinned_cpu(t, 0);     wait_queue_init(&t->retcode_wait_queue);     list_add_head(&thread_list, &t->thread_list_node);     set_current_thread(t); }

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值